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.
Workspace folder setting: scoped home-chat cwd + project-scoped brains provisioning #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Workspace folder setting: scoped home-chat cwd + project-scoped brains provisioning #2
Changes from all commits
5b939e2e825f20a1a46b6File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 The user-global
enabledPluginsskip is bypassed by a sibling entry point:ensureBrainsinsrc/routes/+page.sveltefirst runsensureBrainsPlugin(src/lib/brains-setup.ts), which unconditionally callsenablePlugin(BRAINS_PLUGIN_ID, "user")—claude plugin enable --scope user— beforebrains_provision_pluginever runs. On a fresh install, and wheneverclaude plugin listreports the project-scoped plugin as not enabled (it runs outside the workspace), sign-in still widens brains user-globally, defeating this guard. Apply theworkspace_scoped_enablecheck in theensureBrainsPluginenable step too (or enable with project scope/cwd there).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Nit: the new tests cover
project_enables_brains()(the pure JSON-parsing helper) well, but the actual scoping decision —brains_provision_pluginskipping the globalenabledPluginswrite whenworkspace_scoped_enable()is true, andbrains_is_provisionedOR-ing it in — has no test exercising that wiring end-to-end (e.g. via a tempHOME/settings override). Not blocking given the isolated logic is tested, but this is the actual behavior change users depend on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡
homeChatCwdreturns the rawworking_directorystring with no existence check and no~expansion, and it goes straight toCommand::current_dirin the spawn path (session.rs); the settings input is free text with placeholder~, so a typed~/foo, a relative path, or a since-deleted folder makes every home-chat spawn (warm spawn, first message, transcript summary) fail. Expand~, verify the directory exists, and fall back to the home dir otherwise; the Rustconfigured_workspace/project_enables_brainspair needs the same expansion or the provisioning decision silently misreads a tilde path.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 Medium:
homeChatCwd()returns the configured workspace string as-is with no existence check (and no tilde expansion — the settings input's~placeholder may lead a user to type a literal~/…path, which won't resolve). If the folder was later deleted/renamed, or was mistyped, this becomes thecwdpassed intoapi.startRun/startSessionfor every home-chat entry point (warm spawn, first message, transcript summary).Downstream,
warmSession()in+page.svelteswallows the resulting spawn failure in a barecatch { runId = ""; ...; actorLive = false; }with no user-visible message, and the retry on the next real send hits the same broken cwd — so a stale/invalid Workspace setting can silently break the entire home chat with no indication that the Workspace setting is the cause and no fallback to the home directory. Before this PR, home chat always usedhomeDir(), which is guaranteed to exist, so this failure mode didn't exist. Worth at least a lightweight check (does the dir exist / is it a dir) before adopting it as cwd, with a fallback to home + a surfaced warning.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changing or clearing
working_directoryafter a project-scoped provisioning leaves brains enabled nowhere the home chat runs: provision skipped the user-global enable based on the old workspace, new home-chat sessions now spawn in~(or the new folder) without the plugin, and nothing re-checks readiness until the next app boot (bootRouteis the only caller ofcheckReadiness). Silent degradation for the rest of the session. Re-run the readiness/provisioning check whenworking_directorychanges.