The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): statusbar cwd follows the focused session
Brooklyn Nicholson3707741d9f77
diff --git a/apps/desktop/src/app/chat/composer/status-stack/coding-row.tsx b/apps/desktop/src/app/chat/composer/status-stack/coding-row.tsxindex 1296b3fb180..32b21952db9 100644--- a/apps/desktop/src/app/chat/composer/status-stack/coding-row.tsx+++ b/apps/desktop/src/app/chat/composer/status-stack/coding-row.tsx@@ -15,6 +15,7 @@ import { Codicon } from '@/components/ui/codicon'import { DiffCount } from '@/components/ui/diff-count'import type { HermesGitBranch } from '@/global'import { useI18n } from '@/i18n'+import { displayPath } from '@/lib/display-path'import { registerRepoStatusCwd, repoStatusForCwd, repoWorktreesForCwd } from '@/store/coding-status'import { notifyError } from '@/store/notifications'import { $newWorktreeRequest } from '@/store/projects'@@ -237,6 +238,18 @@ export const CodingStatusRow = memo(function CodingStatusRow({</span></button>+ {/* Worktree path — plain muted text, not a chip. Always in the flex+ so hover doesn't reflow the row; opacity alone reveals it.+ `displayPath` collapses home → ~ (shell / VS Code convention). */}+ {resolvedRepoPath && (+ <span+ className="min-w-0 flex-1 truncate font-mono text-[0.62rem] leading-4 text-muted-foreground/50 opacity-0 transition-opacity group-hover/status-row:opacity-100 group-focus-within/status-row:opacity-100"+ data-slot="coding-status-cwd"+ >+ {displayPath(resolvedRepoPath)}+ </span>+ )}+{/* Branch actions kebab — same pattern as the session/worktree rows.ALWAYS laid out; only its opacity flips on hover/focus/open, sorevealing it never reflows the row (no layout shift). pointer-eventsdiff --git a/apps/desktop/src/app/chat/sidebar/projects/entered-content.tsx b/apps/desktop/src/app/chat/sidebar/projects/entered-content.tsxindex 9d322593163..6b09788157b 100644--- a/apps/desktop/src/app/chat/sidebar/projects/entered-content.tsx+++ b/apps/desktop/src/app/chat/sidebar/projects/entered-content.tsx@@ -15,6 +15,7 @@ import {import type { HermesGitWorktree } from '@/global'import type { SessionInfo } from '@/hermes'import { useI18n } from '@/i18n'+import { displayPath } from '@/lib/display-path'import { $dismissedWorktreeIds, dismissWorktree, setWorkspaceNodeOpen } from '@/store/layout'import { notifyError } from '@/store/notifications'import { removeWorktreePath } from '@/store/projects'@@ -277,7 +278,7 @@ function RepoFlatSection({label={repo.label}onToggle={toggleOpen}open={open}- title={repo.path ?? undefined}+ title={repo.path ? displayPath(repo.path) : undefined}/>{open && <SidebarRowStack className="pl-2.5">{body}</SidebarRowStack>}{removeDialog}diff --git a/apps/desktop/src/app/chat/sidebar/projects/workspace-group.tsx b/apps/desktop/src/app/chat/sidebar/projects/workspace-group.tsxindex dd38e84a2b9..5c05869b5a7 100644--- a/apps/desktop/src/app/chat/sidebar/projects/workspace-group.tsx+++ b/apps/desktop/src/app/chat/sidebar/projects/workspace-group.tsx@@ -4,6 +4,7 @@ import { useState } from 'react'import { Codicon } from '@/components/ui/codicon'import type { SessionInfo } from '@/hermes'import { useI18n } from '@/i18n'+import { displayPath } from '@/lib/display-path'import { setWorkspaceNodeOpen } from '@/store/layout'import { notifyError } from '@/store/notifications'import { newSessionInProfile } from '@/store/profile'@@ -132,7 +133,7 @@ export function SidebarWorkspaceGroup({ group, renderRows, onNewSession, onRemovlabel={group.label}onToggle={toggleOpen}open={open}- title={group.path ?? undefined}+ title={group.path ? displayPath(group.path) : undefined}/></WorkspaceContextMenu>{open && (diff --git a/apps/desktop/src/app/profiles/index.tsx b/apps/desktop/src/app/profiles/index.tsxindex 1db67b8778e..ae2ee9aab52 100644--- a/apps/desktop/src/app/profiles/index.tsx+++ b/apps/desktop/src/app/profiles/index.tsx@@ -9,6 +9,7 @@ import { Codicon } from '@/components/ui/codicon'import { getProfileSoul, type ProfileInfo, updateProfileSoul } from '@/hermes'import { useI18n } from '@/i18n'import { AlertTriangle, Save } from '@/lib/icons'+import { displayPath } from '@/lib/display-path'import { profileColorSoft, resolveProfileColor } from '@/lib/profile-color'import { normalize } from '@/lib/text'import { notify, notifyError } from '@/store/notifications'@@ -258,8 +259,8 @@ function ProfileDetail({ profile }: { profile: ProfileInfo }) {{profile.is_default && <PanelPill tone="good">{p.defaultBadge}</PanelPill>}{profile.has_env && <PanelPill tone="muted">.env</PanelPill>}</div>- <p className="mt-1 truncate font-mono text-[0.66rem] text-muted-foreground/55" title={profile.path}>- {profile.path}+ <p className="mt-1 truncate font-mono text-[0.66rem] text-muted-foreground/55" title={displayPath(profile.path)}>+ {displayPath(profile.path)}</p></div>diff --git a/apps/desktop/src/app/right-sidebar/files/remote-picker.tsx b/apps/desktop/src/app/right-sidebar/files/remote-picker.tsxindex b502c014c7d..3374348e20f 100644--- a/apps/desktop/src/app/right-sidebar/files/remote-picker.tsx+++ b/apps/desktop/src/app/right-sidebar/files/remote-picker.tsx@@ -5,6 +5,7 @@ import { Codicon } from '@/components/ui/codicon'import { Dialog, DialogContent, DialogDescription, DialogTitle } from '@/components/ui/dialog'import { useI18n } from '@/i18n'import { readDesktopDir, setDesktopFsRemotePicker } from '@/lib/desktop-fs'+import { displayPath, pathLeaf } from '@/lib/display-path'import { cn } from '@/lib/utils'function clean(path: string) {@@ -24,7 +25,7 @@ function parentDir(path: string) {}function pathName(path: string) {- return path.split('/').filter(Boolean).pop() || path+ return pathLeaf(path) || path}interface PendingSelection {@@ -167,7 +168,7 @@ export function RemoteFolderPicker() {</div><div className="shrink-0 flex items-center justify-between gap-2 border-t border-border/70 px-4 py-3">- <div className="min-w-0 truncate text-xs text-muted-foreground">{currentPath}</div>+ <div className="min-w-0 truncate text-xs text-muted-foreground">{displayPath(currentPath)}</div><div className="flex shrink-0 items-center gap-2"><Button onClick={() => close()} size="sm" variant="ghost">{t.common.cancel}diff --git a/apps/desktop/src/app/right-sidebar/review/file-tree.tsx b/apps/desktop/src/app/right-sidebar/review/file-tree.tsxindex 5a89f0eb8ba..d9be7d3f7d2 100644--- a/apps/desktop/src/app/right-sidebar/review/file-tree.tsx+++ b/apps/desktop/src/app/right-sidebar/review/file-tree.tsx@@ -16,6 +16,7 @@ import { Tip } from '@/components/ui/tooltip'import type { HermesReviewFile } from '@/global'import { useI18n } from '@/i18n'import { isDesktopFsRemoteMode } from '@/lib/desktop-fs'+import { displayPath } from '@/lib/display-path'import { normalizeOrLocalPreviewTarget } from '@/lib/local-preview'import { cn } from '@/lib/utils'import { $renamingPath, copyFilePath, revealFile, toRelativePath } from '@/store/file-actions'@@ -323,7 +324,7 @@ function ReviewFileRow({ node, depth }: { node: ReviewTreeNode; depth: number })event.dataTransfer.setData('text/plain', dragPath)}}style={rowStyle(depth)}- title={dragPath}+ title={displayPath(dragPath)}><Codicon className={cn('shrink-0', glyph.tone)} name={glyph.icon} size="0.8rem" />{/* Dir collapses first (huge shrink); the name only ellipsizes once thediff --git a/apps/desktop/src/app/right-sidebar/review/index.tsx b/apps/desktop/src/app/right-sidebar/review/index.tsxindex df0d02f3324..5b719b01cfb 100644--- a/apps/desktop/src/app/right-sidebar/review/index.tsx+++ b/apps/desktop/src/app/right-sidebar/review/index.tsx@@ -16,6 +16,7 @@ import { DiffCount } from '@/components/ui/diff-count'import { Tip } from '@/components/ui/tooltip'import { useDelayedTrue } from '@/hooks/use-delayed-true'import { useI18n } from '@/i18n'+import { displayPath } from '@/lib/display-path'import { cn } from '@/lib/utils'import { $panesFlipped } from '@/store/layout'import { notifyError } from '@/store/notifications'@@ -162,9 +163,9 @@ export function ReviewPane() {<div className="flex items-center gap-1 px-2.5 py-1.5" data-suppress-pane-reveal-side=""><spanclassName="min-w-0 flex-1 truncate font-mono text-[0.66rem] text-(--ui-text-secondary)"- title={selectedFile.path}+ title={displayPath(selectedFile.path)}>- {selectedFile.path}+ {displayPath(selectedFile.path)}</span><DiffCount added={selectedFile.added} className="text-[0.64rem] leading-4" removed={selectedFile.removed} /><Tip label={selectedFile.staged ? c.unstage : c.stage}>@@ -217,9 +218,9 @@ export function ReviewPane() {{!revertingAll && revertTarget?.path && (<spanclassName="mt-2 block truncate font-mono text-[0.7rem] text-(--ui-text-secondary)"- title={revertTarget.path}+ title={displayPath(revertTarget.path)}>- {revertTarget.path}+ {displayPath(revertTarget.path)}</span>)}</DialogDescription>diff --git a/apps/desktop/src/app/settings/sessions-settings.tsx b/apps/desktop/src/app/settings/sessions-settings.tsxindex 73cfce113f9..82e4a9d0e0a 100644--- a/apps/desktop/src/app/settings/sessions-settings.tsx+++ b/apps/desktop/src/app/settings/sessions-settings.tsx@@ -12,6 +12,7 @@ import {} from '@/hermes'import { useI18n } from '@/i18n'import { sessionTitle } from '@/lib/chat-runtime'+import { pathLeaf } from '@/lib/display-path'import { triggerHaptic } from '@/lib/haptics'import { Archive, ArchiveOff, FolderOpen, Loader2, Trash2 } from '@/lib/icons'import { notify, notifyError } from '@/store/notifications'@@ -26,22 +27,6 @@ const DEFAULT_AUTO_ARCHIVE_DAYS = 3const ARCHIVED_FETCH_LIMIT = 200-function workspaceLabel(cwd: null | string | undefined): string {- const path = cwd?.trim()-- if (!path) {- return ''- }-- return (- path- .replace(/[/\\]+$/, '')- .split(/[/\\]/)- .filter(Boolean)- .pop() ?? path- )-}-export function SessionsSettings() {const { t } = useI18n()const s = t.settings.sessions@@ -139,7 +124,7 @@ export function SessionsSettings() {) : (<div className="grid gap-1">{sessions.map(session => {- const label = workspaceLabel(session.cwd)+ const label = pathLeaf(session.cwd)const busy = busyId === session.idreturn (diff --git a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsxindex adedab3fa54..c78a5ebca5e 100644--- a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx+++ b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx@@ -9,6 +9,7 @@ import { $paneVisible, togglePaneVisible } from '@/components/pane-shell/tree/stimport { Codicon } from '@/components/ui/codicon'import { GlyphSpinner } from '@/components/ui/glyph-spinner'import { useI18n } from '@/i18n'+import { displayPath, pathLeaf } from '@/lib/display-path'import { Activity, AlertCircle, Clock, Command, FolderOpen, Globe, Hash, Loader2, Terminal } from '@/lib/icons'import type { RuntimeReadinessResult } from '@/lib/runtime-readiness'import { contextBarLabel, LiveDuration, usageContextLabel } from '@/lib/statusbar'@@ -29,6 +30,7 @@ import {$sessions,$sessionStartedAt,$turnStartedAt,+ idsShareLineage,sessionMatchesStoredId,setCurrentUsage} from '@/store/session'@@ -50,13 +52,6 @@ import type { StatusbarItem } from '../statusbar-controls'const EMPTY_USAGE = { calls: 0, input: 0, output: 0, total: 0 } as const-function workspaceLabel(cwd: string): string {- const normalized = cwd.replace(/[\\/]+$/, '')- const leaf = normalized.split(/[\\/]/).filter(Boolean).pop()-- return leaf || cwd-}-interface StatusbarItemsOptions {agentsOpen: booleanchatOpen: boolean@@ -97,13 +92,10 @@ export function useStatusbarItems({// minimized zone, which lit the button for a pane the user couldn't see.const terminalShowing = useStore($paneVisible('terminal'))const primaryBusy = useStore($busy)- const currentCwd = useStore($currentCwd)- // Derive the workspace's project name from the already-cached project tree- // (backend truth via projects.*), so the status item labels by project without- // a second per-session copy of the same fact. Re-derives whenever the cwd or- // the tree changes; null (no named project) falls back to the cwd leaf below.- const projectTree = useStore($projectTree)- const projectName = useMemo(() => projectNameForCwd(currentCwd), [currentCwd, projectTree])+ // Draft / primary composer atom — used only while the focused surface is the+ // primary (or a draft with no runtime slice yet). A focused TILE keeps its+ // own cwd in `$sessionStates` and must not paint the primary's workspace.+ const primaryCwd = useStore($currentCwd)const primaryUsage = useStore($currentUsage)const gatewayRestarting = useStore($gatewayRestarting)const primarySessionStartedAt = useStore($sessionStartedAt)@@ -131,15 +123,14 @@ export function useStatusbarItems({// The FOCUSED session (interacted tile, else the primary — the same// derivation the titlebar title follows): every session-scoped readout- // below (context count, timers, busy pulse) tracks it, so clicking into a- // tile makes the statusbar describe THAT session.+ // below (workspace cwd, context count, timers, busy pulse) tracks it, so+ // clicking into a tile makes the statusbar describe THAT session.const focusedStoredSessionId = useStore($focusedStoredSessionId)const focusedRuntimeId = useStore($focusedRuntimeId)// `$focusedSessionState` is a projection of `$sessionStates`, which is// republished on EVERY message delta — tens of times a second during a turn.- // Only three fields are read off it here, so subscribing to the whole object- // re-ran this hook (and re-created all ~9 statusbar items) per token. Select- // each field individually so an unchanged readout bails out instead.+ // Only the fields read here are selected, so an unchanged readout bails out+ // instead of rebuilding all ~9 statusbar items per token.const focusedBusy = useStoreSelector($focusedSessionState, state => Boolean(state?.busy))const focusedTurnStartedAt = useStoreSelector($focusedSessionState, state => state?.turnStartedAt ?? null)// `usage` is an object, so it can't be compared as a scalar. It IS however@@ -147,6 +138,15 @@ export function useStatusbarItems({// reports new usage — far rarer than a delta — so its reference is a valid// bail-out key on its own.const focusedUsage = useStoreSelector($focusedSessionState, state => state?.usage ?? null)+ const focusedStateCwd = useStoreSelector($focusedSessionState, state => state?.cwd?.trim() || '')+ // Runtime slices carry the stored id they were bound for. During a primary+ // tab switch the runtime id can lag a frame behind the new selection — the+ // slice still describes the PREVIOUS chat. Gate live cwd on ownership so we+ // never paint session A's workspace while the tab already shows session B.+ const focusedStateStoredId = useStoreSelector(+ $focusedSessionState,+ state => state?.storedSessionId?.trim() || null+ )const selectedStoredSessionId = useStore($selectedStoredSessionId)const primaryFocused = !focusedStoredSessionId || focusedStoredSessionId === selectedStoredSessionId@@ -159,15 +159,61 @@ export function useStatusbarItems({const turnStartedAt = primaryFocused ? primaryTurnStartedAt : focusedTurnStartedAt- // A tile's session-start comes from its stored row (the cache only knows- // runtime state); seconds → ms. Only this ONE scalar is read off- // `$sessions`, so select it — a whole-list `useStore` re-ran the hook on- // every session-list write (title updates, poll refreshes, archives).+ // A tile's session-start + cold cwd come from its stored row (the cache only+ // knows runtime state). Only these scalars are read off `$sessions`, so+ // select them — a whole-list `useStore` re-ran the hook on every session-list+ // write (title updates, poll refreshes, archives).const focusedRowStartedAt = useStoreSelector($sessions, sessions =>focusedStoredSessionId? (sessions.find(s => sessionMatchesStoredId(s, focusedStoredSessionId))?.started_at ?? null): null)+ const focusedRowCwd = useStoreSelector($sessions, sessions => {+ if (!focusedStoredSessionId) {+ return ''+ }++ const row = sessions.find(s => sessionMatchesStoredId(s, focusedStoredSessionId))++ return row?.cwd?.trim() || ''+ })++ // Live runtime cwd is authoritative once it belongs to the focused chat+ // (agent can relocate mid-turn). Until then — cold tabs, mid-switch lag —+ // the stored session row is the selection's project. Primary drafts fall+ // through to `$currentCwd`. A focused TILE must never inherit the primary's+ // workspace — an empty tile cwd stays empty rather than lying about another+ // project's path.+ //+ // Lineage match is a pure derivation of ($sessions + the two ids). Select it+ // so a session-list write only re-renders when the answer actually flips —+ // not on every title/archive refresh of an unrelated row.+ const liveCwdSharesFocusLineage = useStoreSelector($sessions, sessions => {+ if (!focusedStoredSessionId || !focusedStateStoredId) {+ return false+ }++ return idsShareLineage(focusedStoredSessionId, focusedStateStoredId, sessions)+ })+ const liveCwdBelongsToFocus =+ Boolean(focusedStateCwd) &&+ (!focusedStoredSessionId ||+ !focusedStateStoredId ||+ focusedStateStoredId === focusedStoredSessionId ||+ liveCwdSharesFocusLineage)+ const currentCwd = (+ (liveCwdBelongsToFocus ? focusedStateCwd : '') ||+ focusedRowCwd ||+ (primaryFocused ? primaryCwd : '') ||+ ''+ ).trim()++ // Derive the workspace's project name from the already-cached project tree+ // (backend truth via projects.*), so the status item labels by project without+ // a second per-session copy of the same fact. Re-derives whenever the cwd or+ // the tree changes; null (no named project) falls back to the cwd leaf below.+ const projectTree = useStore($projectTree)+ const projectName = useMemo(() => projectNameForCwd(currentCwd), [currentCwd, projectTree])const sessionStartedAt = primaryFocused? primarySessionStartedAt@@ -369,33 +415,33 @@ export function useStatusbarItems({hidden: !currentCwd,icon: <FolderOpen className="size-3" />,id: 'workspace-cwd',- // Prefer the named project; fall back to the cwd leaf. The full cwd is- // always in the tooltip (`title` below), so hovering reveals where the- // session actually sits — the worktree/subfolder, not just the project.- label: projectName || (currentCwd ? workspaceLabel(currentCwd) : undefined),+ // Prefer the named project; fall back to the cwd leaf. Hover tip uses+ // the shared display formatter (home → ~) so statusbar and branch bar+ // agree on how a path looks.+ label: projectName || (currentCwd ? pathLeaf(currentCwd) : undefined),menuItems: currentCwd? [{id: 'copy-workspace-path',label: fileMenu.copyPath,onSelect: () => void copyFilePath(currentCwd),- title: currentCwd+ title: displayPath(currentCwd)},{id: 'reveal-workspace-finder',label: fileMenu.revealFileManager,onSelect: () => void revealFile(currentCwd),- title: currentCwd+ title: displayPath(currentCwd)},{id: 'reveal-workspace-sidebar',label: fileMenu.revealInSidebar,onSelect: () => revealFileInTree(currentCwd),- title: currentCwd+ title: displayPath(currentCwd)}]: undefined,- title: currentCwd || undefined,+ title: currentCwd ? displayPath(currentCwd) : undefined,toggleLabel: copy.toggleWorkspace,variant: 'menu'},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 b3d0fe1ad54..021036440d6 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@@ -8,6 +8,7 @@ import { DiffCount } from '@/components/ui/diff-count'import { FadeScroll } from '@/components/ui/fade-scroll'import { FileTypeIcon } from '@/components/ui/file-type-icon'import { useI18n } from '@/i18n'+import { displayPath } from '@/lib/display-path'import { cn } from '@/lib/utils'import { openReviewForPath, revealReview } from '@/store/review'@@ -58,7 +59,7 @@ export const ChangedFilesCard: FC<{ parts: readonly unknown[] }> = ({ parts }) =className="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)}- title={file.path}+ title={displayPath(file.path)}type="button"><FileTypeIcon className="shrink-0 text-(--ui-text-tertiary)" path={file.path} size="0.875rem" />