Skip to content

feat(vault): tree search + hardened file-tree selection and read-error handling#147

Merged
vutuanlinh2k2 merged 3 commits into
mainfrom
linh/ui-revamp
Jun 26, 2026
Merged

feat(vault): tree search + hardened file-tree selection and read-error handling#147
vutuanlinh2k2 merged 3 commits into
mainfrom
linh/ui-revamp

Conversation

@vutuanlinh2k2

@vutuanlinh2k2 vutuanlinh2k2 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Reworks the vault tree panel: adds in-header search, makes file-tree selection robust across different tree renderers (incl. shadow-DOM/web-component rows and renderers that reuse a stale onSelect), stops treating directory clicks as file reads, and surfaces read failures instead of silently showing the empty state.

Closes #148

Changes

Search (feat(vault): promote search into the tree-panel header)

  • New filterNodes() — case-insensitive recursive name filter. Files survive when their name matches; a directory survives whole (with all children) when its own name matches, otherwise only when some descendant survives.
  • New query state drives a visibleRoot memo (empty query → full tree). The tree renders visibleRoot.
  • Header's "Vault / N files" label replaced by a full-width search <input> (aria-label="Search vault", Search… placeholder, focus ring). headerActions stay on the right. countFiles() removed.

Robust selection (fix(vault): open shadow-dom tree selections)

  • treeClickPath() resolves the clicked row via composedPath() (works when a shadow-DOM/web-component tree only exposes data-* attributes), falling back to closest('[data-type="item"]'). Wired through an onClickCapture handler on the scroll container.
  • resolveFilePath() normalizes leading/trailing slashes against the known filePaths set; resolvedSelectedPath memo keeps the controlled/selected path canonical.
  • handleTreeSelect + selectFileRef keep the select callback referentially stable while always running the latest path-validation and dirty-guard logic — fixes renderers that capture their initial onSelect and reuse it after re-render.

Directory + invalid-path handling (fix(vault): ignore directory selections)

  • Clicks only open rows whose data-item-type === 'file'; directory clicks are ignored.
  • A controlled selectedPath that doesn't resolve to a file is cleared (commitPath(null)) instead of being read as a file.

Read-error surfacing

  • New ReadErrorState component (message + Retry), backed by readError / reloadNonce state. Read failures now show a distinct error UI rather than collapsing into the "Open a vault document" empty state.

Tests

Adds tests/vault/vault-pane.test.ts cases covering: shadow-DOM row clicks via data attributes, renderers reusing a stale selection callback, ignoring directory selections, clearing a non-file controlled path, and read-failure surfacing + retry recovery.

Notes

  • Scoped to src/vault/VaultPane.tsx (+ tests). Uses existing theme tokens (border-border, text-foreground, hover:bg-muted, …).

🤖 Generated with Claude Code

Replace the "Vault N files" label with a full-width search input in the header row (refresh/new actions stay on the right) and filter the tree by name as you type.
@vutuanlinh2k2 vutuanlinh2k2 added the wip 🚧 Work in-progress label Jun 26, 2026
Bridge Pierre/RichFileTree row clicks through VaultPane so file rows that only update internal tree selection still drive the shared selected path and file read flow. Surface read failures separately from the no-selection empty state.

Closes #148
@vutuanlinh2k2 vutuanlinh2k2 removed the wip 🚧 Work in-progress label Jun 26, 2026
@vutuanlinh2k2 vutuanlinh2k2 marked this pull request as ready for review June 26, 2026 14:53

@tangletools tangletools left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Auto-approved PR — c3855dee

Blanket team auto-approval is enabled for this reviewer service.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.

tangletools · auto-approval · reason: blanket_auto_approve · 2026-06-26T14:54:05Z

@vutuanlinh2k2 vutuanlinh2k2 changed the title feat(vault): promote search into the tree-panel header feat(vault): tree search + hardened file-tree selection and read-error handling Jun 26, 2026
@vutuanlinh2k2 vutuanlinh2k2 merged commit 1a9e58e into main Jun 26, 2026
1 check passed
@vutuanlinh2k2 vutuanlinh2k2 deleted the linh/ui-revamp branch June 26, 2026 15:05
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.

[BUG] Open selected Vault files from shared VaultPane

2 participants