Skip to content

Commit 741eb41

Browse files
committed
fix: resolve rebase fallout on assistant copy state
1 parent 8d776f7 commit 741eb41

4 files changed

Lines changed: 16 additions & 29 deletions

File tree

apps/web/src/components/chat/MessagesTimeline.logic.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,21 @@ export function normalizeCompactToolLabel(value: string): string {
5959
return value.replace(/\s+(?:complete|completed)\s*$/i, "").trim();
6060
}
6161

62+
export function resolveAssistantMessageCopyState({
63+
text,
64+
streaming,
65+
}: {
66+
text: string | null;
67+
streaming: boolean;
68+
}) {
69+
const hasText = text !== null && text.trim().length > 0;
70+
return {
71+
disabled: streaming,
72+
text: hasText ? text : null,
73+
visible: streaming || hasText,
74+
};
75+
}
76+
6277
export function deriveMessagesTimelineRows(input: {
6378
timelineEntries: ReadonlyArray<TimelineEntry>;
6479
completionDividerBeforeEntryId: string | null;

apps/web/src/components/chat/MessagesTimeline.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
deriveMessagesTimelineRows,
4646
estimateMessagesTimelineRowHeight,
4747
normalizeCompactToolLabel,
48+
resolveAssistantMessageCopyState,
4849
type MessagesTimelineRow,
4950
} from "./MessagesTimeline.logic";
5051
import { TerminalContextInlineChip } from "./TerminalContextInlineChip";

apps/web/src/terminalStateStore.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
} from "./terminalStateStore";
99

1010
const THREAD_ID = ThreadId.makeUnsafe("thread-1");
11-
const TERMINAL_STATE_STORAGE_KEY = "t3code:terminal-state:v1";
1211

1312
function makeTerminalEvent(
1413
type: TerminalEvent["type"],

apps/web/src/terminalStateStore.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,34 +45,6 @@ function createTerminalStateStorage() {
4545
return resolveStorage(typeof window !== "undefined" ? window.localStorage : undefined);
4646
}
4747

48-
function createMemoryStorage(): StateStorage {
49-
const store = new Map<string, string>();
50-
return {
51-
getItem: (name) => store.get(name) ?? null,
52-
setItem: (name, value) => {
53-
store.set(name, value);
54-
},
55-
removeItem: (name) => {
56-
store.delete(name);
57-
},
58-
};
59-
}
60-
61-
function createTerminalStateStorage() {
62-
if (
63-
typeof localStorage !== "undefined" &&
64-
typeof localStorage.getItem === "function" &&
65-
typeof localStorage.setItem === "function" &&
66-
typeof localStorage.removeItem === "function"
67-
) {
68-
return localStorage;
69-
}
70-
71-
return createMemoryStorage();
72-
}
73-
74-
const terminalStateStorage = createTerminalStateStorage();
75-
7648
function normalizeTerminalIds(terminalIds: string[]): string[] {
7749
const ids = [...new Set(terminalIds.map((id) => id.trim()).filter((id) => id.length > 0))];
7850
return ids.length > 0 ? ids : [DEFAULT_THREAD_TERMINAL_ID];

0 commit comments

Comments
 (0)