From c488a552ad91a4ee65eea4ef9a555a7423f3ed0d Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Sun, 24 Aug 2025 15:53:06 +0530 Subject: [PATCH 1/2] feat: fix animation issue for sourcegraph -amp --- chat/src/components/message-list.tsx | 2 +- lib/httpapi/setup.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/chat/src/components/message-list.tsx b/chat/src/components/message-list.tsx index 75c6ade..d675a85 100644 --- a/chat/src/components/message-list.tsx +++ b/chat/src/components/message-list.tsx @@ -127,7 +127,7 @@ export default function MessageList({ messages }: MessageListProps) { {message.role !== "user" && message.content === "" ? ( ) : ( - message.content.trim() + message.content.trimEnd() )} diff --git a/lib/httpapi/setup.go b/lib/httpapi/setup.go index 8328991..5744e8c 100644 --- a/lib/httpapi/setup.go +++ b/lib/httpapi/setup.go @@ -36,6 +36,12 @@ func SetupProcess(ctx context.Context, config SetupProcessConfig) (*termexec.Pro os.Exit(1) } + // Hack for sourcegraph amp to stop the animation. + _, err = process.Write([]byte(" \b")) + if err != nil { + return nil, err + } + // Handle SIGINT (Ctrl+C) and send it to the process signalCh := make(chan os.Signal, 1) signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM) From 7fb47baf8a0ec50aa89e33e2981865c3b64dc457 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Mon, 25 Aug 2025 18:18:54 +0530 Subject: [PATCH 2/2] feat: amp only hack --- README.md | 2 +- cmd/server/server.go | 1 + lib/httpapi/setup.go | 10 +++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3f45478..6bfb02a 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ agentapi server -- goose ``` > [!NOTE] -> When using Codex, Gemini or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break. +> When using Codex, Gemini, Amp or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break. An OpenAPI schema is available in [openapi.json](openapi.json). diff --git a/cmd/server/server.go b/cmd/server/server.go index acdbc54..33c294e 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -94,6 +94,7 @@ func runServer(ctx context.Context, logger *slog.Logger, argsToPass []string) er ProgramArgs: argsToPass[1:], TerminalWidth: termWidth, TerminalHeight: termHeight, + AgentType: agentType, }) if err != nil { return xerrors.Errorf("failed to setup process: %w", err) diff --git a/lib/httpapi/setup.go b/lib/httpapi/setup.go index 5744e8c..1620304 100644 --- a/lib/httpapi/setup.go +++ b/lib/httpapi/setup.go @@ -10,6 +10,7 @@ import ( "time" "github.com/coder/agentapi/lib/logctx" + mf "github.com/coder/agentapi/lib/msgfmt" "github.com/coder/agentapi/lib/termexec" ) @@ -18,6 +19,7 @@ type SetupProcessConfig struct { ProgramArgs []string TerminalWidth uint16 TerminalHeight uint16 + AgentType mf.AgentType } func SetupProcess(ctx context.Context, config SetupProcessConfig) (*termexec.Process, error) { @@ -37,9 +39,11 @@ func SetupProcess(ctx context.Context, config SetupProcessConfig) (*termexec.Pro } // Hack for sourcegraph amp to stop the animation. - _, err = process.Write([]byte(" \b")) - if err != nil { - return nil, err + if config.AgentType == mf.AgentTypeAmp { + _, err = process.Write([]byte(" \b")) + if err != nil { + return nil, err + } } // Handle SIGINT (Ctrl+C) and send it to the process