Skip to content

Add a realistic preview mock filesystem and file RPC support#3042

Merged
sawka merged 3 commits intomainfrom
copilot/improve-preview-mocking-ability
Mar 12, 2026
Merged

Add a realistic preview mock filesystem and file RPC support#3042
sawka merged 3 commits intomainfrom
copilot/improve-preview-mocking-ability

Conversation

Copy link
Contributor

Copilot AI commented Mar 12, 2026

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:

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" },
});

💡 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 in the docs.

Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 12, 2026

Deploying waveterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2778364
Status: ✅  Deploy successful!
Preview URL: https://52c6d485.waveterm.pages.dev
Branch Preview URL: https://copilot-improve-preview-mock.waveterm.pages.dev

View logs

Copilot AI changed the title [WIP] Add mock filesystem integration with diverse file entries Add a realistic preview mock filesystem and file RPC support Mar 12, 2026
@sawka sawka marked this pull request as ready for review March 12, 2026 17:47
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 12, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • frontend/preview/mock/mockfilesystem.ts - New mock filesystem implementation for testing
  • frontend/preview/mock/mockwaveenv.test.ts - Added tests for mock filesystem
  • frontend/preview/mock/mockwaveenv.ts - Added file-related RPC command handlers

The changes implement a mock filesystem for testing purposes, including:

  1. New mock filesystem (mockfilesystem.ts): A comprehensive mock filesystem implementation that provides file info, read, list, join, and streaming operations for testing.

  2. Test coverage (mockwaveenv.test.ts): Tests verifying the mock filesystem is properly rooted at /Users/mike and has at least 100 files and 10 directories, along with tests for all file operations.

  3. RPC handlers (mockwaveenv.ts): Added handlers for fileinfo, fileread, filelist, filejoin, filereadstream, and fileliststream commands using the new mock filesystem.

The implementation is well-structured with proper async generator support for streaming operations.

Verification performed: Reviewed all changed files and confirmed no issues found.

@sawka sawka merged commit 1ebc9a0 into main Mar 12, 2026
7 checks passed
@sawka sawka deleted the copilot/improve-preview-mocking-ability branch March 12, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants