Skip to content

Commit 4fdbb08

Browse files
committed
msgfmt: more robust input box removal
1 parent f124f1c commit 4fdbb08

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

lib/msgfmt/claude.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,21 @@ func removeClaudeMessageBox(msg string) string {
2121
}
2222
}
2323

24-
if strings.HasPrefix(trimmedLastLine(), "? for shortcuts") {
25-
popLine()
26-
}
27-
msgBoxEdge := "───────────────"
28-
if strings.Contains(trimmedLastLine(), msgBoxEdge) {
29-
popLine()
24+
// The ">" symbol is often used to indicate the user input line.
25+
// We remove all lines including and after the last ">" symbol
26+
// in the message.
27+
greaterThanLineIdx := -1
28+
for i := len(lines) - 1; i >= max(len(lines)-6, 0); i-- {
29+
if strings.Contains(lines[i], ">") {
30+
greaterThanLineIdx = i
31+
break
32+
}
3033
}
31-
if strings.Contains(trimmedLastLine(), ">") {
32-
popLine()
34+
if greaterThanLineIdx >= 0 {
35+
lines = lines[:greaterThanLineIdx]
3336
}
37+
38+
msgBoxEdge := "───────────────"
3439
if strings.Contains(trimmedLastLine(), msgBoxEdge) {
3540
popLine()
3641
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
╭────────────────────────────────────────────╮
2+
│ ✻ Welcome to Claude Code research preview! │
3+
│ │
4+
│ /help for help │
5+
│ │
6+
│ cwd: /Users/hugodutka/dev/agentapi │
7+
╰────────────────────────────────────────────╯
8+
9+
Tips for getting started:
10+
11+
1. Run /init to create a CLAUDE.md file with instructions for Claude
12+
2. Run /terminal-setup to set up terminal integration
13+
3. Use Claude to help with file analysis, editing, bash commands and git
14+
4. Be as specific as you would with another engineer for the best results
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
╭────────────────────────────────────────────╮
2+
│ ✻ Welcome to Claude Code research preview! │
3+
│ │
4+
│ /help for help │
5+
│ │
6+
│ cwd: /Users/hugodutka/dev/agentapi │
7+
╰────────────────────────────────────────────╯
8+
9+
Tips for getting started:
10+
11+
1. Run /init to create a CLAUDE.md file with instructions for Claude
12+
2. Run /terminal-setup to set up terminal integration
13+
3. Use Claude to help with file analysis, editing, bash commands and git
14+
4. Be as specific as you would with another engineer for the best results
15+
16+
╭──────────────────────────────────────────────────────────────────────────────╮
17+
│ > │
18+
╰──────────────────────────────────────────────────────────────────────────────╯
19+
⏵⏵ auto-accept edits on (shift+tab to ✓ Update installed • Restart to
20+
toggle) apply

lib/msgfmt/testdata/format/claude/auto-accept-edits/user.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)