Skip to content

Commit 3ed78b3

Browse files
juliusmarmingecodex
andcommitted
Handle canonical-route drafts when gating thread detail
Co-authored-by: codex <[email protected]>
1 parent 9256975 commit 3ed78b3

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

‎apps/web/src/components/BranchToolbar.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ export const BranchToolbar = memo(function BranchToolbar({
234234
() => scopeThreadRef(environmentId, threadId),
235235
[environmentId, threadId],
236236
);
237-
const serverThread = useThread(threadRef, { waitForShell: draftId !== undefined });
238237
const draftThread = useComposerDraftStore((store) =>
239238
draftId ? store.getDraftSession(draftId) : store.getDraftThreadByRef(threadRef),
240239
);
240+
const serverThread = useThread(threadRef, { waitForShell: draftThread !== null });
241241
const setDraftThreadContext = useComposerDraftStore((store) => store.setDraftThreadContext);
242242
const activeProjectRef = serverThread
243243
? scopeProjectRef(serverThread.environmentId, serverThread.projectId)

‎apps/web/src/components/BranchToolbarBranchSelector.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ export function BranchToolbarBranchSelector({
129129
() => scopeThreadRef(environmentId, threadId),
130130
[environmentId, threadId],
131131
);
132-
const serverThread = useThread(threadRef, { waitForShell: draftId !== undefined });
133-
const serverSession = serverThread?.session ?? null;
134132
const draftThread = useComposerDraftStore((store) =>
135133
draftId ? store.getDraftSession(draftId) : store.getDraftThreadByRef(threadRef),
136134
);
135+
const serverThread = useThread(threadRef, { waitForShell: draftThread !== null });
136+
const serverSession = serverThread?.session ?? null;
137137
const setDraftThreadContext = useComposerDraftStore((store) => store.setDraftThreadContext);
138138

139139
const activeProjectRef = serverThread

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,14 @@ function ChatViewContent(props: ChatViewProps) {
11811181
);
11821182
const composerDraftTarget: ScopedThreadRef | DraftId =
11831183
routeKind === "server" ? routeThreadRef : props.draftId;
1184-
const serverThread = useThread(routeThreadRef, { waitForShell: routeKind === "draft" });
1184+
const draftThread = useComposerDraftStore((store) =>
1185+
routeKind === "server"
1186+
? store.getDraftSessionByRef(routeThreadRef)
1187+
: draftId
1188+
? store.getDraftSession(draftId)
1189+
: null,
1190+
);
1191+
const serverThread = useThread(routeThreadRef, { waitForShell: draftThread !== null });
11851192
const markThreadVisited = useUiStateStore((store) => store.markThreadVisited);
11861193
const activeThreadLastVisitedAt = useUiStateStore(
11871194
(store) => store.threadLastVisitedAtById[routeThreadKey],
@@ -1234,13 +1241,6 @@ function ChatViewContent(props: ChatViewProps) {
12341241
const setLogicalProjectDraftThreadId = useComposerDraftStore(
12351242
(store) => store.setLogicalProjectDraftThreadId,
12361243
);
1237-
const draftThread = useComposerDraftStore((store) =>
1238-
routeKind === "server"
1239-
? store.getDraftSessionByRef(routeThreadRef)
1240-
: draftId
1241-
? store.getDraftSession(draftId)
1242-
: null,
1243-
);
12441244
const promptRef = useRef("");
12451245
const composerImagesRef = useRef<ComposerImageAttachment[]>([]);
12461246
const composerTerminalContextsRef = useRef<TerminalContextDraft[]>([]);

‎apps/web/src/components/GitActionsControl.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -986,16 +986,16 @@ export default function GitActionsControl({
986986
() => (activeThreadRef ? { threadRef: activeThreadRef } : undefined),
987987
[activeThreadRef],
988988
);
989-
const activeServerThread = useThread(activeThreadRef, {
990-
waitForShell: draftId !== undefined,
991-
});
992989
const activeDraftThread = useComposerDraftStore((store) =>
993990
draftId
994991
? store.getDraftSession(draftId)
995992
: activeThreadRef
996993
? store.getDraftThreadByRef(activeThreadRef)
997994
: null,
998995
);
996+
const activeServerThread = useThread(activeThreadRef, {
997+
waitForShell: activeDraftThread !== null,
998+
});
999999
const setDraftThreadContext = useComposerDraftStore((store) => store.setDraftThreadContext);
10001000
const [isCommitDialogOpen, setIsCommitDialogOpen] = useState(false);
10011001
const [dialogCommitMessage, setDialogCommitMessage] = useState("");

0 commit comments

Comments
 (0)