Skip to content

Commit b732081

Browse files
committed
hack around a bug in claude code 0.2.70
1 parent 58b193c commit b732081

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/httpapi/claude.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ func formatPaste(message string) []st.MessagePart {
1717

1818
func formatClaudeCodeMessage(message string) []st.MessagePart {
1919
parts := make([]st.MessagePart, 0)
20+
// janky hack: send a random character and then a backspace because otherwise
21+
// Claude Code echoes the startSeq back to the terminal.
22+
// This basically simulates a user typing and then removing the character.
23+
parts = append(parts, st.MessagePartText{Content: "x\b", Hidden: true})
2024
parts = append(parts, formatPaste(message)...)
2125

2226
return parts

lib/screentracker/conversation.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,26 @@ func (c *Conversation) updateLastAgentMessage(screen string, timestamp time.Time
201201
c.messages[len(c.messages)-1].Id = len(c.messages) - 1
202202
}
203203

204+
// This is a temporary hack to work around a bug in Claude Code 0.2.70.
205+
// https://github.com/anthropics/claude-code/issues/803
206+
// 0.2.71 should not need it anymore. We will remove it a couple of days
207+
// after the new version is released.
208+
func removeDuplicateClaude_0_2_70_Output(screen string) string {
209+
// this hack will only work if the terminal emulator is exactly 80 characters wide
210+
// this is hard-coded right now in the termexec package
211+
idx := strings.LastIndex(screen, "╭────────────────────────────────────────────╮ \n│ ✻ Welcome to Claude Code research preview! │")
212+
if idx == -1 {
213+
return screen
214+
}
215+
return screen[idx:]
216+
}
217+
204218
func (c *Conversation) AddSnapshot(screen string) {
205219
c.lock.Lock()
206220
defer c.lock.Unlock()
207221

222+
screen = removeDuplicateClaude_0_2_70_Output(screen)
223+
208224
snapshot := screenSnapshot{
209225
timestamp: c.cfg.GetTime(),
210226
screen: screen,

0 commit comments

Comments
 (0)