Skip to content

Begin PreviewEnv narrowing for the preview widget#3065

Merged
sawka merged 3 commits intomainfrom
copilot/waveenv-narrowing-preview-widget
Mar 15, 2026
Merged

Begin PreviewEnv narrowing for the preview widget#3065
sawka merged 3 commits intomainfrom
copilot/waveenv-narrowing-preview-widget

Conversation

Copy link
Contributor

Copilot AI commented Mar 14, 2026

This starts the WaveEnv narrowing work for the preview widget, focused on wiring the preview view tree to the environment surface it already uses today. The change intentionally avoids adding new mock behavior and instead codifies the existing preview dependencies so the widget can move toward the same env-contract pattern used elsewhere.

  • Preview env contract

    • Adds PreviewEnv in frontend/app/view/preview/previewenv.ts
    • Narrows the preview widget to the specific env surface currently exercised by the preview stack:
      • file RPCs
      • suggestion RPCs
      • config/meta RPCs
      • ObjectService
      • fullConfigAtom
      • settings and connection atom helpers
      • preview-only electron quicklook hook
  • Preview model wiring

    • Updates PreviewModel to retain and use the injected waveEnv instead of reaching directly for global RPC/service helpers where the env already provides equivalents
    • Moves existing preview operations onto env.rpc, env.services, env.wos, and env-provided atom helpers without changing behavior
  • Preview component adoption

    • Switches the top-level preview view to useWaveEnv<PreviewEnv>() for suggestion fetch/dispose calls
    • Switches directory preview code to the narrowed env for:
      • config reads
      • directory file reads
      • copy/create/mkdir actions
      • quicklook dispatch
  • Preview-server compatibility

    • Adds a small type-level/runtime check that the existing mock wave env satisfies PreviewEnv
    • Keeps the change scoped to the functionality already present in the preview server

Example of the new pattern:

const env = useWaveEnv<PreviewEnv>();

const defaultSort = useAtomValue(env.getSettingsKeyAtom("preview:defaultsort")) ?? "name";

await env.rpc.FileReadCommand(TabRpcClient, {
    info: { path: await model.formatRemoteUri(dirPath, globalStore.get) },
});
  • Screenshot
    • Existing preview-server UI used for manual verification:

      Preview widgets screenshot


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

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

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

Deploying waveterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 813fe7a
Status: ✅  Deploy successful!
Preview URL: https://682bc1ca.waveterm.pages.dev
Branch Preview URL: https://copilot-waveenv-narrowing-pr.waveterm.pages.dev

View logs

Copilot AI changed the title [WIP] Add waveenv narrowing for the preview widget Begin PreviewEnv narrowing for the preview widget Mar 14, 2026
Copilot AI requested a review from sawka March 14, 2026 19:38
@sawka sawka marked this pull request as ready for review March 14, 2026 20:50
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 14, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • frontend/app/view/preview/preview-directory-utils.tsx - Refactored to use model.env
  • frontend/app/view/preview/preview-directory.tsx - Added useWaveEnv hook
  • frontend/app/view/preview/preview-model.tsx - Added env property, updated constructor
  • frontend/app/view/preview/preview.tsx - Added useWaveEnv hook
  • frontend/app/view/preview/previewenv.ts - New type definition

This PR is a clean refactoring that introduces the PreviewEnv WaveEnv narrowing type for the preview view. The changes follow the established pattern used by other WaveEnvSubset types in the codebase (TabBarEnv, BlockEnv, BadgeEnv, etc.). All RPC calls and global atoms have been properly migrated to use the env context.

Copy link
Contributor

@kilo-code-bot kilo-code-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • frontend/app/view/preview/preview-directory-utils.tsx - Refactored to use model.env
  • frontend/app/view/preview/preview-directory.tsx - Added useWaveEnv hook
  • frontend/app/view/preview/preview-model.tsx - Added env property, updated constructor
  • frontend/app/view/preview/preview.tsx - Added useWaveEnv hook
  • frontend/app/view/preview/previewenv.ts - New type definition

This PR is a clean refactoring that introduces the PreviewEnv WaveEnv narrowing type for the preview view. The changes follow the established pattern used by other WaveEnvSubset types in the codebase (TabBarEnv, BlockEnv, BadgeEnv, etc.). All RPC calls and global atoms have been properly migrated to use the env context.

@sawka sawka merged commit b1d7f42 into main Mar 15, 2026
7 checks passed
@sawka sawka deleted the copilot/waveenv-narrowing-preview-widget branch March 15, 2026 00:45
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