Skip to content

Commit 50d9a3f

Browse files
authored
fix: animation issue for amp (#67)
1 parent d3710ae commit 50d9a3f

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ agentapi server -- goose
6565
```
6666

6767
> [!NOTE]
68-
> When using Codex, Gemini or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break.
68+
> When using Codex, Gemini, Amp or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break.
6969
7070
An OpenAPI schema is available in [openapi.json](openapi.json).
7171

chat/src/components/message-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default function MessageList({ messages }: MessageListProps) {
127127
{message.role !== "user" && message.content === "" ? (
128128
<LoadingDots />
129129
) : (
130-
message.content.trim()
130+
message.content.trimEnd()
131131
)}
132132
</div>
133133
</div>

cmd/server/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func runServer(ctx context.Context, logger *slog.Logger, argsToPass []string) er
9494
ProgramArgs: argsToPass[1:],
9595
TerminalWidth: termWidth,
9696
TerminalHeight: termHeight,
97+
AgentType: agentType,
9798
})
9899
if err != nil {
99100
return xerrors.Errorf("failed to setup process: %w", err)

lib/httpapi/setup.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/coder/agentapi/lib/logctx"
13+
mf "github.com/coder/agentapi/lib/msgfmt"
1314
"github.com/coder/agentapi/lib/termexec"
1415
)
1516

@@ -18,6 +19,7 @@ type SetupProcessConfig struct {
1819
ProgramArgs []string
1920
TerminalWidth uint16
2021
TerminalHeight uint16
22+
AgentType mf.AgentType
2123
}
2224

2325
func SetupProcess(ctx context.Context, config SetupProcessConfig) (*termexec.Process, error) {
@@ -36,6 +38,14 @@ func SetupProcess(ctx context.Context, config SetupProcessConfig) (*termexec.Pro
3638
os.Exit(1)
3739
}
3840

41+
// Hack for sourcegraph amp to stop the animation.
42+
if config.AgentType == mf.AgentTypeAmp {
43+
_, err = process.Write([]byte(" \b"))
44+
if err != nil {
45+
return nil, err
46+
}
47+
}
48+
3949
// Handle SIGINT (Ctrl+C) and send it to the process
4050
signalCh := make(chan os.Signal, 1)
4151
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM)

0 commit comments

Comments
 (0)