Skip to content

Commit be343af

Browse files
committed
refactor(tui): simplify copy feedback and regressions
1 parent 2a38dca commit be343af

2 files changed

Lines changed: 3 additions & 87 deletions

File tree

‎packages/tui/src/routes/session/index.tsx‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ export function Session(props: {
11501150
(msg.type === "compaction" && msg.status === "completed" && msg.summary.trim() !== ""),
11511151
)
11521152
if (!lastAssistantMessage) {
1153-
toast.show({ message: "No assistant messages found", variant: "error" })
1153+
toast.show({ message: "No reply text found in the last turn", variant: "error" })
11541154
dialog.clear()
11551155
return
11561156
}
@@ -1165,15 +1165,6 @@ export function Session(props: {
11651165
: lastAssistantMessage.type === "compaction" && lastAssistantMessage.status === "completed"
11661166
? lastAssistantMessage.summary.trim()
11671167
: ""
1168-
if (!text) {
1169-
toast.show({
1170-
message: "No text content found in last assistant message",
1171-
variant: "error",
1172-
})
1173-
dialog.clear()
1174-
return
1175-
}
1176-
11771168
clipboard
11781169
.write(text)
11791170
.then(() => toast.show({ message: "Message copied to clipboard!", variant: "success" }))

‎packages/tui/test/copy-reply.test.tsx‎

Lines changed: 2 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -16,88 +16,17 @@ const assistant = (id: string, texts: string[]): Extract<SessionMessageInfo, { t
1616
? texts.map((text) => ({ type: "text", text }))
1717
: [{ type: "reasoning", text: "Nothing more to add.", time: { created: 1, completed: 2 } }],
1818
})
19-
const summary: SessionMessageInfo = {
20-
type: "compaction",
21-
id: "summary",
22-
status: "completed",
23-
reason: "manual",
24-
summary: " Compaction summary ",
25-
recent: "answer",
26-
time: { created: 3 },
27-
}
28-
2919
test.each([
3020
{
3121
name: "reasoning-only tail",
3222
messages: [user("prompt"), assistant("answer", ["Final answer"]), assistant("tail", [])],
3323
text: "Final answer",
3424
},
35-
{
36-
name: "blank text tail",
37-
messages: [
38-
user("prompt"),
39-
assistant("answer", ["First paragraph", "Second paragraph"]),
40-
assistant("tail", [" ", "\n"]),
41-
],
42-
text: "First paragraph\nSecond paragraph",
43-
},
44-
{
45-
name: "latest text",
46-
messages: [user("prompt"), assistant("earlier", ["Earlier draft"]), assistant("answer", ["Final answer"])],
47-
text: "Final answer",
48-
},
49-
{
50-
name: "tool-only tail",
51-
messages: [
52-
user("prompt"),
53-
assistant("answer", ["Final answer"]),
54-
{
55-
...assistant("tail", []),
56-
content: [
57-
{
58-
type: "tool",
59-
id: "call_execute",
60-
name: "execute",
61-
time: { created: 1, completed: 2 },
62-
state: {
63-
status: "completed",
64-
input: { code: "return 1" },
65-
content: [{ type: "text", text: "Tool output must not be copied" }],
66-
metadata: {},
67-
},
68-
},
69-
],
70-
},
71-
],
72-
text: "Final answer",
73-
},
74-
{
75-
name: "last compaction",
76-
messages: [user("prompt"), assistant("answer", ["Earlier draft"]), summary],
77-
text: "Compaction summary",
78-
},
79-
{
80-
name: "compaction summary",
81-
messages: [user("prompt"), assistant("answer", ["Earlier draft"]), summary, assistant("tail", [])],
82-
text: "Compaction summary",
83-
},
8425
{
8526
name: "empty current turn",
8627
messages: [user("old"), assistant("old-answer", ["Previous turn"]), user("prompt"), assistant("tail", [])],
8728
text: undefined,
8829
},
89-
{
90-
name: "reverted messages",
91-
messages: [
92-
user("prompt"),
93-
assistant("answer", ["Visible answer"]),
94-
assistant("tail", []),
95-
user("reverted"),
96-
assistant("hidden", ["Hidden answer"]),
97-
],
98-
text: "Visible answer",
99-
revert: { messageID: "reverted" },
100-
},
10130
])("/copy selects reply text ($name)", async (input) => {
10231
const session = {
10332
id: "ses_copy_reply",
@@ -109,7 +38,6 @@ test.each([
10938
cost: 0,
11039
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
11140
time: { created: 0, updated: 0 },
112-
revert: input.revert,
11341
}
11442
await using setup = await createAppFixture({
11543
args: { sessionID: session.id },
@@ -140,11 +68,8 @@ test.each([
14068
await setup.waitForFrame((frame) => frame.includes("Current prompt"))
14169
await setup.mockInput.typeText("/copy")
14270
setup.mockInput.pressEnter()
143-
await setup.waitForFrame(
144-
(frame) =>
145-
frame.includes("Message copied to clipboard!") ||
146-
frame.includes("No text content") ||
147-
frame.includes("No assistant messages"),
71+
await setup.waitForFrame((frame) =>
72+
frame.includes(input.text ? "Message copied to clipboard!" : "No reply text found in the last turn"),
14873
)
14974
if (input.text) {
15075
expect(copy).toHaveBeenCalledTimes(1)

0 commit comments

Comments
 (0)