Skip to content

fix(sidebar): empty environment children from cache poisoning + watcher gap - #905

Merged
jeonghun-jj-lee merged 1 commit into
mainfrom
fix/sidebar-empty-env-children
Sep 8, 2026
Merged

fix(sidebar): empty environment children from cache poisoning + watcher gap#905
jeonghun-jj-lee merged 1 commit into
mainfrom
fix/sidebar-empty-env-children

Conversation

@jeonghun-jj-lee

Copy link
Copy Markdown
Contributor

Problem

Expanding a resolved (non-workspace) environment root in the sidebar shows nothing beneath it — the chevron rotates but zero filesystem children render, despite the directory having contents.

Root cause

Two bugs combine:

1. Cache poisoning (sidebar_webview.ts)

readDirectoryEntries catches all errors and returns []. The webview caches this as childrenCache[path] = []. Because [] is truthy in JavaScript, all !childrenCache[path] guards evaluate false, permanently suppressing re-requests for that path.

2. Watcher gap (sidebar_view.ts)

setupWatcher uses createFileSystemWatcher('**/*') (workspace-scoped) and the handler checks getWorkspaceFolder(uri) — both drop non-workspace URIs. Resolved environments (source: "resolved", auto-surfaced from the registry) are not workspace folders, so filesystem changes inside them never invalidate the poisoned cache.

Fix

Fix 1: Never cache empty arrays — delete the key on empty responses so undefined (falsy) lets future renders re-request children.

Fix 2: Create per-path FileSystemWatcher using RelativePattern for resolved environment paths. Watchers are refreshed on roots changes, deduped by path set, debounced (300ms), and disposed cleanly.

Bonus: Added console.warn to readDirectoryEntries catch block for future diagnosis.

Verification

  • pnpm -r build — clean
  • pnpm --filter amicode test — 2980 passed, 0 failures (including all 278 sidebar tests)

Closes #903

…er gap (#903)

Two bugs combined to make resolved (non-workspace) environment nodes expand
with nothing beneath them:

1. Cache poisoning: readDirectoryEntries swallows errors and returns [].
   The webview cached [] (truthy), so all !childrenCache[path] guards
   evaluated false, permanently suppressing re-requests.

   Fix: never cache empty arrays — delete the key instead, leaving
   undefined (falsy) so future renders re-request children.

2. Watcher gap: setupWatcher uses createFileSystemWatcher('**/*') which
   is workspace-scoped, and the handler checks getWorkspaceFolder(uri)
   which drops non-workspace URIs. Resolved environments (source:
   'resolved', auto-surfaced from the registry) are not workspace
   folders, so filesystem changes inside them never invalidated the
   poisoned cache.

   Fix: create per-path FileSystemWatcher using RelativePattern for
   resolved environment paths. Watchers are refreshed on roots changes,
   deduped, debounced (300ms), and disposed cleanly.

Also adds console.warn to readDirectoryEntries catch block for future
diagnosis visibility.
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 98ddeef0-9e9a-49b1-9dc1-672cd558aa5f


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.

@jeonghun-jj-lee
jeonghun-jj-lee merged commit 55769a4 into main Sep 8, 2026
10 checks passed
@jeonghun-jj-lee
jeonghun-jj-lee deleted the fix/sidebar-empty-env-children branch September 8, 2026 20:36
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.

1 participant