Skip to content

fix(web): recreated folders no longer show deleted files - #36590

Merged
juliusmarminge merged 4 commits into
pingdotgg:mainfrom
StiensWout:t3/refresh-recreated-directories
Nov 14, 2026
Merged

juliusmarminge merged 4 commits into
pingdotgg:mainfrom
StiensWout:t3/refresh-recreated-directories

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

An already mounted Files panel can show deleted filenames after a folder disappears and is recreated under the same name. A successful child read can race with a parent refresh that observes the removal, leaving the old listing marked as loaded.

Invalidate removed child branches when their parent listing arrives, and prevent reads and queued refreshes belonging to a removed folder from updating its replacement. Preserve reads of newly created children whose parent cache has not refreshed yet.

Found in Wout's bughunt and independently confirmed by Claude Opus 5.5 on ac180919a67fa99bc34dba6c3ad0a970c22764c9. Reconfirmed on current main e80468ba256a025c68dbf331c76a7cca46f71dfc: the supplied reloads a removed folder browser test expected src/new.ts and received src/old.ts.

Validation: the same reproduction passes with the fix. The adjacent Files browser tests and pnpm exec vp run check:changed pass. Coverage uses the public hook in Chromium with controlled directory responses. Full-app filesystem race reproduction and scenarios:prove remain unproven; ordinary child ENOENT already clears the loaded marker and does not reproduce this ordering. Web and desktop share this hook; no native shell, mobile, RPC contract, provider or permission behavior changes.

Size: medium, confined to the directory hook and its existing browser tests, with no storage or migration.

Council review

Reviewer Round 1 Round 2
Claude Opus 5.5 7/10 9/10
GPT 6.1 Sol 6/10 9/10

Round one found stale shared-query reuse, removed-generation refresh ownership, invalidation against old ancestor listings, and inadequate overlap coverage. These findings were addressed in one fix batch, followed by fresh second-round reviews of the delta. Replacement reads wait for a detached query to settle before fetching fresh data. Local cubic raised the ancestor rescan concern as P2, addressed by scoping invalidation to the arriving parent listing. Cubic could not load repository context for the fork.

Round two has no blockers or shoulds. Deferred nits: an older parent response can discard a newer child listing and require another read; grouping per-folder state would reduce future cleanup coupling. Neither needs expanding this fix. Remaining limits: a hung detached read delays its replacement; another consumer independently refreshing the same atom could still supply an overlapping snapshot. No full-app filesystem race or large-tree performance claim is made.

Created with GPT 6.1 Sol (lead, hunter, review and fixes) and Claude Opus 5.5 (independent verification, build, trim and review) in T3 Code through the Codex and Claude harnesses.

Closes #36589

StiensWout and others added 3 commits November 14, 2026 09:33
When a refresh's parent listing no longer holds a folder, the file tree kept
that folder's cached listing and loaded marker, so recreating it showed the
old children and a late read of the old folder could reattach them.

An authoritative listing now purges every detached folder's cache, loaded,
requested and error state, and drops its in-flight request so a late read is
ignored and a queued follow-up refresh does not start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: GPT 6.1 Sol <codex@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: GPT 6.1 Sol <codex@openai.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 14, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 1e39bc3

Macroscope's review found this PR approvable — The file browser now clears stale folder listings and ignores outdated reads so recreated folders no longer display deleted files. The change is limited to in-memory display state and directory reads, without modifying files or product defaults.

No code changes detected at 606ec29. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 14, 2026
…directories

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge
juliusmarminge force-pushed the t3/refresh-recreated-directories branch from f50df2d to 606ec29 Compare November 14, 2026 08:42
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1e39bc3 and 606ec29.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

useDirectoryEntries now reconciles cached listings and request state when parent listings change. Browser tests cover retaining a loaded child during refresh and loading the current contents when a removed folder reappears.

Changes: Directory listing reconciliation

Layer / File(s) Summary
Listing and request reconciliation
apps/web/src/components/files/useDirectoryEntries.ts, apps/web/src/components/files/useDirectoryEntries.browser.test.tsx
The hook tracks listings and detached requests, ignores stale results, and removes cached state for descendants no longer present. Tests cover refresh behavior and reloading a folder after it is removed and recreated.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: juliusmarminge, saphid

Merge Risk: Minimal · previous review 1e39b

