[Feature]: [Feature Request] Single-click file preview reuse — VSCode-style preview block
Feature description
Summary
When clicking a file in the Directory Preview block, Wave currently opens a new block each time. It would be great to have a “preview mode” that reuses an existing preview block instead, similar to how VSCode handles single-click file previews.
Desired Behavior
∙ Single-clicking a file in the Directory Preview block opens it in a designated “preview block” (e.g., the adjacent right block)
∙ If a preview block already exists, it gets updated in place rather than spawning a new block
∙ Double-clicking (or some explicit action) “pins” the file, locking the block so it’s no longer replaced on next click
∙ The preview block could be indicated visually (e.g., italic title, like VSCode)
Current Behavior
Every single-click on a file in the Directory block opens a brand new block, which quickly clutters the layout — especially when browsing through multiple markdown files or source files.
Use Case
Browsing a documentation folder or source tree and quickly previewing multiple .md / .txt / source files one by one, without accumulating a pile of open blocks.
Workaround
Manually running wsh setmeta -b
Additional Context
This is a common UX pattern in editors (VSCode, Zed, JetBrains IDEs). Given Wave’s block-based layout, a natural implementation might be: the directory block “remembers” a linked preview block ID, and routes single-click opens to that block.
Implementation Suggestion
No response
Anything else?
No response
Implementation Complete
This feature has been implemented with the following changes:
Solution Overview
When single-clicking a file in the Directory Preview block, Wave now:
- Reuses an existing preview block if one exists and is not pinned
- Creates a new preview block only if no preview block is linked to the source block
- Supports pinning - a pinned preview block will not be reused
Implementation Details
Meta Fields Added:
previewblock:sourceid- ID of the source directory blockpreviewblock:targetid- ID of the linked preview blockpreviewblock:ispinned- Whether the preview block is pinned
New Menu Item:
- "Open Preview in New Block" - Opens a file in a new preview block and links it to the source directory block
Behavior:
- Single-click on file → updates the linked preview block in place
- If no preview block exists → creates a new one to the right
- Double-click on file → creates a new preview block (legacy behavior)
- Pinned blocks are never overwritten
Files Modified
frontend/util/previewutil.ts- Core preview reuse logicfrontend/app/view/preview/preview-directory.tsx- File click handlingfrontend/app/view/preview/preview-model.tsx- Model with previewblock meta keysfrontend/app/block/blockenv.ts- BlockEnv type definitions
This matches the VSCode-style behavior described in the feature request.
您好,已经收到您的邮件,我会尽快给您回复。
Implementation Complete
This feature has been implemented with the following changes:
Solution Overview
When single-clicking a file in the Directory Preview block, Wave now:
- Reuses an existing preview block if one exists and is not pinned
- Creates a new preview block only if no preview block is linked to the source block
- Supports pinning - a pinned preview block will not be reused
Implementation Details
Meta Fields Added:
previewblock:sourceid- ID of the source directory blockpreviewblock:targetid- ID of the linked preview blockpreviewblock:ispinned- Whether the preview block is pinned
New Menu Item:
- "Open Preview in New Block" - Opens a file in a new preview block and links it to the source directory block
Behavior:
- Single-click on file → updates the linked preview block in place
- If no preview block exists → creates a new one to the right
- Double-click on file → creates a new preview block (legacy behavior)
- Pinned blocks are never overwritten
Code Changes
frontend/util/previewutil.ts
+export async function openFileInPreviewBlock(
+ sourceBlockId: string,
+ filePath: string,
+ connection: string,
+ isPinned: boolean = false
+): Promise<string | null> {
+ const previewBlockIdAtom = getBlockMetaKeyAtom(sourceBlockId, "previewblock:targetid");
+ const existingPreviewBlockId = globalStore.get(previewBlockIdAtom);
+
+ if (existingPreviewBlockId) {
+ const isPinnedAtom = getBlockMetaKeyAtom(existingPreviewBlockId, "previewblock:ispinned");
+ const isPinnedVal = globalStore.get(isPinnedAtom);
+
+ if (!isPinnedVal) {
+ await RpcApi.SetMetaCommand(TabRpcClient, {
+ oref: makeORef("block", existingPreviewBlockId),
+ meta: {
+ file: filePath,
+ connection: connection,
+ "previewblock:sourceid": sourceBlockId,
+ },
+ });
+ return existingPreviewBlockId;
+ }
+ }
+
+ const blockDef: BlockDef = {
+ meta: {
+ view: "preview",
+ file: filePath,
+ connection: connection,
+ "previewblock:sourceid": sourceBlockId,
+ "previewblock:ispinned": isPinned,
+ },
+ };
+
+ const newPreviewBlockId = await createBlockSplitHorizontally(blockDef, sourceBlockId, "after");
+
+ await RpcApi.SetMetaCommand(TabRpcClient, {
+ oref: makeORef("block", sourceBlockId),
+ meta: { "previewblock:targetid": newPreviewBlockId },
+ });
+
+ return newPreviewBlockId;
+}
frontend/app/view/preview/preview-directory.tsx
- addOpenMenuItems(menu, conn, finfo);
+ addOpenMenuItems(menu, conn, finfo, model.blockId);
+ const handleFileSingleClickCallback = useCallback(
+ (finfo: FileInfo) => {
+ if (finfo == null || finfo.isdir) {
+ return;
+ }
+ fireAndForget(async () => {
+ await openFileInPreviewBlock(model.blockId, finfo.path, conn ?? "");
+ });
+ },
+ [conn, model.blockId]
+ );
- onClick={() => setFocusIndex(idx)}
+ onClick={() => {
+ setFocusIndex(idx);
+ if (!row.original.isdir) {
+ handleFileSingleClick(row.original);
+ }
+ }}
frontend/app/view/preview/preview-model.tsx
+ simpleView: PrimitiveAtom<boolean>;
+ this.simpleView = atom<boolean>(false);
+ const sourceBlockId = get(this.blockAtom)?.meta?.["previewblock:sourceid"];
+ const isPinned = get(this.blockAtom)?.meta?.["previewblock:ispinned"] ?? false;
+
+ if (sourceBlockId) {
+ buttons.push({
+ elemtype: "iconbutton",
+ icon: "thumbtack",
+ title: isPinned ? "Unpin Preview" : "Pin Preview",
+ click: () => {
+ fireAndForget(async () => {
+ await togglePreviewBlockPinned(this.blockId);
+ });
+ },
+ } as IconButtonDecl);
+ }
Files Modified
frontend/util/previewutil.ts- Core preview reuse logicfrontend/app/view/preview/preview-directory.tsx- File click handlingfrontend/app/view/preview/preview-model.tsx- Model with previewblock meta keysfrontend/app/block/blockenv.ts- BlockEnv type definitions
This matches the VSCode-style behavior described in the feature request.