Skip to content

Commit ba9f6db

Browse files
committed
chore: add note and remove amp animation parsing logic
1 parent 8fc86c6 commit ba9f6db

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ agentapi server -- goose
7575
> [!NOTE]
7676
> When using Codex, Opencode, Copilot, Gemini, Amp or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break.
7777
78+
79+
> [!NOTE]
80+
> When using Amp, set `"amp.terminal.animation": false` in `~/.config/amp/settings.json` to disable terminal animations, which can interfere with AgentAPI's message parsing.
81+
7882
An OpenAPI schema is available in [openapi.json](openapi.json).
7983

8084
By default, the server runs on port 3284. Additionally, the server exposes the same OpenAPI schema at http://localhost:3284/openapi.json and the available endpoints in a documentation UI at http://localhost:3284/docs.

lib/termexec/utils.go

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,6 @@ import (
66
"github.com/coder/agentapi/lib/msgfmt"
77
)
88

9-
func calcAmpAnimatedContent(lines []string) (int, bool) {
10-
animatedContentEnd := -1
11-
firstTextEncountered := false
12-
continueRemoving := true
13-
14-
// search for the first 3 consecutive empty lines after the first text encountered.
15-
if len(lines) > 3 {
16-
for i := 0; i < len(lines)-3; i++ {
17-
if !firstTextEncountered && len(strings.Trim(lines[i], " \n")) != 0 {
18-
if strings.HasPrefix(strings.TrimSpace(lines[i]), "┃") {
19-
continueRemoving = false
20-
}
21-
firstTextEncountered = true
22-
}
23-
if firstTextEncountered && len(strings.Trim(lines[i], " \n")) == 0 && len(strings.Trim(lines[i+1], " \n")) == 0 &&
24-
len(strings.Trim(lines[i+2], " \n")) == 0 {
25-
animatedContentEnd = i
26-
break
27-
28-
}
29-
}
30-
}
31-
return animatedContentEnd, continueRemoving
32-
}
33-
349
func calcOpencodeAnimatedContent(lines []string) (int, bool) {
3510
// Skip header lines for Opencode agent type to avoid false positives
3611
// The header contains dynamic content (token count, context percentage, cost)
@@ -48,12 +23,11 @@ func removeAnimatedContent(screen string, agentType msgfmt.AgentType) (string, b
4823
lines := strings.Split(screen, "\n")
4924
animatedContentEnd := -1
5025
var continueRemoving bool
51-
if agentType == msgfmt.AgentTypeAmp {
52-
animatedContentEnd, continueRemoving = calcAmpAnimatedContent(lines)
53-
} else if agentType == msgfmt.AgentTypeOpencode {
26+
switch agentType {
27+
case msgfmt.AgentTypeOpencode:
5428
animatedContentEnd, continueRemoving = calcOpencodeAnimatedContent(lines)
55-
} else {
56-
continueRemoving = false
29+
default:
30+
return screen, false
5731
}
5832
return strings.Join(lines[animatedContentEnd+1:], "\n"), continueRemoving
5933
}

0 commit comments

Comments
 (0)