Skip to content

Restore optimistic sidebar updates and group archive Undo - #5045

Merged
ymichael merged 2 commits into
mainfrom
bb/fix-optimistic-thread-update-thr_d4yd3x7s72
Oct 6, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/fix-optimistic-thread-update-thr_d4yd3x7s72

Conversation

@ymichael

@ymichael ymichael commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The sidebar plugin migration replaced several host mutation hooks with direct SDK calls, bypassing optimistic cache updates for worktree-group archiving, restoring threads, and pinned moves. Project/machine renaming and project/section removal also waited for server updates. Nested archive/delete operations could leave descendants visible, and pinned drag previews could settle back into stale ordering.

Environment-group archiving also used a plain Sonner success toast rather than BB's shared archive feedback, so its styling differed and it had no Undo action.

What changed

  • Apply optimistic writes and failure rollback in the shared browser SDK for environment-group archive, restore, pin/unpin and move, project/machine/section renames, and project/section removal. Populate section creation and pinned ordering results before resolving.
  • Remove every cached descendant during archive/delete and restore affected membership on failure while preserving unrelated rows. Replace the section-name overlay with shared cache updates.
  • Route group archiving through the host action flow for pane cleanup and the shared ten-second Undo toast. Undo restores only returned archived IDs, sequentially with lifecycle owners before descendants.
  • Document the experimental group archive action in the SDK, Plugin Guide, and API audit inventory. Bump the plugin SDK to 0.6.24 and require that version in the thread-list plugin. No server/daemon wire, database, or CLI contract changes.

How you verified

Regression tests failed before their fixes for pending SDK writes, pinned-order settlement, nested family removal, and missing group Undo.

Focused Turbo verification passed:

  • App cache-owner, thread mutation, bound SDK, and sidebar hook suites: 67 tests.
  • Sidebar row/list/preferences suites: 158 tests.
  • Plugin Guide suite: 75 tests.
  • After adding group Undo: host archive/Undo, navigation, bound SDK, and sidebar hook suites: 62 tests; project-row interactions: 33 tests; Plugin Guide: 75 tests.
  • SDK/domain tests and SDK version/publish guards after the version bump.
  • Turbo lint/typecheck for @bb/app, bb-plugin-thread-list, @get-bb/plugin-sdk, and the affected Plugin Guide package; git diff --check.

Browser verification against pnpm start:worktree confirmed optimistic group archive, pinned move, restore, project/section rename and removal, and machine rename. Held requests proved updates happened before responses; injected failures verified rollback. A real group archive → Undo restored both threads, confirmed through the server API.

AGENT GENERATED

@ymichael
ymichael merged commit 9b5cb7f into main Oct 6, 2026
7 checks passed
@ymichael
ymichael deleted the bb/fix-optimistic-thread-update-thr_d4yd3x7s72 branch October 6, 2026 19:16
ymichael added a commit that referenced this pull request Oct 6, 2026
## Human comments

## What was wrong

In the sidebar's By project mode, project groups were treated as
unrestricted drop destinations. Dragging a pinned or child thread onto
another project's header or row could show a valid landing affordance
and attempt to unpin or detach the thread, even though the drop cannot
change its project.

## What changed

Track each project group's project ID, including the personal Threads
container, and reject mismatched destinations during collision detection
and drop resolution. Invalid destinations no longer highlight or show
landing previews, and releasing there leaves the thread unchanged. Drops
into the thread's own project and supported cross-project parent/child
links remain available. No wire, CLI, or public SDK changes. Also align
the cache-owner import registry with the sidebar group owner introduced
in #5045: declare its six imports and remove the stale projectsQueryKey
allowance from the thread state owner.

## How you verified

- Added four regression cases covering another project's header and row,
an empty project, and the personal Threads group. Each checks that a
valid prior target clears and dropping causes no mutation.
- `pnpm exec turbo run test --filter=bb-plugin-thread-list --
app/dnd/useSectionThreadDnd.test.ts
app/dnd/useSectionThreadDnd.projection.test.tsx`: 62 passed, including
existing cross-project nesting coverage.
- `pnpm exec turbo run typecheck lint --filter=bb-plugin-thread-list`:
passed; lint reports 9 existing warnings and no errors.
- Real browser mouse drags in an isolated source app: another project
and an empty project show no drop indicators or preview; dropping
preserves project and pin state. Dropping onto the thread's own project
unpins it, and the placement survives reload.
- Reproduced the cache-owner registry CI failure locally, then verified
all 3 registry checks pass after the update: `pnpm exec turbo run test
--filter=@bb/app --
src/hooks/cache-owners/cache-owner-registry.test.ts`. The 62 drag checks
also pass after merging current main.
- Prepared and started `pnpm start:worktree` with labeled test projects
and threads for manual review.

> AGENT GENERATED
ymichael added a commit that referenced this pull request Nov 3, 2026
## Human comments

## What was wrong

`@bb/app` had grown to 657 test files and 6,809 tests. Many tests
checked a contract that another test already covered more strongly.
Others only exercised wiring, tested a third-party library, or held
assertions that could not fail. A few production `export`s and one
parameter existed only for these tests. This made the suite slower to
run and maintain without catching any extra bugs.

## What changed

