Repository navigation
Conversation
experimental_Diff and experimental_SourceCode now read the thread view's Add to chat handler from context, so selected lines get core's gutter button and quote into that thread's composer. Outside a thread the handler is absent and the action stays hidden. normalizeFilePatch strips only trailing line breaks, so a hunk's blank trailing context line survives and full-file enrichment keeps the unmodified-lines expander. A real git diff with no hunks (mode-only change) now renders as an empty diff instead of raw text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/add-to-chat-automatically-on-plugin-diff-and-cod-thr_aj56nvdbqx
branch
October 27, 2026 03:36
ymichael
pushed a commit
that referenced
this pull request
Oct 27, 2026
…ugin The Git plugin now draws the Diff tab, the Info tab's branch, merge base, git status, Commits and Uncommitted files rows, and the composer's changed-files segment through the public slots, on top of the panel controller (#6356), experimental_useCanOpenFileExternally (#6357), automatic Add to chat (#6353) and experimental_ref (#6348). - Thread tabs and Info rows receive environment: { id } | null straight from the thread, null only without one. The Git plugin reads everything else itself: the Diff tab's loading, failure and Retry come from its bb--git status read, and a missing workspace folder shows "Workspace not found" in Info. - experimental_useTabVisible() tells any panel tab whether it is selected in an open panel; the Diff tab pauses its file list, patch and Viewed reads while it is false. - Mod+D is the Git plugin's toggle-diff command, calling the panel controller's toggleTab. - InfoListRow, its row actions and InfoRowTime move to @bb/shared-ui for core and the plugin; the subheading and commit rail live in the plugin. - Keyed RPC reads gain refetchKeys for a per-row Retry. - Plugin SDK 0.6.90. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
pushed a commit
that referenced
this pull request
Oct 27, 2026
…ugin The Git plugin now draws the Diff tab, the Info tab's branch, merge base, git status, Commits and Uncommitted files rows, and the composer's changed-files segment through the public slots, on top of the panel controller (#6356), experimental_useCanOpenFileExternally (#6357), automatic Add to chat (#6353) and experimental_ref (#6348). - Thread tabs and Info rows receive environment: { id } | null straight from the thread, null only without one. The Git plugin reads everything else itself: the Diff tab's loading, failure and Retry come from its bb--git status read, and a missing workspace folder shows "Workspace not found" in Info. - experimental_useTabVisible() tells any panel tab whether it is selected in an open panel; the Diff tab pauses its file list, patch and Viewed reads while it is false. - Mod+D is the Git plugin's toggle-diff command, calling the panel controller's toggleTab. - InfoListRow, its row actions and InfoRowTime move to @bb/shared-ui for core and the plugin; the subheading and commit rail live in the plugin. - Keyed RPC reads gain refetchKeys for a per-row Retry. - Plugin SDK 0.6.90. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Oct 27, 2026
…ugin (#6157) ## Human comments ## What was wrong Since #6165, the Git plugin owns every git read, but core still drew the Diff tab, the Info tab's branch, merge base, git status, Commits and Uncommitted files rows, and the composer's changed-files segment. Plugins couldn't replace them, and turning the plugin off left them showing errors. This PR moves that UI into the Git plugin, through the same public slots any plugin uses, on top of the four prep PRs: the panel controller (#6356), `experimental_useCanOpenFileExternally` (#6357), automatic Add to chat on diff and code views (#6353) and `experimental_ref` on workspace file targets (#6348). ## What changed **Moved into the Git plugin (`plugins/git/app.tsx`, `plugins/git/ui/`)** - **Diff tab**: a thread fixed `experimental_tab` with `{ kind: "file", path }` and `{ kind: "commit", sha }` targets. - It shows its own loading state, failure and Retry from its `bb--git` status read, and hides for a workspace that isn't a git repository. - Filters are kept per environment, so they survive switching tabs. - Open in editor is decided per file card with `experimental_useCanOpenFileExternally`. The workspace path for copying absolute paths comes from the plugin's own environment read. - **Mod+D**: the plugin's `toggle-diff` command calls `ctx.experimental_panel.toggleTab`. A user's saved `diff.toggle` binding migrates to it, as before. - **Info**: - Branch, Merge base and Git status rows, plus the Commits and Uncommitted files sections. - A missing workspace folder shows "Workspace not found" from the plugin's status read. - Changed files with status D preview read-only at `HEAD` or the merge base through `experimental_ref`. - **Composer**: the changed-files segment with its merge-base picker. - **Merge-base picker**: takes its branch from the plugin's own status read, not from an environment record. - **Removed from core**: - The Diff tab and its panel code, the Info git rows and sections, and the changed-files segment. - The status, files, patches, branches and Viewed query hooks. - `diff.toggle`, and the core Diff case in the panel controller contract table. - Core still reads status through the plugin for the Commit button and the composer branch chip. **Components** - Moved to `@bb/shared-ui`, because both core and the plugin render them: - The diff card body and header, diff parsing and patch text, renderers, and `BranchPicker` with its picker helpers. - Git status display, the workspace change summary and changes list, and the diff stats tally. - The file path link, Open in editor button, copy button, image preview and diff loading skeleton. - `InfoListRow` with its row actions, and `InfoRowTime`. Core's Related threads and thread storage sections use these too. - Kept inside the plugin, because only it uses them: the Diff panel, toolbar, filters, the Info subheading and the commit rail. **Plugin SDK 0.6.90** (all in `docs/api_to_audit.md` and the Plugin Guide) - **`environment` on thread tabs and Info rows.** - Thread tabs (fixed and action, including `useVisible` and action `run`) and Info rows receive `environment: { id } | null`. It comes straight from the thread and is null only when the thread has no environment. - Components read the environment's state themselves. - Core no longer filters Info rows' environment through its "can use git UI" check. - New type: `ExperimentalThreadTabProps`. - **`experimental_useTabVisible(): boolean`**: - True while the panel tab it renders in is selected and the side panel is open. False when the panel is closed or suppressed, when another tab is selected, and outside a tab. - Core keeps a closed panel's tab mounted, as before. `ThreadSecondaryPanel` provides the value for every surface. - The Diff tab pauses its file list, patch, Viewed and branch-list reads while it is false, as core's Diff did with `isDiffPanelLive`. - The test harness answers it with `tabVisible`, default true. - **`refetchKeys(keys)` on keyed reads**: reads only those keys again and keeps every other row. The Diff tab retries one failed patch with it, and Retry re-reads one environment's status. **Dropped from the previous version of this PR** - `environmentState`, `threadArchived` and `isOpen` on tab props, and keeping visited fixed tabs mounted. - `useVisible` returning `"pending"` for context segments. - `experimental_shortcutCommandId` (on main the shortcut appeared only in the Diff tab's screen-reader label) and `experimental_inactiveInInputs`. - `experimental_InfoRowTime`, `experimental_InfoSubheading`, `InfoList` `rail` and `InfoListRow` `actions` as SDK members. - `DiffProps.experimental_addSelectionToChat`, now automatic since #6353. - `experimental_deleted`, replaced by `experimental_ref`. - `ctx.experimental_toggleTab`, replaced by the panel controller. **Differences from main (accepted)** - Mod+D also toggles the Diff tab while typing. - The composer context row appears when git status arrives, instead of being held back until then. - Turning the Git plugin off hides the Diff tab, the Info git rows and the composer segment. With the plugin off, Commit returns 409 `git_plugin_unavailable`. ## How you verified - **Turbo checks:** - `pnpm exec turbo run typecheck lint --filter='...[origin/main]'` passes. - Tests pass for `@bb/app` (6286), the Git plugin, `@bb/shared-ui`, `@get-bb/plugin-sdk`, `@bb/query-tags`, `@bb/client-core`, the Plugin Guide, the GitHub, Side chat, Tasks, Workflows, Docs and Automations plugins, and the server's authoring-docs and keybinding tests. - **New tests (each fails without its change):** - `ThreadSecondaryPanel.tabVisible.test.tsx`: true while selected and open; false once closed, still mounted. - The panel controller contract table: "reports the shown tab visible only while the side panel is open", run against the thread view, plugin page and New thread surfaces. - `DiffTab.test.tsx`: visibility from status; the status failure with Retry; no file list while the tab isn't showing; Open in editor only for a valid per-file target. - `DiffFilesPanel.test.tsx`: no patch or Viewed reads while the tab is hidden. - `PluginThreadFixedTabs.test.tsx`: the tab and its `useVisible` receive the thread's environment. - `plugins/git/app.test.tsx`: Mod+D calls `toggleTab` on the Diff tab. - **Squash tests on Windows:** in `plugins/git/host/workspace-status-cache.test.ts`, the squash-detection tests now read again until the check completes, as bb does on the next refresh. The plugin package now also runs the Diff and Info UI tests, and that extra load on Windows runners pushed single reads past the 1 s squash budget (three runs, three different tests). The tests of the timeout itself are unchanged. - **Real app QA:** this branch and `main` built side by side on the same data and repository (a rename, edits, a deletion, a binary file, an image, a mode change). | Check | Branch | Main | |---|---|---| | Diff tab opens and closes with Mod+D and lists the same files | Pass | Pass | | Open in editor on every Diff card (7) | Pass | Pass | | Mod+D while typing in the composer | Toggles (accepted) | Does nothing | | Composer context row "Uncommitted · 7 files, +3 −74" and merge-base picker | Pass | Pass | | Info: branch, merge base, git status, Uncommitted files | Pass | Pass | | Merge-base picker opens with the branch list | Pass | Pass | | Add to chat on selected diff lines inserts the quoted diff | Pass | Pass | | A deleted file opens a read-only preview at `HEAD` | Pass | Pass | | A thread whose workspace folder is gone shows "Workspace not found" | Pass | n/a | | No file list, patch or Viewed reads after an edit while the Diff tab is closed; reads resume on reopen | Pass | Pass | > AGENT GENERATED Co-authored-by: Michael Yong <review@local> Co-authored-by: Claude Opus 5.5 <[email protected]>
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
Plugins that render
experimental_Difforexperimental_SourceCodeinside a thread never offered Add to chat. Core's file previews do offer it, because they pass the thread's Add to chat handler straight toDiffHost/SourceCodeHost. The plugin wrappers had no way to get that handler.normalizeFilePatch, whichexperimental_Diffuses, also had two bugs:trimEnd()ed the patch, which deleted a hunk's trailing blank context line. Full-file enrichment then rejected the hunk, so the card lost its trailing "N unmodified lines" expander. Repro: rename a file and edit line 1 of a file whose line 4 is blank.nulland fell back to rawdiff --gittext.What changed
Add to chat:
SelectionAddToChatContext(apps/app/src/components/thread/SelectionAddToChatContext.tsx).ThreadDetailViewandEmbeddedThreadChatprovide it, using the same handler their core file previews already use.PluginDiffandPluginSourceCoderead it and pass it toDiffHost/SourceCodeHost.normalizeFilePatch:diff --gitpatch with zero hunks, so it renders as a diff card like core does.Plugin SDK:
DiffProps/SourceCodePropsdoc comments about Add to chat.No server/daemon wire, DB, or lifecycle changes.
How you verified
New tests: all fail on main and pass here.
git-diff-parsing.test.ts: trailing blank context line survives and enrichment is not partial; mode-only diff parses withhunks: []; non-patch text returnsnull.DiffHost.test.tsx: mode-only diff renders as a diff, not raw text.DiffHost.test.tsxandSourceCodeHost.test.tsx: Add to chat is offered only inside a thread.Turbo:
@bb/app6395 passed / 2 skipped, plugin-sdk 402 passed, plugin-api-docs 75 passed.Real run:
pnpm start:worktreewithBB_*unset, plus a QA plugin that renders diffs and source in a thread tab and in a nav panel.src/add.ts:2into the composer.🤖 Generated with Claude Code