Repository navigation
Add seeding props to experimental_NewThreadComposer - #916
SawyerHood merged 2 commits into
Conversation
A plugin that stores a NewThreadRequest and re-opens it for editing had no way to seed the composer's provider, model, reasoning level, service tier, permission mode, or environment — every mount reset to project defaults, so saving an unrelated edit silently overwrote the stored configuration. Adds optional defaultProviderId / defaultModel / defaultReasoningLevel / defaultServiceTier / defaultPermissionMode / defaultEnvironment seed props: uncontrolled seeds that take precedence over project defaults, value-compared so a seed change after mount re-seeds even user-touched selections. defaultEnvironment maps CreateThreadEnvironmentArgs back to picker selections (including the managed-worktree base branch); unrepresentable variants are documented on the prop. Round-trip covered by tests: submitting a seeded, untouched composer reproduces the stored request. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Security review complete. I found no injection path, secret exposure, authorization bypass, or unsafe trust change.
The composer checks host and reuse seeds against current project data. The existing submission resolver still controls the final environment request.
| // fresh `defaultEnvironment` object each render. A signature change means | ||
| // the caller switched records: it re-seeds every selection (via the | ||
| // creation-options resetKey below), including ones the user had touched. | ||
| const seedSignature = JSON.stringify([ |
There was a problem hiding this comment.
🚨 slopcop/review — Include the project seed in the branch reset identity
This signature does not include defaultProjectId. A project change can reset selections but keep branchSeedOverridden from the prior record.
The second record then loses its branch seed when all other seed values match. Please include the project seed in this identity.
| initialServiceTier: projectDefaults?.serviceTier, | ||
| initialReasoningLevel: projectDefaults?.reasoningLevel, | ||
| initialPermissionMode: projectDefaults?.permissionMode, | ||
| initialProviderId: defaultProviderId ?? projectDefaults?.providerId, |
There was a problem hiding this comment.
🚨 slopcop/review — Preserve the execution source data for seeded values
This prop overrides project defaults in the UI. However, the hook treats the value as an untouched default and returns empty executionInputSources.
The server ignores providerId and model when their source keys are absent. It can replace these visible seeds with project defaults.
Please accept and restore the saved source map, or mark each provided seed as explicit. Add a round-trip test with explicit sources.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Code quality review complete. I found one blocking correctness issue and two branch seed defects.
The blocking issue loses execution source data. The server can then replace visible provider and model seeds with project defaults.
I added three inline comments with the exact failure paths and test requests.
| // seed were absent. | ||
| const selectedBranch = | ||
| pickedBranch ?? | ||
| (!branchSeedOverridden && |
There was a problem hiding this comment.
🚨 slopcop/review — Stop the old branch seed after an environment change
This callback changes the environment without setting branchSeedOverridden. If the user changes away and returns, the old branch seed becomes active again.
Please wrap environment and reuse changes to clear the seed. Add a test for the away-and-return path.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
End-to-end smoke test complete on commit e6236780.
I installed the Cascade example in a fresh development instance. I opened its host composer, entered a prompt, and submitted it.
The composer created a second thread. The route showed the new thread and no alert.
This test covers the basic route. It does not cover the blocking execution source round trip.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Request changes.
The seed props discard the saved executionInputSources. The server can then replace visible provider and model seeds with project defaults.
I also found two branch seed defects:
- A project change can keep the prior branch override state.
- An environment change can restore an old branch seed after the user returns.
Security and performance reviews found no issues.
The 12 focused tests pass. The app and plugin SDK typechecks pass. The live Cascade composer smoke test also passes.
The current tests use empty source data. Add explicit source data to the round-trip test and fix all three inline findings.
- Seeded execution fields now report caller-explicit provenance. The server discards a requested providerId/model whose source key is absent and re-derives it from the project's stored defaults, which silently undid the seeds. component-local scope never reports a providerId source at all, so the composer's provider could never survive spawn. - Include defaultProjectId in the seed identity, so a record that differs only by project clears the previous record's branch override. - Retire the branch seed when the user changes environment, so leaving and returning no longer resurrects it. The host-driven worktree-unavailable fallback keeps the raw setter, since it is not a user pick. Each fix is covered by a test verified to fail without it. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Addressed all three findings. Each fix has a test I verified fails without it. 1. Seeded values discarded by the server (blocking). Confirmed against Fix: each seeded field now reports 2. Branch reset identity missing the project. Fixed — 3. Stale branch seed after an environment round trip. Fixed — user environment changes (including the worktree picker, which routes through the same setter) retire the seed permanently. New test covers away-and-return: back in worktree mode the base branch falls to One deliberate exception: the host-driven "managed worktree unavailable → fall back to local" effect keeps the raw setter. It is a system correction, not a user pick, so it should not retire the seed. Also updated the Full suites green: 2199 |
The composer previously seeded only project and prompt, so re-opening a rule showed project defaults for model, reasoning, service tier, permission mode, and machine. Because the composer's submit IS the save, editing an unrelated field silently overwrote all of them. BB's experimental_NewThreadComposer now takes default* seeding props (get-bb/bb#916), so replay the rule's stored NewThreadRequest into them. Editing a rule is non-destructive again. Also refreshes the vendored plugin-SDK type declarations, which are a scaffold-time snapshot and did not yet know about the new props. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
## The bug `experimental_NewThreadComposer` exposed only `defaultProjectId` and `initialPrompt` as seeds. A plugin that stores the submitted `NewThreadRequest` and re-opens it for editing (e.g. bb-plugin-slopcop's `RuleEditor`, where the composer's submit IS the save) got a composer reset to project defaults on every mount — so re-saving after an unrelated edit silently overwrote the stored provider, model, permission mode, and environment. No warning, no diff. ## The fix Additive, optional seed props on `NewThreadComposerProps`: - `defaultProviderId`, `defaultModel`, `defaultReasoningLevel`, `defaultServiceTier`, `defaultPermissionMode` — fed into `useThreadCreationOptions` as initial values, taking precedence over the project's remembered defaults and falling back to today's behavior when omitted. - `defaultEnvironment` — a new pure mapping (`new-thread-environment-seed.ts`) inverts `resolveRootComposeThreadEnvironment`: args → encoded environment-picker selection + branch pick, including the managed-worktree base branch and unmanaged existing/new branch specs. Unrepresentable variants are documented on the prop (`project-default` seeds nothing; `personal` without `hostId` and an `unmanaged` non-null `path` cannot be encoded). Semantics (documented in the prop doc comments): they are seeds, not controlled values; the props are value-compared each render, and any change re-seeds every selection — including user-touched ones — via the creation-options `resetKey`, following the established `defaultProjectId` re-seed-during-render pattern. So switching between two saved records in one mounted composer reloads that record's values. Supporting fix in `useThreadCreationOptions`: a `resetKey` change cleared touched fields in a layout effect *after* the render's `executionInputSources` had been computed, so the reset render reported stale `explicit` provenance. The provenance memo now treats a pending reset as "nothing touched", mirroring the render-time rule `renderedThreadSelections` already applies. `RootComposeView` is untouched. The SDK testing harness's fake composer now echoes the seeds back on submit so plugin tests can cover store-then-restore. ## Round-trip test The property that prevents the data loss: feeding a submitted request back in as the `default*` props and submitting untouched must reproduce an equivalent request. - `new-thread-environment-seed.test.ts` — pure round trip of every environment variant (reuse, managed worktree named/default base, unmanaged existing/new/no branch) plus the documented unrepresentable cases. - `PluginNewThreadComposer.test.tsx` — renders the real composer (prompt box + query hooks mocked) and asserts: (1) a seeded, untouched submit `toEqual`s the stored request; (2) after a user touches the model, swapping in a second record's seeds re-seeds everything and submits that record exactly; (3) with no seed props, behavior is unchanged (project defaults). ## Also - Bundled type declarations regenerated via the repo scripts (`build-bundled-dts.mjs`, `generate-templates.mjs`). - bb-plugin-authoring skill: new props + store-then-restore pattern documented. - `docs/api_to_audit.md`: audit entry get-bb#6 for the seeding props. `turbo lint`/`typecheck` clean for app, plugin-sdk, server, templates; full `@bb/app` (2197 tests) and `@bb/plugin-sdk` suites pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5 <[email protected]>
The bug
experimental_NewThreadComposerexposed onlydefaultProjectIdandinitialPromptas seeds. A plugin that stores the submittedNewThreadRequestand re-opens it for editing (e.g. bb-plugin-slopcop'sRuleEditor, where the composer's submit IS the save) got a composer reset to project defaults on every mount — so re-saving after an unrelated edit silently overwrote the stored provider, model, permission mode, and environment. No warning, no diff.The fix
Additive, optional seed props on
NewThreadComposerProps:defaultProviderId,defaultModel,defaultReasoningLevel,defaultServiceTier,defaultPermissionMode— fed intouseThreadCreationOptionsas initial values, taking precedence over the project's remembered defaults and falling back to today's behavior when omitted.defaultEnvironment— a new pure mapping (new-thread-environment-seed.ts) invertsresolveRootComposeThreadEnvironment: args → encoded environment-picker selection + branch pick, including the managed-worktree base branch and unmanaged existing/new branch specs. Unrepresentable variants are documented on the prop (project-defaultseeds nothing;personalwithouthostIdand anunmanagednon-nullpathcannot be encoded).Semantics (documented in the prop doc comments): they are seeds, not controlled values; the props are value-compared each render, and any change re-seeds every selection — including user-touched ones — via the creation-options
resetKey, following the establisheddefaultProjectIdre-seed-during-render pattern. So switching between two saved records in one mounted composer reloads that record's values.Supporting fix in
useThreadCreationOptions: aresetKeychange cleared touched fields in a layout effect after the render'sexecutionInputSourceshad been computed, so the reset render reported staleexplicitprovenance. The provenance memo now treats a pending reset as "nothing touched", mirroring the render-time rulerenderedThreadSelectionsalready applies.RootComposeViewis untouched. The SDK testing harness's fake composer now echoes the seeds back on submit so plugin tests can cover store-then-restore.Round-trip test
The property that prevents the data loss: feeding a submitted request back in as the
default*props and submitting untouched must reproduce an equivalent request.new-thread-environment-seed.test.ts— pure round trip of every environment variant (reuse, managed worktree named/default base, unmanaged existing/new/no branch) plus the documented unrepresentable cases.PluginNewThreadComposer.test.tsx— renders the real composer (prompt box + query hooks mocked) and asserts: (1) a seeded, untouched submittoEquals the stored request; (2) after a user touches the model, swapping in a second record's seeds re-seeds everything and submits that record exactly; (3) with no seed props, behavior is unchanged (project defaults).Also
build-bundled-dts.mjs,generate-templates.mjs).docs/api_to_audit.md: audit entry [codex] Update sidebar manager row presentation #6 for the seeding props.turbo lint/typecheckclean for app, plugin-sdk, server, templates; full@bb/app(2197 tests) and@bb/plugin-sdksuites pass.🤖 Generated with Claude Code