refactor(btw): read the promoted flag from the panel state, not a second subscription

`useBtwPanelState` already subscribes to the composer's own session — it is
what the fork link is derived from — so asking `useSession` for the same
session and directory a second time in `ChatInput` was a duplicate
subscription for a value already in hand. Expose it as `parentSession` and
read the promoted flag from there.

No behavior change.
This commit is contained in:
dibanez
2026-08-27 14:04:12 +02:00
parent 7a95efc4ac
commit 0389af6cb3
2 changed files with 5 additions and 6 deletions
@@ -18,7 +18,7 @@ import {
import type { AttachedFile } from '@/stores/types/sessionTypes';
import * as sessionActions from '@/sync/session-actions';
import { buildLinkedIssue } from '@/lib/linkedIssues';
import { useSession, useUserMessageHistory } from "@/sync/sync-context";
import { useUserMessageHistory } from "@/sync/sync-context";
import { getInlineCommentDraftKey, useInlineCommentDraftStore, type InlineCommentDraft, type InlineCommentDraftTarget } from '@/stores/useInlineCommentDraftStore';
import { useSnippetsStore } from '@/stores/useSnippetsStore';
import { renderMagicPrompt } from '@/lib/magicPrompts';
@@ -342,11 +342,7 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({
// A session promoted out of `/btw` keeps the boundary instructions in its
// transcript — there is no way to delete a message part — so it has to say
// they no longer apply.
const currentSessionRecord = useSession(
currentSessionId,
currentSessionDirectoryForSync ?? currentDirectory ?? undefined,
);
const isPromotedBtwSession = wasPromotedBtwSession(currentSessionRecord);
const isPromotedBtwSession = wasPromotedBtwSession(btwPanel.parentSession);
const activeRuntimeKey = getRuntimeKey();
const chatDraftIdentity = React.useMemo(
() => createChatDraftIdentity(
@@ -5,6 +5,8 @@ import { getBtwBoundaryMessageID, getBtwSessionID } from '@/lib/sessionBtwMetada
import { useBtwStore } from '@/stores/useBtwStore';
export type BtwPanelState = {
/** The session the composer is in — the one `/btw` would fork. */
parentSession: Session | null;
/** The active fork for this parent, or null when no panel should exist. */
btwSessionId: string | null;
btwSession: Session | null;
@@ -40,6 +42,7 @@ export function useBtwPanelState(
const destroying = Boolean(uiState?.destroying);
const btwSessionId = btwSession && !destroying ? linkedBtwSessionId : null;
return {
parentSession: parentSession ?? null,
btwSessionId,
btwSession: btwSessionId ? btwSession : null,
// SAFETY: the SDK Session type omits the server's `directory` field; this