Skip to content

add preview:openfileinnewblock setting to open files in a new block from directory preview#3440

Open
jungmyunggi wants to merge 1 commit into
wavetermdev:mainfrom
jungmyunggi:feat/preview-open-file-in-new-block
Open

add preview:openfileinnewblock setting to open files in a new block from directory preview#3440
jungmyunggi wants to merge 1 commit into
wavetermdev:mainfrom
jungmyunggi:feat/preview-open-file-in-new-block

Conversation

@jungmyunggi

Copy link
Copy Markdown

Closes #3387

What

Adds an opt-in setting preview:openfileinnewblock (bool, defaults to false). 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:

  • PreviewOpenFileInNewBlock added to SettingsType (pkg/wconfig/settingsconfig.go), no default entry (false is the correct default, matching preview:showhiddenfiles)
  • task generate run — schema/settings.json, gotypes.d.ts, metaconsts.go regenerated
  • Key added to the PreviewEnv getSettingsKeyAtom narrowing (previewenv.ts)
  • Read via getSettingsKeyAtom with ?? false fallback in preview-directory.tsx (double-click handler and Enter key handler)
  • Documented in docs/docs/config.mdx with a v0.15 badge

Testing

Manually verified in dev mode (task dev) on macOS arm64:

  • Setting off (default): double-click/Enter replaces the current block as before
  • wsh setconfig preview:openfileinnewblock=true: double-click/Enter on a file opens a new preview block; applies live without restart
  • Directories navigate in place regardless of the setting
  • tsc --noEmit clean for the touched files

🤖 Generated with Claude Code

https://claude.ai/code/session_01V5mUZ9htrAijaph5zpHp2j

…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
@CLAassistant

CLAassistant commented Jul 21, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds the preview:openfileinnewblock boolean setting across backend configuration, JSON schema, and frontend types. Preview directory double-click and Enter actions now create a new preview block for files when enabled, while directories continue navigating in place. The setting is documented with a default of false.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding the new preview:openfileinnewblock setting for directory preview.
Description check ✅ Passed The description directly matches the implemented setting, behavior, defaults, and testing notes.
Linked Issues check ✅ Passed The PR fulfills #3387 by adding a configurable setting that opens file previews in a new block on double-click, with directories still navigating in place.
Out of Scope Changes check ✅ Passed All changes support the new preview setting; no clearly unrelated or extraneous code is evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.ts

File 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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
frontend/app/view/preview/preview-directory.tsx (1)

533-546: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider 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 moving setSearch("") and globalStore.set(model.directorySearchActive, false) inside the else block (for in-place navigation only).
  • frontend/app/view/preview/preview-directory.tsx#L676-L689: Consider moving setSearchText("") and globalStore.set(model.directorySearchActive, false) inside the else block.
🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between c99022c and c5bdebc.

📒 Files selected for processing (7)
  • docs/docs/config.mdx
  • frontend/app/view/preview/preview-directory.tsx
  • frontend/app/view/preview/previewenv.ts
  • frontend/types/gotypes.d.ts
  • pkg/wconfig/metaconsts.go
  • pkg/wconfig/settingsconfig.go
  • schema/settings.json

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.

[Feature]: Setting to Open file preview in new block with double click

2 participants