Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix: prevent duplicate turn emission by disabling fromStart in session watcher registration

0xken15603ec987ca50
diff --git a/cli/src/cli.ts b/cli/src/cli.ts
index 6667257bb..fdb50f55d 100644
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@ -766,10 +766,12 @@ async function runForeground(token: string): Promise<void> {
}
if (session.transcriptPath) {
neverFoldedHistory.delete(session.sessionId)
- await watcher.addSession(
- { ...session, transcriptPath: session.transcriptPath },
- { fromStart: replayFromStart },
- )
+ // Deliberately NOT `fromStart`, even when the caller asked for it: this branch has just folded the
+ // file into the normalizer above, so replaying it from byte 0 emits every line a second time.
+ // Measured: a claude turn opened, closed after 44ms and opened again, because the fold replayed the
+ // open turn and the watcher then re-read the same bytes. `fromStart` belongs to the re-attach path,
+ // which folds nothing.
+ await watcher.addSession({ ...session, transcriptPath: session.transcriptPath })
} else if (session.engine === 'cursor') {
await cursorDiscovery.add(session.sessionId)
} else {