Repository navigation
Conversation
ymichael
force-pushed
the
bb/one-thread-action-target-on-every-surface-git-st-thr_7zxi74ezuz
branch
5 times, most recently
from
November 24, 2026 23:18
17833bd to
71fb9ff
Compare
Each surface that hosted thread actions built its own PluginThreadActionTarget:
the thread header passed the environment only when a new thread could reuse
it, while the sidebar, mobile recents, thread-list and Conductor passed any
environment, so one action saw different targets in different menus. The
thread-list and Conductor plugins carried byte-identical mappers, and git's
Commit useData fetched every open thread with threads.get to learn its
environment.
The host now builds the target from the thread id on experimental_useThread's
resolution (thread-state.ts readThread, shared by useThreadState and the new
non-hook threadReadSource) plus the environment's path. Menus,
experimental_useThreadActions and experimental_bulkThreads take { id } and read
only the id; item, bulkItem and the new
PluginThreadActionDataInput.experimental_threads all read that one
resolution. Git reads environments from experimental_threads. The mappers in
thread-list and Conductor are gone. Plugin SDK 0.6.192.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…thread The thread action target now carries the environment's setup status and its machine's lifecycle, so core's New thread in environment hides for a failed setup or a machine being removed instead of ending in an error toast. Held sidebar entries get both from the server's thread list entry (joined from the environment and its host), and an environment status change refreshes the sidebar threads in it. The thread page's own button uses the same rule, which now includes environments that are still provisioning. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d host lifecycle Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/one-thread-action-target-on-every-surface-git-st-thr_7zxi74ezuz
branch
from
November 24, 2026 23:58
dd0e260 to
2eb0274
Compare
ymichael
deleted the
bb/one-thread-action-target-on-every-surface-git-st-thr_7zxi74ezuz
branch
November 25, 2026 00:12
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.
Human comments
What was wrong
Every surface that hosts thread actions built its own
PluginThreadActionTarget, and they disagreed onenvironment. The thread header (ThreadDetailView) passed it only when a new thread could reuse it: environmentready, host active, path set. The sidebar, mobile recents, thread-list and Conductor passed any environment the thread had. So one action saw different targets in different menus. Live on main at phone width, for a thread whose worktree is still running its setup script (provisioning, path set), the header menu has no "New thread in environment" while the same thread's sidebar long-press menu offers it. thread-list (rows/threadActionTarget.ts) and Conductor (thread-target.ts) carried byte-identical copies of the mapper, and so do five community plugins. Separately, a thread action'suseDatareceived only ids. Git's Commit therefore calledsdk.threads.getfor every open thread, plus one subscription per thread, and fetched again on each environment change and reconnect, only to learn the environment the target already carried (audit a-thread F8b and F18's git item).What changed
One resolver, on
experimental_useThread's path.apps/app/src/lib/thread-actions/thread-action-target.tsxbuilds the target on #7955's thread-by-id resolution inthread-state.ts, not on a store of its own:thread-state.tsnow has onereadThreadresolution, used by bothuseThreadStateand a new non-hookthreadReadSource. It reads the held sidebar entry, otherwise the thread query, and keeps the last entry while a thread leaves the sidebar.ThreadActionCollectorsmounts a loader that callsuseThreadStateanduseEnvironment. Those are the same queries the thread page uses, so the open thread adds no request.The registry evaluates
item,experimental_bulkItemanduseDatafrom that single resolution, so every surface gets the same target: the header, row menus and quick actions, the long-press drawer, selection menus, the pin/read/archive palette commands, mobile recents, and plugin lists.SDK (0.6.202)
PluginThreadActionDataInput.experimental_threads: readonly PluginThreadActionTarget[]: the targets forthreadIds, in the same order, leaving out threads not loaded yet.experimental_useThreadActions(thread: { id: string }, options?),PluginThreadActionsMenuBaseProps.thread: { id: string }, andexperimental_bulkThreads?: readonly { id: string }[]: bb reads onlyid. Existing callers that pass hand-built targets orPluginSidebarThreads still type-check.PluginThreadActionTarget.environmentnow means "the thread's environment" on every surface:{ id, path, status, hostLifecycle }, withpathnull while there is no checkout, or null when the thread has none or bb cannot read it. The JSDoc said "when a new thread can reuse it" but held something else on the sidebar.TestThreadActionsResolverandTestThreadBulkActionsResolvernow receive the{ id }the plugin passed.Callers
ThreadDetailView(header, header menu,PaneThreadActionCommandHandler) andRootComposeMobileRecentspass the thread they hold.toThreadActionTargetandthreadListEntryActionTargetare deleted.ThreadRowand the selection store passSidebarThreads.rows/threadActionTarget.tsis deleted.WorkspaceTabsandWorkspaceSidebarpass the thread.thread-target.tsis deleted.useDatareadsexperimental_threads[].environmentand no longer callsthreads.getor subscribes per thread.>=0.6.202.Visible changes. One rule now decides where "New thread in environment" shows: the environment has a checkout, is ready or still provisioning, and its machine is active. Core's action reads it from the target, and the thread page's own button uses the same condition.
To give every surface that state without extra requests,
PluginThreadActionTarget.environmentgainsstatusandhostLifecycle. Sidebar entries get them from the server:ThreadListEntrygainsenvironmentStatusandenvironmentHostLifecycle, joined from the environment and its host in the thread list query. An environmentstatus-changedevent (host lifecycle changes also send it) now refreshes the sidebar threads in that environment. A thread outside the sidebar reads them from the environment query, as before.Git's Commit is not visible in any of these states. Its status RPC answers "Workspace is still starting.", "Workspace setup failed." or "Workspace status unavailable.", so the action hides from its own data.
Docs
docs/api_to_audit.md: a "One target" paragraph naming the core callers,experimental_threads, and an updated audit item 1.PluginThreadActionDataInput.experimental_threadsinsurfaces.ts.frontend-registration.mdandfrontend-sidebar-navigation.mdsay to pass the thread and readexperimental_threads.Community callers (not edited). All still compile. Their mappers are now unnecessary, and their thread actions see the host-resolved target:
components/thread-row.tsxtoActionTarget)app.tsxactionTarget)lib/thread-action-target.ts)rows/threadActionTarget.tsand its selection store). ItsThreadRow.testresolver reads target fields from the object it passes, so it needs a lookup by id once it moves to SDK 0.6.202.useDatausers notpritam/bb-plugin-inbox, yusuf8834/bb-git-history and jgnagy/bb-plugin-madmax are unaffected (the field is additive).How you verified
Live repro,
pnpm start:worktree. The fixture is a git project whose.bb-env-setup.shsleeps, which keeps a worktree environmentprovisioningwith its path set.status-changedevents arrived in the same batch asmetadata-changedevents, which already refresh the sidebar, so the new refresh added nosidebar-bootstrapfetch of its own.showCommitButtonon.Git requests. Script: open a thread, then click 5 more sidebar rows, and attribute each
GET /api/v1/threads/:idby its request initiator stack.bb--gitbundle (one per opened thread).showCommitButtonoff and on. Total API requests for the walk fell from 152 to 141.Sidebar render cost.
sidebar.bench.test.tsxwith 3000 threads and the real thread-list plugin, alternating main and branch undertaskpolicy -a.Tests
ThreadActionsMenu.test.tsx"thread action target": every menu surface (desktop dropdown, desktop context menu, compact drawer, compact long press), header entries, a two-thread selection and both placements'useDatareceive the same target, resolved from an id. A thread outside the sidebar resolves through the thread and environment queries.ThreadActionsMenu.test.tsxon both compact surfaces: New thread in environment shows for ready and provisioning environments on an active machine, and hides for failed setup and for machines being removed or gone.thread-runtime-display.test.ts: list entries carry the environment's status and the host's lifecycle, and follow both when they change.realtime-cache-effects.test.ts: an environmentstatus-changedevent invalidates the sidebar when it holds a thread in that environment.ThreadDetailView.contract.test.tsx: header actions get the thread's environment while it provisions. On main that target'senvironmentis null, so the test fails there.commit-action.test.tsx: Commit appears fromexperimental_threads, withthreads.getrejecting and never called.holdSidebarThreads(active threads in navigation, archived ones in the archive list), as the app does.Commands
pnpm exec turbo run typecheck lint --filter=@bb/app --filter=@get-bb/plugin-sdk --filter=bb-plugin-bb--git --filter=bb-plugin-thread-list --filter=bb-plugin-conductor --filter=bb-plugin-push-notifications --filter=bb-plugin-plugin-api-docs --filter=bb-plugin-bb-guide: green.turbo run test: green for the same packages.@bb/apppassed 7453 tests with 3 failures, in composer-contract, PromptBoxInternal and exclusive-pick-first-paint. All 313 tests in those files pass when the three run alone.ThreadDetailSecondaryContent.test.tsxfails 7/8 when run directly withnpx viteston both this branch and origin/main, and passes under turbo.🤖 Generated with Claude Code