Test files only, apart from removing test-only exports. Net −1,077 test
lines across 58 files (+290 / −1,367), four whole files deleted, and
6,809 → 6,750 tests. Production changes are +8 / −11 across 7 files,
with no behaviour change.

**Removed**
- **Duplicates:** the raw-thread-id title tests that #5261 copied into
`ThreadTitleMentions.resources.test.ts` but never removed from the
original. Also sibling tests repeating the same setup and assertion, and
mocked copies of scenarios that already run through the real code:
`composer-submissions`, `app-toast-title-overflow`, OnboardingGate,
AddMachineDialog expiry, ToolsView banners, provider-icon, plugin-slots,
the cache-owner rename, pin acknowledgement, the CommandPalette settings
page, QuestionForm, and the PromptBox/composer-contract rejection.
- **Wiring and constant pins:** small helpers tested directly when their
only caller is tested (`resolveUrlOpenTarget`, `parseLifecycleError`,
`buildAudioInputConstraints`, `resolvePaneArrangementLabel`); realtime
registry rows that `satisfies Record<…>` already enforces at typecheck;
a snapshot-identity check covered by a stricter structural-sharing test.
- **Third-party only:** `src/test/virtualizer-scroll-lifecycle.test.tsx`
tested `@tanstack/virtual-core` and guarded a repo patch that #5951
removed. Upstream now cancels the timer itself.
- **Vacuous:** a lifecycle-error row varying `hasPath`, which no code
reads; BrowserTabDeck rows that pass either way; a FollowUpPromptBox
placeholder test whose two placeholders were the same string; a dead
`vi.mock` of a module the code under test never imports.
- **Test-only production seams:** dropped `export` from
`buildAudioInputConstraints`, `buildDevWebSocketUrl`,
`resolveUrlOpenTarget`, `parseLifecycleError`, `threadTitleTextSegments`
and `resolvePaneArrangementLabel`. Removed
`getSecondaryPanelChromeStackClassName`'s `hasGitDiffToolbar` parameter;
its only caller passed `false`.

**Repaired** (assertions that could not fail)
- `plugin-bound-sdk`: the test promised cache updates but only checked
call shape. It now asserts that a created section reaches the sidebar
cache before `create` resolves. That behaviour (#5045) had no test
before.
- `split-layout/ops`: `if (root.type === "split")` guards could skip
every resize-clamp assertion; they now throw on a non-split root.
- `provider-icon`: `toBeDefined()` on a non-optional return replaced
with real `ariaLabel` checks.
- `use-composers`: the test named "lock or paint" now also exercises
`setTextEffect`.
- `ThreadMetadataContent`: `path: null` let the "provisioning" test pass
without its status check.
- Terminal UTF-8 split glyph: this tested the browser's `TextDecoder`.
It now writes through `writeTerminalOutput` into a real xterm.
- Early `focusEnd`, the voice transition while hidden or under reduced
motion, and the model-picker cycle-chord exception could all pass with
the guarded code removed. They now fail when it is.
- `dev-websocket-url` now goes through `buildBrowserWebSocketUrl`, which
also covers the production fallback URL.

## How you verified

- **Mutation checks.** Three independent reviewers worked on dedicated
worktrees of `main` and of this branch. For every removed or merged
test, they wrote the bug it caught as a mutation of the production code.
They confirmed the old test fails on `main` and that a remaining test
fails on this branch, then restored the source.
- About 110 mutations were run. 18 removals turned out to be the only
guard on their contract; 16 of those were restored.
- The most important restoration: a known raw thread id must display as
its title through the synchronous `resolveThreadTitleDisplayText`. The
rendered pills hide this bug, but the AppLayout title, archived-threads
settings and the parent-thread picker show it.
- Other restorations: the Meta+Enter `aria-keyshortcuts` label,
QueuedMessagesList open/close reporting and overflow toggling, older
touch actions at the former width threshold, the touch-selection menu
side (#6567), the terminal-view unmount, the plugin update-action icon,
the marketplace icon in AddPluginDialog, the ReuseEnvironmentPicker
secondary text, the app chrome row-height token, the focused
notification on title Show more, the mapper's unread-error indicator,
the `useThreadStorageLocation` fetch, the thread invalidation `maxWait`
bounds, and the sidebar info-tab id.
- Two gaps were left out on purpose: the `hasPath` lifecycle row (no
code reads `hasPath`) and a single `shrink-0` class pin.
- Each repaired assertion was shown to fail under a mutation that the
old assertion let through.
- **Baseline** at 51d8ddc: `pnpm exec turbo run test
--filter=@bb/app` ran 6,809 tests, with 6 failures at machine load ~89.
All six pass when run alone or at normal load.
- **After rebasing onto origin/main:** `pnpm exec turbo run lint
typecheck test --filter=@bb/app` gave 0 lint errors, a clean typecheck,
and 6,740 of 6,750 tests passing (9 skipped).
- The one failure, `CommandPalette` "runs an available shortcut … after
closing and restoring focus", timed out opening the palette at load ~79.
It failed the same way in the baseline run on `main`.
  - It passes in five isolated reruns, two of them uncached (`--force`).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED

Co-authored-by: Claude Opus 5.5 <[email protected]>
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