Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ jobs:
--skip pty_render::tests::codex_initial_render_after_restart_is_bounded \
--skip pty_render::tests::many_pinned_sessions_resize_within_budget \
--skip pty_render::tests::pseudo_terminal_render_is_fast_per_frame \
--skip pty_render::tests::codex_resize_bound_is_reasonable
--skip pty_render::tests::codex_resize_bound_is_reasonable \
--skip pty_render::tests::smith_tool_expand_collapse_rebuilds_only_retained_suffix

- name: Render TUI casts to GIFs
if: always()
Expand Down
25 changes: 24 additions & 1 deletion crates/daemon/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4643,10 +4643,33 @@
if (entry.row && entry.row.isConnected) entry.row.remove();
}

// Whitespace-insensitive normalization for matching an echoed user message to
// its optimistic row. Harnesses re-emit the text we sent, but not byte-for-byte:
// codex stores+replays it through its rollout, smith/claude re-emit it, and any
// of them can add a trailing newline, CRLF, or reflow line wrapping. An exact
// `===` then misses, so the optimistic row AND the echo both show (the dup).
function normalizeChatText(s) {
return String(s || "").replace(/\s+/g, " ").trim();
}

function consumeOptimisticMessage(sessionId, role, text) {
if (state.renderingTranscriptHistory || role !== "user" || !sessionId) return false;
const list = state.optimisticMessagesById.get(sessionId) || [];
const idx = list.findIndex((entry) => entry.role === role && entry.text === text);
if (!list.length) return false;
const n = normalizeChatText(text);
// Match exact → whitespace-normalized → one normalized text wrapping the other
// (a harness may prepend/append a little). Pick the oldest match so rapid
// sends pair up in send order. Dissimilar messages (e.g. injected
// `OBSERVATION:` user events) don't match, so they still render.
let idx = list.findIndex((e) => e.role === role && e.text === text);
if (idx < 0) idx = list.findIndex((e) => e.role === role && normalizeChatText(e.text) === n);
if (idx < 0 && n) {
idx = list.findIndex((e) => {
if (e.role !== role) return false;
const en = normalizeChatText(e.text);
return en && (en.startsWith(n) || n.startsWith(en));
});
}
if (idx < 0) return false;
const [entry] = list.splice(idx, 1);
if (list.length) state.optimisticMessagesById.set(sessionId, list);
Expand Down
Loading