/bots looks like Command HQ, and stops opening the wrong chat
TWO BUGS AND A LAYOUT. the first outing of /bots opened a months-old conversation about deleting proxy hosts. resume-newest called useClaudeSessions(absoluteCwd) with no context, and a screen that owns its own directory has cwd '~', so that join yields null and the hook listed the caller's HOME. the panel then resumed the newest thing there. same bug the header had, one function down; the declared context wins now. second: ChatPanelWrapper takes an optional sessionId, because a screen whose selection lives in the URL cannot also let usePanelSession decide — two sources would disagree and the URL would lose. null means "the screen chose a new chat", undefined means "no opinion", and collapsing them would make New snap back to the newest. the layout is Command HQ's: a narrow list left, the conversation right, and a route pair — /bots is the new-bot state, /bots/:sessionId is one of them. rows are real links, so cmd-click works and a reload keeps its place. no categories pane. a commander is a job somebody files and a filter earns its place; a bot is a sentence, and a filter over a handful of one-line watches would be furniture. no table either: every bot is a chat in bots/, so the list IS the session list for that directory. nothing to keep in step. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Officer-Session: 656f5c85-e49a-4f1f-b9f3-042a04b4d043
This commit is contained in:
@@ -164,6 +164,18 @@ type ChatPanelWrapperProps = {
|
||||
* platform mounts, not a caller that could pass this.
|
||||
*/
|
||||
chatContext?: { context: string; contextId?: string };
|
||||
/**
|
||||
* Which conversation to show, when the SCREEN decides rather than the panel.
|
||||
*
|
||||
* `usePanelSession` is right for a dashboard, where two chat panels side by side hold different
|
||||
* conversations and each remembers its own. It is wrong for a screen whose selection lives in the URL —
|
||||
* `/bots/:sessionId`, the same shape Command HQ uses — because then two sources would disagree about
|
||||
* which one is open and the URL would lose.
|
||||
*
|
||||
* `null` means the screen has chosen a NEW chat, which is not the same as `undefined` meaning it has no
|
||||
* opinion. Collapsing them would make New snap back to the newest.
|
||||
*/
|
||||
sessionId?: string | null;
|
||||
/**
|
||||
* Called when a turn ends, with whether it ran any tools.
|
||||
*
|
||||
@@ -182,6 +194,7 @@ export const ChatPanelWrapper = ({
|
||||
panelId,
|
||||
promptPrefix,
|
||||
chatContext: declared,
|
||||
sessionId: fromScreen,
|
||||
onTurnComplete: alsoOnTurnComplete,
|
||||
}: ChatPanelWrapperProps) => {
|
||||
const { workspace, cwd, root } = useWorkspace();
|
||||
@@ -261,11 +274,24 @@ export const ChatPanelWrapper = ({
|
||||
const { defaultCwd } = useChatPwds();
|
||||
const relativeCwd = cwdToPath(cwd);
|
||||
const absoluteCwd = relativeCwd === '/' ? null : defaultCwd ? `${defaultCwd.replace(/\/$/, '')}${relativeCwd}` : null;
|
||||
const { sessions, isLoading: sessionsLoading } = useClaudeSessions(absoluteCwd);
|
||||
/*
|
||||
The declared context wins over the derived path, and it has to.
|
||||
|
||||
const neverChose = panelSessionId === undefined;
|
||||
A screen that owns its own directory — a plugin's chats, `/bots` — has a `cwd` of `~`, so the join
|
||||
above yields null and this listed the caller's HOME instead. The panel then resumed the newest
|
||||
conversation in the home directory, which on this machine meant `/bots` opening a months-old chat about
|
||||
something else entirely. Reported the first time the screen was used.
|
||||
*/
|
||||
const { sessions, isLoading: sessionsLoading } = useClaudeSessions(absoluteCwd, {
|
||||
chatContext: declared ? { context: declared.context, contextId: declared.contextId } : null,
|
||||
});
|
||||
|
||||
// A screen that says which conversation is open wins over the panel's own memory of one.
|
||||
const screenDecides = fromScreen !== undefined;
|
||||
const neverChose = !screenDecides && panelSessionId === undefined;
|
||||
const selectedSessionId =
|
||||
agentPanel.agent?.sessionKey ?? (neverChose ? sessions[0]?.id : (panelSessionId ?? undefined));
|
||||
agentPanel.agent?.sessionKey ??
|
||||
(screenDecides ? (fromScreen ?? undefined) : neverChose ? sessions[0]?.id : (panelSessionId ?? undefined));
|
||||
|
||||
/**
|
||||
* Fetch the transcript BEFORE the chat mounts.
|
||||
|
||||
Reference in New Issue
Block a user