The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): send review agent-ship to the composer that opened it
Brooklyn Nicholson830108c8d958
diff --git a/apps/desktop/src/app/chat/composer/index.tsx b/apps/desktop/src/app/chat/composer/index.tsxindex c61f81f1fc2..763f62f13ed 100644--- a/apps/desktop/src/app/chat/composer/index.tsx+++ b/apps/desktop/src/app/chat/composer/index.tsx@@ -1278,7 +1278,7 @@ export function ChatBar({// A tile's rail reviews ITS worktree: pin the pane's scope to// this surface's cwd. Main keeps the classic follow-the-// active-session scope (null).- onOpen={() => toggleReview(scope.target === 'main' ? null : (cwd ?? null))}+ onOpen={() => toggleReview(scope.target === 'main' ? null : (cwd ?? null), scope.target)}onOpenWorktree={openInWorktree}onSwitchBranch={handleSwitchBranch}repoPath={cwd}diff --git a/apps/desktop/src/app/contrib/controller.tsx b/apps/desktop/src/app/contrib/controller.tsxindex 5c65fd3f19c..f5d400a2043 100644--- a/apps/desktop/src/app/contrib/controller.tsx+++ b/apps/desktop/src/app/contrib/controller.tsx@@ -59,7 +59,14 @@ import {SIDEBAR_MAX_WIDTH} from '@/store/layout'import { runExportProfileFlow, runImportProfileFlow } from '@/store/profile-share'-import { $reviewOpen, closeReview, openReview, REVIEW_PANE_ID } from '@/store/review'+import {+ $reviewOpen,+ $reviewScopeCwd,+ $reviewScopeTarget,+ closeReview,+ openReview,+ REVIEW_PANE_ID+} from '@/store/review'import { $currentCwd, $selectedStoredSessionId, $sessions, $yoloActive, sessionMatchesStoredId } from '@/store/session'import { watchSessionPins } from '@/store/session-pin-sync'import { watchUnreadWriteGuard } from '@/store/session-unread-remote'@@ -580,7 +587,7 @@ bindPaneVisibility('review',computed([$reviewOpen, $hasWorkspace], (open, workspace) => open && workspace),closeReview,- openReview+ () => openReview($reviewScopeCwd.get(), $reviewScopeTarget.get()))// ⌃` / statusbar toggle — the terminal COLLAPSES to a rail (tab stays), not// hides; PTYs stay alive while collapsed (see PersistentTerminal).diff --git a/apps/desktop/src/app/right-sidebar/review/ship-bar.tsx b/apps/desktop/src/app/right-sidebar/review/ship-bar.tsxindex 2f85a9ade43..3d0e03325fd 100644--- a/apps/desktop/src/app/right-sidebar/review/ship-bar.tsx+++ b/apps/desktop/src/app/right-sidebar/review/ship-bar.tsx@@ -15,6 +15,7 @@ import {$reviewCommitDefault,$reviewCommitMsgBusy,$reviewFiles,+ $reviewScopeTarget,$reviewShipBusy,$reviewShipInfo,cancelCommitMessage,@@ -35,6 +36,7 @@ export function ReviewShipBar() {const c = t.statusStack.codingconst files = useStore($reviewFiles)const ship = useStore($reviewShipInfo)+ const scopeTarget = useStore($reviewScopeTarget)const busy = useStore($reviewShipBusy)const generating = useStore($reviewCommitMsgBusy)const commitDefault = useStore($reviewCommitDefault)@@ -129,7 +131,11 @@ export function ReviewShipBar() {<ButtonclassName="min-w-0 flex-1 justify-center px-7 text-[0.7rem] text-muted-foreground/85 hover:text-foreground"disabled={!hasFiles}- onClick={() => requestComposerSubmit(c.agentShipPrompt, { target: 'main' })}+ onClick={() => {+ if (!requestComposerSubmit(c.agentShipPrompt, { target: scopeTarget })) {+ notifyError(new Error(c.agentShipUnavailable), c.agentShip)+ }+ }}size="sm"variant="ghost">diff --git a/apps/desktop/src/components/assistant-ui/thread/changed-files-card.tsx b/apps/desktop/src/components/assistant-ui/thread/changed-files-card.tsxindex 021036440d6..6d3f6b8346f 100644--- a/apps/desktop/src/components/assistant-ui/thread/changed-files-card.tsx+++ b/apps/desktop/src/components/assistant-ui/thread/changed-files-card.tsx@@ -1,6 +1,7 @@import { useStore } from '@nanostores/react'import { type FC, useMemo } from 'react'+import { useComposerScope } from '@/app/chat/composer/scope'import { useSessionView } from '@/app/chat/session-view'import { deriveChangedFiles } from '@/components/assistant-ui/thread/changed-files'import { WIDGET_SHELL_CLASS } from '@/components/chat/widget-shell'@@ -33,6 +34,7 @@ export const ChangedFilesCard: FC<{ parts: readonly unknown[] }> = ({ parts }) =const view = useSessionView()const viewCwd = useStore(view.$cwd)const scopeCwd = view.kind === 'primary' ? null : viewCwd || null+ const composerScope = useComposerScope()if (files.length === 0) {return null@@ -47,7 +49,7 @@ export const ChangedFilesCard: FC<{ parts: readonly unknown[] }> = ({ parts }) =<span className="min-w-0 flex-1 truncate text-(--ui-text-primary)">{copy.filesChanged(files.length)}</span><buttonclassName="shrink-0 cursor-pointer text-(--ui-text-tertiary) transition-colors hover:text-(--ui-text-primary)"- onClick={() => revealReview(scopeCwd)}+ onClick={() => revealReview(scopeCwd, composerScope.target)}type="button">{copy.reviewChanges}@@ -58,7 +60,7 @@ export const ChangedFilesCard: FC<{ parts: readonly unknown[] }> = ({ parts }) =<buttonclassName="row-hover flex shrink-0 items-center gap-2 rounded-md px-1.5 py-1 text-left"key={file.path}- onClick={() => void openReviewForPath(file.path, scopeCwd)}+ onClick={() => void openReviewForPath(file.path, scopeCwd, composerScope.target)}title={displayPath(file.path)}type="button">diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 2c0f27e6537..d39a26d2b08 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -1894,6 +1894,7 @@ export const ar = defineLocale({openPr: 'فتح PR',ghMissing: 'ثبّت GitHub CLI (gh) وسجّل الدخول لفتح طلبات السحب',agentShip: 'اطلب من Hermes فتح PR',+ agentShipUnavailable: 'المحادثة التي تملك هذه التغييرات ليست على الشاشة.',agentShipPrompt: 'راجع التغييرات الحالية، وأودعها برسالة إيداع تقليدية واضحة، وادفع الفرع، وافتح طلب سحب.',newBranch: 'فرع جديد',branchOffFrom: base => `فرع جديد من ${base}`,diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 091ae1b8286..b3b6d0dcd93 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -2433,6 +2433,7 @@ export const en: Translations = {openPr: 'Open PR',ghMissing: 'Install the GitHub CLI (gh) and sign in to open PRs',agentShip: 'Ask Hermes to open PR',+ agentShipUnavailable: "The chat that owns these changes isn't on screen.",agentShipPrompt:'Review the current changes, commit them with a clear conventional-commit message, push the branch, and open a pull request.',newBranch: 'New branch',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 5110bf27aaa..b31ed718aef 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -2097,6 +2097,7 @@ export const ja = defineLocale({openPr: 'PR を開く',ghMissing: 'PR を開くには GitHub CLI (gh) をインストールしてサインインしてください',agentShip: 'Hermes にコミットと PR を任せる',+ agentShipUnavailable: 'この変更を持つチャットが画面にありません。',agentShipPrompt:'現在の変更を確認し、分かりやすい Conventional Commits 形式でコミットし、ブランチをプッシュして、プルリクエストを作成してください。',newBranch: '新しいブランチ',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 25ba1df58b5..0e4d2ab3c13 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -2060,6 +2060,7 @@ export interface Translations {openPr: stringghMissing: stringagentShip: string+ agentShipUnavailable: stringagentShipPrompt: stringnewBranch: stringbranchOffFrom: (base: string) => stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 54bb68ecc77..968b5ce1138 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -2034,6 +2034,7 @@ export const zhHant = defineLocale({openPr: '開啟 PR',ghMissing: '安裝 GitHub CLI (gh) 並登入後可開啟 PR',agentShip: '讓 Hermes 提交並開 PR',+ agentShipUnavailable: '擁有這些變更的對話目前不在畫面上。',agentShipPrompt: '檢查目前的變更,使用清晰的約定式提交訊息提交,推送分支,並開啟一個拉取請求。',newBranch: '新增分支',branchOffFrom: base => `從 ${base} 建立新分支`,diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex c78354f41ee..54da42fb754 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -2618,6 +2618,7 @@ export const zh: Translations = {openPr: '打开 PR',ghMissing: '安装 GitHub CLI (gh) 并登录后可打开 PR',agentShip: '让 Hermes 提交并开 PR',+ agentShipUnavailable: '拥有这些更改的会话当前不在屏幕上。',agentShipPrompt: '检查当前更改,使用清晰的约定式提交信息提交,推送分支,并开启一个拉取请求。',newBranch: '新建分支',branchOffFrom: base => `从 ${base} 新建分支`,diff --git a/apps/desktop/src/store/review.test.ts b/apps/desktop/src/store/review.test.tsindex 44c882f1e2f..446e4f00dce 100644--- a/apps/desktop/src/store/review.test.ts+++ b/apps/desktop/src/store/review.test.ts@@ -14,6 +14,7 @@ import {$reviewOpen,$reviewRevertTarget,$reviewScopeCwd,+ $reviewScopeTarget,$reviewSelectedPath,$reviewShipBusy,$reviewShipInfo,@@ -30,9 +31,11 @@ import {refreshReview,refreshShipInfo,requestRevert,+ revealReview,revertReviewFile,selectReviewFile,stageReviewFile,+ toggleReview,toggleReviewTreeMode,unstageReviewFile} from './review'@@ -96,6 +99,7 @@ beforeEach(() => {$reviewCommitMsgBusy.set(false)$reviewRevertTarget.set(undefined)$reviewScopeCwd.set(null)+ $reviewScopeTarget.set('main')$currentCwd.set('/repo')})@@ -263,6 +267,45 @@ describe('view state', () => {expect(review.list).toHaveBeenCalledWith('/tile-worktree', 'uncommitted', null)})+ it('openReview remembers the tile composer that owns the scoped worktree', () => {+ stubReview()++ openReview('/tile-worktree', 'tile:project-b')++ expect($reviewScopeCwd.get()).toBe('/tile-worktree')+ expect($reviewScopeTarget.get()).toBe('tile:project-b')+ })++ it('revealReview re-homes the origin when the repo stays the same', () => {+ stubReview()+ openReview('/tile-worktree', 'tile:project-a')++ revealReview('/tile-worktree', 'tile:project-b')++ expect($reviewScopeTarget.get()).toBe('tile:project-b')+ })++ it('narrow toggle re-homes the origin before showing the overlay', () => {+ const originalMatchMedia = window.matchMedia++ Object.defineProperty(window, 'matchMedia', {+ configurable: true,+ value: vi.fn(() => ({ matches: true }))+ })++ try {+ stubReview()+ openReview('/project-a', 'tile:project-a')++ toggleReview('/project-b', 'tile:project-b')++ expect($reviewScopeCwd.get()).toBe('/project-b')+ expect($reviewScopeTarget.get()).toBe('tile:project-b')+ } finally {+ Object.defineProperty(window, 'matchMedia', { configurable: true, value: originalMatchMedia })+ }+ })+it('closeReview closes the pane, clears selection, and drops scope', () => {stubReview()$reviewOpen.set(true)@@ -274,6 +317,7 @@ describe('view state', () => {expect($reviewOpen.get()).toBe(false)expect($reviewScopeCwd.get()).toBeNull()+ expect($reviewScopeTarget.get()).toBe('main')expect($reviewSelectedPath.get()).toBeNull()expect($reviewDiff.get()).toBeNull()})diff --git a/apps/desktop/src/store/review.ts b/apps/desktop/src/store/review.tsindex 64ebd936c26..11428d20d15 100644--- a/apps/desktop/src/store/review.ts+++ b/apps/desktop/src/store/review.ts@@ -90,6 +90,10 @@ export const $reviewCommitMsgBusy = atom(false)// tiles can sit in different worktrees than main, and reviewing "the diff I'm// looking at" must mean that tile's repo, not whatever main happens to be on.export const $reviewScopeCwd = atom<null | string>(null)+// The composer target that opened the pane. The review pane is a shared+// surface, but its "let the agent ship it" action must return to the session+// whose worktree the user is reviewing, not broadcast to every mounted tile.+export const $reviewScopeTarget = atom('main')/** The repo the pane is reading right now: its pinned scope, else the active* session's cwd. Exported for pane helpers that join repo-relative paths. */@@ -258,9 +262,11 @@ function refreshShipInfoIfStale(): void {}/** Open the pane scoped to `scopeCwd` (a tile's worktree), or to the active- * session's cwd when null — see `$reviewScopeCwd`. */-export function openReview(scopeCwd: null | string = null): void {+ * session's cwd when null — see `$reviewScopeCwd`. Keep the originating+ * composer target alongside it for agent-ship actions. */+export function openReview(scopeCwd: null | string = null, scopeTarget = 'main'): void {$reviewScopeCwd.set(scopeCwd?.trim() || null)+ $reviewScopeTarget.set(scopeTarget.trim() || 'main')$reviewOpen.set(true)void refreshReview()void refreshShipInfo()@@ -269,16 +275,21 @@ export function openReview(scopeCwd: null | string = null): void {export function closeReview(): void {$reviewOpen.set(false)$reviewScopeCwd.set(null)+ $reviewScopeTarget.set('main')clearReviewSelection()}-export function toggleReview(scopeCwd: null | string = null): void {+export function toggleReview(scopeCwd: null | string = null, scopeTarget = 'main'): void {// Narrow width: the pane is a collapsed overlay (like the sidebar under ⌘B).// Make sure its data is loaded, then slide it in/out via the forced-reveal pin// — never the docked open state, which a 0px track would render invisibly.if (matchesQuery(SIDEBAR_COLLAPSE_MEDIA_QUERY)) {- if (!$reviewOpen.get()) {- openReview(scopeCwd)+ const target = scopeTarget.trim() || 'main'+ const originChanged =+ ($reviewScopeCwd.get() ?? null) !== (scopeCwd?.trim() || null) || $reviewScopeTarget.get() !== target++ if (!$reviewOpen.get() || originChanged) {+ openReview(scopeCwd, target)}window.dispatchEvent(new CustomEvent(PANE_TOGGLE_REVEAL_EVENT, { detail: { id: REVIEW_PANE_ID } }))@@ -294,7 +305,7 @@ export function toggleReview(scopeCwd: null | string = null): void {if (isPaneVisible(REVIEW_PANE_ID)) {closeReview()} else {- revealReview(scopeCwd)+ revealReview(scopeCwd, scopeTarget)}}@@ -303,15 +314,18 @@ export function toggleReview(scopeCwd: null | string = null): void {* closes an already-open pane — it's the "take me to the diff" entry point used* by the transcript's changed-files card.*/-export function revealReview(scopeCwd: null | string = null): void {+export function revealReview(scopeCwd: null | string = null, scopeTarget = 'main'): void {const wasOpen = $reviewOpen.get()+ const target = scopeTarget.trim() || 'main'if (!wasOpen) {- openReview(scopeCwd)- } else if (($reviewScopeCwd.get() ?? null) !== (scopeCwd?.trim() || null)) {+ openReview(scopeCwd, target)+ } else if (($reviewScopeCwd.get() ?? null) !== (scopeCwd?.trim() || null) || $reviewScopeTarget.get() !== target) {// Already open but on another worktree's diff — re-home it. The scope- // subscription below clears the stale list and re-probes.+ // subscription below clears the stale list and re-probes. Keep the+ // originating composer target alongside the cwd for the agent-ship action.$reviewScopeCwd.set(scopeCwd?.trim() || null)+ $reviewScopeTarget.set(target)}if (matchesQuery(SIDEBAR_COLLAPSE_MEDIA_QUERY)) {@@ -346,8 +360,12 @@ function matchReviewFile(files: readonly HermesReviewFile[], path: string): Herm* Open the review pane on one file's diff. The path comes from a tool call, so* it may be absolute while git reports repo-relative — match on the tail.*/-export async function openReviewForPath(path: string, scopeCwd: null | string = null): Promise<void> {- revealReview(scopeCwd)+export async function openReviewForPath(+ path: string,+ scopeCwd: null | string = null,+ scopeTarget = 'main'+): Promise<void> {+ revealReview(scopeCwd, scopeTarget)await refreshReview()const file = matchReviewFile($reviewFiles.get(), path)