Skip to content

fix(bots): keep a Share dialog's cached skill listing and preview tied to the folders and build that produced them - #47895

Merged
AmethystLiang merged 6 commits into
mainfrom
AmethystLiang/fix-sta-16989-roots
Nov 24, 2026
Merged

AmethystLiang merged 6 commits into
mainfrom
AmethystLiang/fix-sta-16989-roots

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #47154 (STA-16989).

ELI5

A bot's Share dialog keeps the skill list it read so ticking stays fast. That kept list could end up holding the wrong skills: one read from a different folder than it was filed under, a list taken while a linked project's folder was briefly missing or swapped, or a slow, older request overwriting a newer one. This makes sure a kept list always matches the folders it was read from and the newest request.

Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​284 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​281
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​201 $\color{#cf222e}{\Huge{\mathbf{−}}}$​73 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​128

What Changed

  • One lookup, used for both the cache key and the scan. Each linked project's real folder is resolved once, while reading skills. The listing is filed under those folders and scans those exact folders; the scan no longer resolves the path a second time. Tools, memory and avatar reads no longer wait on these lookups, and builds without a dialog session skip the cache key entirely.
  • Unresolved or moved folders are never cached. If a linked project path can't be resolved, the listing is read fresh and not kept. Each project folder is checked before the read and again after the whole listing is done, shape checks included: same inode and change time, and it still resolves to itself. If it went missing, came back, or was swapped for a link meanwhile, that listing is not kept. A pick that was waiting on it reads again.
  • Older requests never replace newer ones.
    • Every build and pick now takes its place in its dialog when main receives it. The place is kept outside the cached listing and is never dropped while that dialog has a request running.
    • An older request that can't reuse the listing fails as "prepare again" without stopping or replacing a newer read.
    • The candidate store applies the same check where replacements run one at a time, so a late older build can't delete the newer preview.
    • The dialog already ignores results from older requests, so the user sees nothing.

Why

With the old code, a pick could reuse a listing read from a different folder than the one it was filed under:

  • after a transient ENOENT on a linked project path,
  • after a link was retargeted and rolled back,
  • after a folder went missing during the scan or shape checks.

And a slow older pick could abort the read a newer pick was waiting on, or replace the newer preview so it then expired. Resolving once and checking identity around the whole read is the smallest change that keeps the cache key and the content in step. No comparable: mechanical.

Linked Issue

STA-16989 (internal).

Visual Proof

N/A: no visible UI change. It only affects which cached skill listing and preview main keeps.

Testing

Invariant tests only. Each one fails when the fix it covers is reverted.

bot-share-skill-reads.test.ts:

  • A pick reuses the listing, looking the project up once per build: 1 walk, 2 lookups. Without single resolution, 3 lookups.
  • Never keeps or reuses a listing read while the project couldn't be looked up (a gated ENOENT). Without the fix, the next ENOENT pick reuses another folder's skills.
  • Keeps a listing under the folder it was read from when the link moves back meanwhile. Without the fix, the listing is stored under the wrong folder.
  • Never keeps a listing read while the project folder goes missing, or is swapped for a link, and is then put back (two cases). Without the fix, the next pick reuses [] or the other project's skills.
  • Never keeps a listing read while the folder goes missing during its shape checks. The first restored pick returns the skill, and the next pick does zero walks.
  • Never lets an older pick stop or replace a newer build, or stop the read a newer pick is waiting for.
  • Keeps a dialog's order while its builds run, however many dialogs open meanwhile.

bot-share-service.test.ts:

  • Never lets an older build's preview replace the newer one's. Without the fix, the older build succeeds and deletes the newer preview.

Local: the two test files pass (17 tests), oxfmt and oxlint are clean on the changed files, and pnpm tc:node passes. macOS only. The on-disk symlink tests are skipped on Windows.

Performance

  • Root lookups: each skills read resolves at most 20 linked project paths (BOT_MAX_SKILL_PROJECTS), in parallel and only on the skills branch. A warm pick adds about one lookup's latency and still does zero walks. Cold and sessionless builds do one lookup per project instead of two.
  • Folder checks: each actual walk adds 2 lstat calls and 1 realpath per linked project, also in parallel. Warm picks don't pay this.
  • Re-walks: a pick walks again only while a project path can't be resolved, or once after a folder changed during a read. That is the same walk the dialog does when it opens.
  • Memory: ordering is kept for at most 8 idle dialogs plus one per dialog with a request in flight, three numbers each, plus one number per bot for previews.

Risk

Level: Low. Main process only, in the Share dialog's skill listing and preview. The riskiest part is the new "prepare again" path for older requests: if ordering misfired, a current pick would show the "prepare again" error and the user would retry. A plain revert restores the previous behavior.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I stated the risk: what could break, for whom, and how to back it out
  • N/A with reason for visual proof
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (symlink tests skip on Windows; no remote or IPC contract change)
  • Targeted tests, lint and typecheck pass locally; CI covers the full suite

… from

Linked project roots are resolved once, on the skills branch, and the scan reads those exact
folders; a root that cannot be resolved makes the listing uncacheable; an older build or pick
never stops or replaces a newer listing. Sessionless builds skip the cache key.
…ed folder's listing is never kept

A dialog's call order lives apart from its cached listing and is kept while any of its calls
run, so an older pick can't stop a read a newer pick joined, however many dialogs open. A
linked project folder that goes missing, or is swapped, while it is scanned makes that listing
one never kept. The candidate store checks, where replacement runs in turn, that an older
build never replaces the bot's newer preview.
…s keeps it out of the cache

The linked projects' folders are checked again once the whole listing is done, shape checks
included, so a folder that went missing while a skill's shape was checked never leaves that
skill out of a reused listing.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Bot sharing now assigns positions to skill reads and picks, rejects stale work, and carries build positions into candidate preparation. Linked-project skill reads use resolved folder paths and report when a folder moves or disappears during a read. The changes add ordering and linked-project movement tests, plus a regression test for candidate preparation completing out of order.

Merge Risk: Minimal · up to 3e6d2

This change ties cached skill listings in the Share dialog to the folders and build that produced them, and rejects stale builds with a prepare-again error. No concrete defect was identified, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the Share dialog's cached skill listing and preview are now tied to the linked-project folders and the build that produced them. The changeset matches this. It adds fo…
Description check Passed The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure section, Review, Agent skill upstream bou…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the Share dialog's cached skill listing and preview are now tied to the linked-project folders and the build that produced them. The changeset matches this. It adds folder resolution and identity checks, and it orders builds and picks so older requests cannot replace newer ones. The title is specific, follows a conventional fix(scope) form, and is a single sentence. It is long at 114 characters, but that does not make it unclear.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure section, Review, Agent skill upstream boundary, and Checklist. The What Changed, Why, Testing, Performance, and Risk sections are detailed and give a reviewer enough context. Minor gaps: the Linked Issue entry is an internal reference (STA-16989) with no 'Fixes #' line, the Risk level is set to Low with a revert note, the 'Testing' checkbox for manual testing is not ticked, and the 'Review' section is left as a bare heading. The AI Disclosure section was removed, which is acceptable for an internal contributor. The description is mostly complete.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 835a2fa6-ccc0-4b3e-a3f0-c921bac8c220
Commits

Reviewing files that changed from the base of the PR and between 2ef459d and 3e6d222.

Files selected for processing: 2

  • src/main/bots/sharing/bot-share-service.test.ts
  • src/main/bots/sharing/bot-share-skill-reads.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@AmethystLiang
AmethystLiang merged commit 0b7fe2f into main Nov 24, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant