Match chat sessions to sites by site id instead of path#4131
Draft
bcotrim wants to merge 2 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
How AI was used in this PR
Claude implemented the change end-to-end from a scoped brief: traced the placement/matching flow, made the code changes, and extended the unit tests. I reviewed the diff via a guided code tour and steered the follow-up (extending id-matching to all call sites through a shared helper).
Proposed Changes
Chat sessions are bound to local sites via placements in
~/.studio/app.json, which have always stored a validatedsiteId— but the actual matching (sidebar grouping, empty-draft reuse, session header/preview owner lookup, and the main process' owner-server resolution) compared filesystem paths. Since site paths are name-derived and get reused, deleting a site and creating a new one at the same folder made the new site silently inherit the dead site's chat history.This PR switches matching to the site id, consistent with everything else per-site in
app.json(e.g.siteMetadata). All matching now routes through one shared, dependency-free helper (packages/common/ai/sessions/owner-site.ts) used by the renderer, the router, and the main process:ownerSitePath/ownerSiteNameare kept for display, and path matching remains as a defensive fallback for placements written beforesiteIdexisted (placements are read from user-editable JSON without schema validation), so no existing chats are dropped.Testing Instructions
Unit tests cover the matching semantics:
npm test -- packages/common/ai/sessions/tests apps/ui/src/components/site-listManual (agentic UI,
apps/ui):siteIdfrom one entry inaiSessionPlacementsin~/.studio/app.json— that chat should still group under its site via the path.Pre-merge Checklist
🤖 Generated with Claude Code