diff --git a/src/workspaces/officerdev/src/apps/Chat/ChatHeader.tsx b/src/workspaces/officerdev/src/apps/Chat/ChatHeader.tsx index edd812fd..dd570c47 100644 --- a/src/workspaces/officerdev/src/apps/Chat/ChatHeader.tsx +++ b/src/workspaces/officerdev/src/apps/Chat/ChatHeader.tsx @@ -7,7 +7,7 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; -import { useClaudeSessions } from 'state/useClaudeSessions'; +import { useChatPwds, useClaudeSessions } from 'state/useClaudeSessions'; import { useWorkspace, cwdToPath } from '../../components/Workspace'; import { usePanelSession } from './use-panel-session'; import type { ChatMessage } from './types'; @@ -34,10 +34,23 @@ const title = (s: { title: string }) => s.title || '(untitled)'; export const ChatHeader = ({ panelId }: { panelId?: string }) => { const { workspace, cwd } = useWorkspace(); - const cwdPath = cwdToPath(cwd); - // The endpoint takes a home-relative path and treats absent as "the caller's default", which is what an - // unscoped panel wants. - const { sessions, renameSession, deleteSession } = useClaudeSessions(cwdPath === '/' ? null : cwdPath); + + /** + * `/chat/sessions` wants an ABSOLUTE path, and that is not the convention next door. + * + * The file endpoints take a home-relative path (`/Tests/platform`); chat takes the real one, because + * Claude's folder name is `cwd.replace(/[^a-zA-Z0-9]/g, '-')` applied to the directory a turn actually + * ran in. Handing it the home-relative form asked for `-Tests-platform`, which is not a directory that + * exists, so a dashboard with a perfectly good conversation in it listed nothing at all. + * + * `useChatPwds().defaultCwd` is the caller's home as the server sees it — the same value `cwdOf` falls + * back to — so it is the right thing to join against rather than a second guess at where home is. + */ + const { defaultCwd } = useChatPwds(); + const relative = cwdToPath(cwd); + const absoluteCwd = relative === '/' ? null : defaultCwd ? `${defaultCwd.replace(/\/$/, '')}${relative}` : null; + + const { sessions, renameSession, deleteSession } = useClaudeSessions(absoluteCwd); const [sessionId, setSessionId] = usePanelSession(panelId, workspace); const [renaming, setRenaming] = useState(null);