Commit 1ebc9a0
Add a realistic preview mock filesystem and file RPC support (#3042)
The preview environment had no useful filesystem model, which limited
FileSystem integration work and made file-oriented previews hard to
exercise. This change adds a realistic mock filesystem rooted at
`/Users/mike` and teaches `mockwaveenv` to answer the core file RPCs
used by preview flows.
- **Mock filesystem dataset**
- Adds a dedicated mock filesystem module for preview usage.
- Seeds a macOS-style tree rooted at `/Users/mike` with 100+ file
entries across common directories like `Documents`, `Downloads`,
`Pictures`, `Projects`, and `waveterm`.
- Includes a small set of files with actual payloads so preview
consumers can render meaningful content:
- text (`.bashrc`)
- markdown (`meeting-notes.md`, repo docs)
- images (`.png`, `.jpg`)
- **Mock file RPC implementations**
- Wires preview-backed implementations for:
- `FileInfoCommand`
- `FileReadCommand`
- `FileListCommand`
- `FileJoinCommand`
- `FileListStreamCommand`
- `FileReadStreamCommand`
- Supports:
- `wsh://...` URIs and plain paths
- path normalization (`~`, relative paths, `.` / `..`)
- directory reads returning `entries`
- hidden file filtering via `FileListOpts.all`
- offset/size range reads
- streamed directory batches and file chunks
- **Preview behavior improvements**
- Makes directory previews behave more like a real local filesystem.
- Makes markdown-relative asset resolution via `FileJoinCommand` work
against a coherent tree.
- Gives future FileSystem integration work a stable preview substrate
instead of ad hoc RPC stubs.
- **Focused coverage**
- Adds preview mock tests for:
- filesystem population shape
- file metadata lookup
- file reads
- directory listing
- path joining
- stream responses
Example:
```ts
const joined = await env.rpc.FileJoinCommand(null as any, [
"wsh://local//Users/mike/Documents",
"../waveterm/docs",
"preview-notes.md",
]);
const file = await env.rpc.FileReadCommand(null as any, {
info: { path: "/Users/mike/.bashrc" },
});
```
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Co-authored-by: sawka <mike@commandline.dev>1 parent 896c89f commit 1ebc9a0
File tree
3 files changed
+659
-13
lines changed- frontend/preview/mock
3 files changed
+659
-13
lines changed
0 commit comments