This change makes the Files panel load the current contents when a folder is deleted and recreated under the same name, instead of showing the old files. The change is confined to a client-side hook and its tests, with no data or contract changes. The mounted-panel path was not tested end to end, but no concrete defect was established, so it is ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and the scenario: a recreated folder no longer shows deleted files. It matches the changeset, which invalidates removed child listings in useDirectoryEntries and prevents stale…
Description check Passed The description covers the problem, the change, scope, and verification. It has a clear problem statement, an explanation of the invalidation and race handling, and a reproduction result from the supp…
Linked Issues check Passed Issue #36589 requires that a recreated folder load its current contents after a parent listing observes the removal, even when a concurrent child read had succeeded with old contents. The whole-PR dif…
Out of Scope Changes check Passed All changes sit in the two files named in the PR: the directory hook (useDirectoryEntries.ts) and its browser test (useDirectoryEntries.browser.test.tsx). The hook changes (listings map, detached requ…
Full details: Title check

Explanation

The title names the fix and the scenario: a recreated folder no longer shows deleted files. It matches the changeset, which invalidates removed child listings in useDirectoryEntries and prevents stale reads from updating a replacement folder. It follows the conventional commit format from the template.

Full details: Description check

Explanation

The description covers the problem, the change, scope, and verification. It has a clear problem statement, an explanation of the invalidation and race handling, and a reproduction result from the supplied browser test. It links issue #36589 and states the limits of the verification, including the unproven full-app filesystem race. It uses a council review table that the template does not require. The Verification section lists the adjacent tests and check command, and it names what was not checked. It does not include the before/after screenshots that the template asks for on UI changes, but this change is a hook-level behavior fix with no visual change, so the omission is acceptable. The description is mostly complete.

Full details: Linked Issues check

Explanation

Issue #36589 requires that a recreated folder load its current contents after a parent listing observes the removal, even when a concurrent child read had succeeded with old contents. The whole-PR diff of apps/web/src/components/files/useDirectoryEntries.ts addresses this path:

  • When a successful parent listing lacks a requested child directory, the hook deletes that path from listings, loaded, requested, requests, and followUpRefreshes, and clears its loading and error state.
  • The in-flight request for the removed path moves to detachedRequests. Its .then returns early when requests.current.get(directoryPath) !== request, so the stale old-contents read cannot update directories.
  • A new read for the same path awaits the detached request before it queries. Its result applies only when it is still the current request.
  • Queued follow-up refreshes run only while the path remains in requested.
    The browser test reloads a removed folder when it reappears under the same name in useDirectoryEntries.browser.test.tsx covers the issue ordering: old child read, parent removal, then recreation with src/new.ts, and checks that the replacement listing is loaded and refresh callers share one promise. The mock change keys controlled queries by generation and request, so test runs stay isolated.
    Limits: I did not run the tests. The PASS rests on code reading and the author's reported results. The code path that keeps reads of newly created children before the parent refresh was not traced in full; the diff shows no explicit guard for that case, but the author reports it is covered.
Full details: Out of Scope Changes check

Explanation

All changes sit in the two files named in the PR: the directory hook (useDirectoryEntries.ts) and its browser test (useDirectoryEntries.browser.test.tsx). The hook changes (listings map, detached requests, removed-descendant purge, guarded follow-ups and result application) implement the stale-listing fix in #36589. The test changes add the removal/recreation regression test and the generation-keyed mock, which support that fix. The mutation-rescan test extension checks that a child load followed by a root refresh keeps both entries, which relates to the same listing-merge behavior. The PR reports no changes to native shell, mobile, RPC contracts, providers, permissions, storage, or migrations, and the diff does not show any. No unrelated changes were found.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f315da3 and 1e39bc3.

Files selected for processing: 2

  • apps/web/src/components/files/useDirectoryEntries.browser.test.tsx
  • apps/web/src/components/files/useDirectoryEntries.ts

Limit details: You’ve used all 10 included reviews currently available.

@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Expand src/old.ts in the mounted Files panel. Refresh with a real child response delayed across a root listing that reports src missing. Deliver the old child response, recreate src containing only new.ts, refresh and expand it. Genuine RPC messages were scheduled deterministically; directory responses were not fabricated. Both sides used Chromium, 1280×800, light theme, fresh isolated state and identical synthetic data.

Before After
Before: recreated src incorrectly displays old.ts After: recreated src correctly displays new.ts
d2bdd58eef 606ec29007
Before recording After recording

Scenario and filesystem driver

scenarios:prove exited 0: failsOnBase=true, passesOnHead=true.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 14, 2026
@juliusmarminge
juliusmarminge merged commit 28f1786 into pingdotgg:main Nov 14, 2026
54 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 14, 2026
Pipyakas pushed a commit to Pipyakas/t3code that referenced this pull request Nov 15, 2026
…6590)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
(cherry picked from commit 28f1786)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Recreated folders can show deleted files in the Files panel

2 participants