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 23, 03:00 UTC
fix(web): up-arrow recall skips automation and agent messages (#21510)
Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>
maria committed
Oct 19, 2026 at 05:01 UTC
5569a42bff98f06b297115542b25c942f8607c16
2 files changed
+21
-4
apps/web/src/components/chat/composerPromptHistory.test.ts
+16
@@ -1,3 +1,4 @@
1
+import { ScheduledTaskId } from "@t3tools/contracts";
2
import { describe, expect, it } from "vite-plus/test";
3
4
import { ATTACHMENT_ONLY_BOOTSTRAP_PROMPT } from "@t3tools/shared/composerContextReferences";
@@ -117,6 +118,21 @@ describe("buildComposerPromptHistoryEntries", () => {
118
{ id: "m4", prompt: "same" },
119
]);
120
});
121
+
122
+ it("skips messages sent by automations, agents, and T3 Code", () => {
123
+ const typed = buildComposerPromptHistoryEntries([
124
+ { id: "m1", role: "user", text: "typed" },
125
+ { id: "m2", role: "user", text: "scheduled", scheduledTaskId: ScheduledTaskId.make("task") },
126
+ {
127
+ id: "scheduled-task-message:task:1:scheduled",
128
+ role: "user",
129
+ text: "[Triggered by schedule task: Daily]\n\nlegacy scheduled",
130
+ },
131
+ { id: "m3", role: "user", text: "from agent", createdBy: "agent", creationSource: "mcp" },
132
+ { id: "m4", role: "user", text: "from server", createdBy: "agent", creationSource: "server" },
133
+ ]);
134
+ expect(typed).toEqual([{ id: "m1", prompt: "typed" }]);
135
+ });
136
});
137
138
describe("stepComposerPromptHistory", () => {
apps/web/src/components/chat/composerPromptHistory.ts
+5
-4
@@ -1,3 +1,4 @@
1
+import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-message";
2
import {
3
ATTACHMENT_ONLY_BOOTSTRAP_PROMPT,
4
collectComposerContextReferences,
@@ -9,11 +10,9 @@ const REVIEW_COMMENT_BLOCK_PATTERN = /<review_comment\b[^>]*>[\s\S]*?<\/review_c
10
const TRAILING_LEGACY_CONTEXT =
11
/\n*<(terminal_context|element_context|preview_annotation)>\n([\s\S]*?)\n<\/\1>\s*$/;
12
12
-export interface ComposerPromptHistoryMessage {
13
+export type ComposerPromptHistoryMessage = Parameters<typeof resolveUserMessagePresentation>[0] & {
14
readonly id: string;
14
- readonly role: string;
15
- readonly text: string;
16
-}
15
+};
16
17
export interface ComposerPromptHistoryEntry {
18
readonly id: string;
@@ -129,6 +128,8 @@ export function buildComposerPromptHistoryEntries(
128
const entries: ComposerPromptHistoryEntry[] = [];
129
for (const message of messages) {
130
if (message.role !== "user") continue;
131
+ // Automations and other agents send user-role messages; recall only what the user typed.
132
+ if (resolveUserMessagePresentation(message).attribution !== null) continue;
133
const prompt = recallableComposerPrompt(message.text);
134
if (prompt.length === 0) continue;
135
const previous = entries[entries.length - 1];