Skip to content

Commit 7fe3491

Browse files
committed
refactor(ui): move branch-display ownership out of the header render
check-lint-core-4 flagged chat-pane-header.ts at 702 counted lines after the equivalence gate landed there. The branches-for-display decision belongs to the state owner anyway: displayedChatSessionBranches in chat-history.ts now owns it and the header render consumes the fact.
1 parent 0ab98e1 commit 7fe3491

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎ui/src/pages/chat/chat-history.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,15 @@ export async function switchChatHistoryBranch(
13701370
}
13711371
}
13721372

1373+
/** Branches for the current pane; equivalence covers alias-canonicalization windows (#124020 class). */
1374+
export function displayedChatSessionBranches(
1375+
state: Pick<ChatState, "chatBranches" | "chatBranchesSessionKey" | "sessionKey">,
1376+
): SessionBranch[] {
1377+
return areUiSessionKeysEquivalent(state.chatBranchesSessionKey, state.sessionKey)
1378+
? (state.chatBranches ?? [])
1379+
: [];
1380+
}
1381+
13731382
export async function loadChatBranches(state: ChatState): Promise<void> {
13741383
const sessions = state.sessions;
13751384
const client = state.client;

‎ui/src/pages/chat/chat-pane-header.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import { t } from "../../i18n/index.ts";
2222
import { isGatewayMethodAdvertised } from "../../lib/gateway-methods.ts";
2323
import { readSessionMethodAccess } from "../../lib/session-method-access.ts";
2424
import {
25-
areUiSessionKeysEquivalent,
2625
canArchiveSessionRow,
2726
canDeleteSessionRows,
2827
resolveUiConfiguredMainKey,
2928
} from "../../lib/sessions/session-key.ts";
3029
import { isActiveTask } from "../../lib/tasks/data.ts";
3130
import { renderBoardViewSwitch } from "./board-session-surface.ts";
31+
import { displayedChatSessionBranches } from "./chat-history.ts";
3232
import { resolveChatPaneDesktopTarget, resolveChatPanePlacement } from "./chat-pane-placement.ts";
3333
import { ChatPaneSessionMenu } from "./chat-pane-session-menu.ts";
3434
import { readChatSessionActionAccess } from "./chat-session-action-access.ts";
@@ -367,11 +367,7 @@ export abstract class ChatPaneHeader extends ChatPaneSessionMenu {
367367
workspaceIcon: this.resolveWorkspaceIcon(workspace.root ? row?.key : undefined),
368368
parentSession: resolveChatPaneParentSession(row, this.state?.sessionsResult?.sessions ?? []),
369369
branch,
370-
branches:
371-
this.state &&
372-
areUiSessionKeysEquivalent(this.state.chatBranchesSessionKey, this.state.sessionKey)
373-
? (this.state.chatBranches ?? [])
374-
: [],
370+
branches: this.state ? displayedChatSessionBranches(this.state) : [],
375371
branchSwitchDisabledReason,
376372
platform: this.headerPlatform,
377373
canReveal,

0 commit comments

Comments
 (0)