The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 18:30 UTC
Use stable IDs for approval actions in ChatView
- Derive `activeSessionId` and `activeThreadId` before approval callbacks - Avoid stale thread/session captures when submitting approval decisions - Pass `hasMessages` to `MessagesTimeline` instead of the full thread
Julius Marminge committed
Feb 16, 2026 at 00:47 UTC
73fa2d66c79eb1351fbae55a81c61e1f7b88c619
1 file changed
+10
-9
apps/web/src/components/ChatView.tsx
+10
-9
@@ -51,7 +51,7 @@ import {
51
} from "../session-logic";
52
import { isScrollContainerNearBottom } from "../chat-scroll";
53
import { useStore } from "../store";
54
-import type { ChatImageAttachment, Thread } from "../types";
54
+import type { ChatImageAttachment } from "../types";
55
import BranchToolbar from "./BranchToolbar";
56
import GitActionsControl from "./GitActionsControl";
57
import {
@@ -168,6 +168,7 @@ export default function ChatView() {
168
169
const activeThread = state.threads.find((t) => t.id === state.activeThreadId);
170
const activeThreadId = activeThread?.id ?? null;
171
+ const activeSessionId = activeThread?.session?.sessionId;
172
const activeProject = state.projects.find((p) => p.id === activeThread?.projectId);
173
const selectedModel = resolveModelSlug(
174
activeThread?.model ?? activeProject?.model ?? DEFAULT_MODEL,
@@ -895,28 +896,28 @@ export default function ChatView() {
896
897
const onRespondToApproval = useCallback(
898
async (requestId: string, decision: ProviderApprovalDecision) => {
898
- if (!api || !activeThread?.session) return;
899
+ if (!api || !activeSessionId || !activeThreadId) return;
900
901
setRespondingRequestIds((existing) =>
902
existing.includes(requestId) ? existing : [...existing, requestId],
903
);
904
try {
905
await api.providers.respondToRequest({
905
- sessionId: activeThread.session.sessionId,
906
+ sessionId: activeSessionId,
907
requestId,
908
decision,
909
});
910
} catch (err) {
911
dispatch({
912
type: "SET_ERROR",
912
- threadId: activeThread.id,
913
+ threadId: activeThreadId,
914
error: err instanceof Error ? err.message : "Failed to submit approval decision.",
915
});
916
} finally {
917
setRespondingRequestIds((existing) => existing.filter((id) => id !== requestId));
918
}
919
},
919
- [activeThread?.id, activeThread?.session, api, dispatch],
920
+ [activeSessionId, activeThreadId, api, dispatch],
921
);
922
923
const onModelSelect = useCallback(
@@ -1015,7 +1016,7 @@ export default function ChatView() {
1016
onScroll={onMessagesScroll}
1017
>
1018
<MessagesTimeline
1018
- activeThread={activeThread}
1019
+ hasMessages={activeThread.messages.length > 0}
1020
isWorking={isWorking}
1021
timelineEntries={timelineEntries}
1022
completionDividerBeforeEntryId={completionDividerBeforeEntryId}
@@ -1413,7 +1414,7 @@ const PendingApprovalsPanel = memo(function PendingApprovalsPanel({
1414
});
1415
1416
interface MessagesTimelineProps {
1416
- activeThread: Thread;
1417
+ hasMessages: boolean;
1418
isWorking: boolean;
1419
timelineEntries: ReturnType<typeof deriveTimelineEntries>;
1420
completionDividerBeforeEntryId: string | null;
@@ -1427,7 +1428,7 @@ interface MessagesTimelineProps {
1428
}
1429
1430
const MessagesTimeline = memo(function MessagesTimeline({
1430
- activeThread,
1431
+ hasMessages,
1432
isWorking,
1433
timelineEntries,
1434
completionDividerBeforeEntryId,
@@ -1439,7 +1440,7 @@ const MessagesTimeline = memo(function MessagesTimeline({
1440
onImageExpand,
1441
messagesEndRef,
1442
}: MessagesTimelineProps) {
1442
- if (activeThread.messages.length === 0 && !isWorking) {
1443
+ if (!hasMessages && !isWorking) {
1444
return (
1445
<div className="flex h-full items-center justify-center">
1446
<p className="text-sm text-muted-foreground/30">Send a message to start the conversation.</p>