Skip to content

Resolve native chat workspaces from catalog snapshots - #26428

Merged
AmethystLiang merged 5 commits into
mainfrom
sta-9590-1-catalog-snapshots
Oct 9, 2026
Merged

AmethystLiang merged 5 commits into
mainfrom
sta-9590-1-catalog-snapshots

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​357 $\color{#cf222e}{\Huge{\mathbf{−}}}$​66 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​291
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​168 $\color{#cf222e}{\Huge{\mathbf{−}}}$​65 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​103

Problem

Native chat finds a workspace's folder by calling a getter that reads the live app store at call time. If the store changes during a lookup, the folder can come from a newer snapshot than the rest of the data. Workspaces that exist only in the detected list can also fail to resolve.

Solution

Native chat now reads workspace lists from one snapshot passed into each call and takes the folder path from that same snapshot. Detected-only workspaces resolve too. File links, attachments, mentions, image context, and model discovery share one lookup helper.

What Changed

  • Removed getKnownWorktreeById from native chat state shapes. Lookups use findKnownWorktreeById on the supplied snapshot.
  • lib/workspace-directory.ts resolves from a catalog snapshot: visible rows, detected rows, folder workspaces, and the floating path.
  • Model discovery uses getSettingsForWorktreeRuntimeOwner for the worktree.
  • Mention files and the quick-open list use a new useKnownWorktreeById selector.
  • Adds typed test fixtures for store rows.

Before: in some timing cases, chat file links, attachments, or mentions could resolve a different path, or none for detected-only workspaces. After: they resolve from one consistent snapshot.

Why

A getter closes over whichever store state was live when it was created, so it cannot guarantee one consistent view. Passing the snapshot in fixes that at the source. TODO: list the alternatives considered.

Linked Issue

No GitHub issue is linked. This is a partial fix for STA-9590 based on the branch name, so it does not close the full work.

Visual Proof

N/A: no intended visual change. The same paths are shown; only the data source changed.

Testing

Automated tests added or updated:

  • native-chat-attachment-upload.test.ts
  • native-chat-file-link.test.ts
  • native-chat-image-runtime-context.test.ts
  • native-chat-session-option-discovery.test.ts (new)
  • native-chat-tab-directory.test.ts
  • workspace-directory.test.ts (new)
  • quick-open-file-list.react.test.tsx

TODO: record test run results and the platforms tested.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

TODO

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.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance.

TODO: confirm these. SSH host IDs are kept in the lookup, and a test covers the ssh:box-1 case.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b18e41f7-cc6c-4bb1-8f20-926888610540
📥 Commits

Reviewing files that changed from the base of the PR and between 1c50443 and 7e8606f.

📒 Files selected for processing (5)
  • src/renderer/src/components/native-chat/native-chat-owner-selectors.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-mention-files.ts
  • src/renderer/src/components/quick-open-file-list-remote-catalog.react.test.tsx
  • src/renderer/src/components/quick-open-file-list.ts
  • src/renderer/src/store/selectors.ts

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


📝 Walkthrough

Walkthrough

Workspace path lookups now use known-worktree catalog snapshots and a shared store selector. Native chat and file-list components use catalog-based worktree paths. Tests cover host matching, detected worktrees, snapshot paths, remote file-list requests, and shared workspace fixtures.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 7e860

When the same worktree ID exists on different hosts, quick-open and native-chat mentions can request files using a path from the wrong host. Qualify the lookup before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 19 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: resolving native chat workspaces from catalog snapshots.
Description check Passed The description explains the problem, solution, affected areas, rationale, visual impact, and test coverage. It remains incomplete because test results and tested platforms are not recorded, AI disclo…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 53fb7543-39bc-49dc-9f75-93b04c9872ed
📥 Commits

Reviewing files that changed from the base of the PR and between 00a8250 and fddeb42.

📒 Files selected for processing (16)
  • src/renderer/src/components/native-chat/native-chat-attachment-upload.test.ts
  • src/renderer/src/components/native-chat/native-chat-attachment-upload.ts
  • src/renderer/src/components/native-chat/native-chat-file-link.test.ts
  • src/renderer/src/components/native-chat/native-chat-file-link.ts
  • src/renderer/src/components/native-chat/native-chat-image-runtime-context.test.ts
  • src/renderer/src/components/native-chat/native-chat-image-runtime-context.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-discovery.test.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-discovery.ts
  • src/renderer/src/components/native-chat/native-chat-tab-directory.test.ts
  • src/renderer/src/components/native-chat/native-chat-workspace-test-fixtures.ts
  • src/renderer/src/components/native-chat/use-native-chat-mention-files.ts
  • src/renderer/src/components/quick-open-file-list.react.test.tsx
  • src/renderer/src/components/quick-open-file-list.ts
  • src/renderer/src/lib/workspace-directory.test.ts
  • src/renderer/src/lib/workspace-directory.ts
  • src/renderer/src/store/selectors.ts
💤 Files with no reviewable changes (1)
  • src/renderer/src/components/native-chat/native-chat-image-runtime-context.ts

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

Comment thread src/renderer/src/store/selectors.ts Resolved
@AmethystLiang
AmethystLiang force-pushed the sta-9590-1-catalog-snapshots branch from fddeb42 to 56dd38e Compare October 8, 2026 18:47

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 603cdeb7-de58-47ba-9d50-8c61abe53bbd
📥 Commits

Reviewing files that changed from the base of the PR and between fddeb42 and 56dd38e.

📒 Files selected for processing (13)
  • src/renderer/src/components/native-chat/native-chat-file-link.test.ts
  • src/renderer/src/components/native-chat/native-chat-file-link.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-discovery.test.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-discovery.ts
  • src/renderer/src/components/native-chat/native-chat-tab-directory.test.ts
  • src/renderer/src/components/native-chat/native-chat-workspace-test-fixtures.ts
  • src/renderer/src/components/native-chat/use-native-chat-mention-files.ts
  • src/renderer/src/components/native-chat/use-native-chat-skills.test.ts
  • src/renderer/src/components/quick-open-file-list.ts
  • src/renderer/src/lib/workspace-directory.test.ts
  • src/renderer/src/lib/workspace-directory.ts
  • src/renderer/src/store/selectors.test.ts
  • src/renderer/src/store/selectors.ts

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

- Stop falling through to folder-path parsing once the catalog is loaded. The fallthrough let a folder workspace on another host resolve to a local path.
- Look up model discovery settings by the worktree's runtime owner instead of the agent tab's, so a session's model list matches the worktree it runs in.
@AmethystLiang
AmethystLiang force-pushed the sta-9590-1-catalog-snapshots branch from 1c50443 to 7e8606f Compare October 9, 2026 00:36
@AmethystLiang
AmethystLiang merged commit 4ad8690 into main Oct 9, 2026
39 checks passed
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