add preview:openfileinnewblock setting to open files in a new block from directory preview#3440
Conversation
…rom directory preview Implements the setting requested in wavetermdev#3387. When enabled, double-clicking a file (or pressing Enter on it) in the directory preview opens it in a new preview block instead of replacing the current block. Directories still navigate in place. Defaults to false, preserving current behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V5mUZ9htrAijaph5zpHp2j
WalkthroughAdds the Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Biome (2.5.3)frontend/types/gotypes.d.tsFile contains syntax errors that prevent linting: Line 1881: Expected a property, or a signature but instead found '#'.; Line 1881: Expected an expression, or an assignment but instead found ':'.; Line 1881: Expected an expression but instead found ']'.; Line 2194: Expected a statement but instead found '}'. 🔧 ESLint
ESLint install failed due to a network error. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/app/view/preview/preview-directory.tsx (1)
533-546: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider preserving the search state when opening a file in a new block.
Currently, opening a file unconditionally clears the search state. While this makes sense for in-place navigation where the directory view is completely replaced, clearing it when opening a file in a new block will instantly reset the user's background directory view. If users frequently open multiple files sequentially from the same search results, preserving the search state might provide a smoother UX.
frontend/app/view/preview/preview-directory.tsx#L533-L546: Consider movingsetSearch("")andglobalStore.set(model.directorySearchActive, false)inside theelseblock (for in-place navigation only).frontend/app/view/preview/preview-directory.tsx#L676-L689: Consider movingsetSearchText("")andglobalStore.set(model.directorySearchActive, false)inside theelseblock.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/app/view/preview/preview-directory.tsx` around lines 533 - 546, Preserve directory search state when opening files in a new block by moving the search-clearing calls inside the in-place navigation else branches: update the onDoubleClick handler around createBlock/model.goHistory and the corresponding handler around setSearchText so setSearch("") or setSearchText("") and globalStore.set(model.directorySearchActive, false) run only for in-place navigation. Apply this in frontend/app/view/preview/preview-directory.tsx at lines 533-546 and 676-689.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@frontend/app/view/preview/preview-directory.tsx`:
- Around line 533-546: Preserve directory search state when opening files in a
new block by moving the search-clearing calls inside the in-place navigation
else branches: update the onDoubleClick handler around
createBlock/model.goHistory and the corresponding handler around setSearchText
so setSearch("") or setSearchText("") and
globalStore.set(model.directorySearchActive, false) run only for in-place
navigation. Apply this in frontend/app/view/preview/preview-directory.tsx at
lines 533-546 and 676-689.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c88e5064-751c-41ce-a99b-f3003f214ade
📒 Files selected for processing (7)
docs/docs/config.mdxfrontend/app/view/preview/preview-directory.tsxfrontend/app/view/preview/previewenv.tsfrontend/types/gotypes.d.tspkg/wconfig/metaconsts.gopkg/wconfig/settingsconfig.goschema/settings.json
Closes #3387
What
Adds an opt-in setting
preview:openfileinnewblock(bool, defaults tofalse). When enabled, double-clicking a file — or pressing Enter on it — in the directory preview opens it in a new preview block (same behavior as the existing "Open Preview in New Block" context menu item) instead of replacing the current block. Directories still navigate in place, and with the setting off nothing changes.Implementation
Followed the add-config guide:
PreviewOpenFileInNewBlockadded toSettingsType(pkg/wconfig/settingsconfig.go), no default entry (false is the correct default, matchingpreview:showhiddenfiles)task generaterun —schema/settings.json,gotypes.d.ts,metaconsts.goregeneratedPreviewEnvgetSettingsKeyAtomnarrowing (previewenv.ts)getSettingsKeyAtomwith?? falsefallback inpreview-directory.tsx(double-click handler and Enter key handler)docs/docs/config.mdxwith a v0.15 badgeTesting
Manually verified in dev mode (
task dev) on macOS arm64:wsh setconfig preview:openfileinnewblock=true: double-click/Enter on a file opens a new preview block; applies live without restarttsc --noEmitclean for the touched files🤖 Generated with Claude Code
https://claude.ai/code/session_01V5mUZ9htrAijaph5zpHp2j