@devries-cameron20 / t3code-1 / commits / 8211893622
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): reveal folded imported responses when opening citations (#18423)

Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Alex Southwell committed Oct 19, 2026 at 16:32 UTC 821189362209838136064e7eb86f7aaf99a9c405
3 files changed +75 -6
apps/web/src/components/chat/MessagesTimeline.browser.test.tsx
+56
@@ -795,6 +795,62 @@ describe("MessagesTimeline attachments", () => {
795 });
796
797 describe("MessagesTimeline history and thread links", () => {
798 + it.each([
799 + ["imported runless", null],
800 + ["standard", RunId.make("citation-run")],
801 + ] as const)("reveals a cited response inside a folded %s turn", async (_label, runId) => {
802 + const quote = "The imported response contains this cited detail.";
803 + const props = {
804 + ...baseProps(),
805 + timelineEntries: [
806 + message("Investigate the issue.", { runId }, "citation-prompt"),
807 + message(quote, { role: "assistant", runId }, "citation-source"),
808 + message("Investigation complete.", { role: "assistant", runId }, "citation-answer"),
809 + ],
810 + };
811 + await renderElement(<MessagesTimeline {...props} />);
812 + const source = () =>
813 + container.querySelector<HTMLElement>('[data-assistant-citation-source="citation-source"]');
814 + await vi.waitFor(() => expect(text()).toContain("Investigation complete."));
815 + expect(buttons(/^Worked/)).toHaveLength(1);
816 + expect(source()).toBeNull();
817 +
818 + await act(async () =>
819 + roots.at(-1)!.render(
820 + <MessagesTimeline
821 + {...props}
822 + citationRequest={{
823 + key: "open-citation",
824 + citation: {
825 + version: 1,
826 + environmentId: ENVIRONMENT_ID,
827 + threadId: ThreadId.make(`thread-${threadCount}`),
828 + messageId: MessageId.make("citation-source"),
829 + text: quote,
830 + start: 0,
831 + end: quote.length,
832 + prefix: "",
833 + suffix: "",
834 + },
835 + }}
836 + />,
837 + ),
838 + );
839 +
840 + await vi.waitFor(() => {
841 + expect(source()?.textContent ?? "").toContain(quote);
842 + const highlight = CSS.highlights.get("t3-assistant-citation");
843 + expect(highlight).toBeDefined();
844 + const range = [...highlight!][0] as Range;
845 + expect(range.toString()).toBe(quote);
846 + const viewport = container.querySelector<HTMLElement>("[data-assistant-citation-viewport]")!;
847 + const bounds = range.getBoundingClientRect();
848 + expect(bounds.height).toBeGreaterThan(0);
849 + expect(bounds.top).toBeGreaterThanOrEqual(viewport.getBoundingClientRect().top);
850 + expect(bounds.bottom).toBeLessThanOrEqual(viewport.getBoundingClientRect().bottom);
851 + });
852 + });
853 +
854 it("loads earlier turns from a control ahead of the bounded timeline", async () => {
855 const onLoadEarlier = vi.fn();
856 await renderTimeline([message("Recent activity")], {
apps/web/src/components/chat/MessagesTimeline.tsx
+14 -5
@@ -800,8 +800,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
800 });
801 }, [latestRun, listIdentityKey]);
802
803 - // Find the fold that hides the match: imported turns have no run id but still
804 - // fold under a synthetic key, so the match's own run id cannot open them.
803 + // Imported turns fold under synthetic keys rather than the entries' own run ids.
804 const findFoldRunIds = findActive
805 ? timelineTurnFoldRunIdsByEntryId({
806 timelineEntries,
@@ -811,9 +810,8 @@ const ConversationTimeline = memo(function ConversationTimeline({
810 runlessWorkActive,
811 })
812 : null;
814 - const activeFindRunId = activeFindMatch
815 - ? findFoldRunIds?.get(activeFindMatch.entryId)
816 - : undefined;
813 + const activeFindRunId =
814 + findActive && activeFindMatch ? findFoldRunIds?.get(activeFindMatch.entryId) : undefined;
815 const [expandedFindRunId, setExpandedFindRunId] = useState<RunId | undefined>();
816 if (expandedFindRunId !== activeFindRunId) {
817 setExpandedFindRunId(activeFindRunId);
@@ -1003,6 +1001,17 @@ const ConversationTimeline = memo(function ConversationTimeline({
1001 viewport: timelineViewportElement,
1002 historyLoading: citationHistoryLoading,
1003 loadEarlier,
1004 + getTurnFoldRunId: (entryId) =>
1005 + (
1006 + findFoldRunIds ??
1007 + timelineTurnFoldRunIdsByEntryId({
1008 + timelineEntries,
1009 + latestRun,
1010 + runningRunId,
1011 + isWorking,
1012 + runlessWorkActive,
1013 + })
1014 + ).get(entryId),
1015 onExpandTurn: expandCitedRun,
1016 onManualNavigation,
1017 });
apps/web/src/components/chat/useAssistantCitationTarget.ts
+5 -1
@@ -20,6 +20,7 @@ export function useAssistantCitationTarget({
20 viewport,
21 historyLoading,
22 loadEarlier,
23 + getTurnFoldRunId,
24 onExpandTurn,
25 onManualNavigation,
26 }: {
@@ -30,6 +31,7 @@ export function useAssistantCitationTarget({
31 viewport: HTMLElement | null;
32 historyLoading: boolean;
33 loadEarlier: CitationHistoryPage | null;
34 + getTurnFoldRunId: (entryId: string) => RunId | undefined;
35 onExpandTurn: (runId: RunId) => void;
36 onManualNavigation: () => void;
37 }) {
@@ -123,12 +125,14 @@ export function useAssistantCitationTarget({
125 (row) => row.kind === "message" && row.message.id === navigation.target.citation.messageId,
126 );
127 if (index < 0) {
126 - if (source.message.runId) onExpandTurn(source.message.runId);
128 + const foldRunId = getTurnFoldRunId(source.id);
129 + if (foldRunId) onExpandTurn(foldRunId);
130 return;
131 }
132 if (listLoaded && listRef.current) setReady(navigation.target);
133 }, [
134 entries,
135 + getTurnFoldRunId,
136 historyLoading,
137 listLoaded,
138 listRef,