Skip to content

Commit 9c49d90

Browse files
feat: re-advertise commands on every prompt to ensure autocomplete functionality
debug: add logging for ACP messages to stderr when CODEEP_ACP_DEBUG is enabled
1 parent 2e45536 commit 9c49d90

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/acp/server.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,19 @@ export function startAcpServer(): Promise<void> {
760760
return;
761761
}
762762

763+
// Re-advertise commands on every prompt — Zed sometimes drops the initial
764+
// `available_commands_update` from session/new because the thread_view
765+
// isn't registered yet on Zed's side (race against the session/new
766+
// response). Re-sending here guarantees `/` autocomplete works by the
767+
// time the user could plausibly type the next prompt.
768+
transport.notify('session/update', {
769+
sessionId: params.sessionId,
770+
update: {
771+
sessionUpdate: 'available_commands_update',
772+
availableCommands: AVAILABLE_COMMANDS,
773+
},
774+
});
775+
763776
// Extract text from ContentBlock[]
764777
let prompt = params.prompt
765778
.filter((b) => b.type === 'text')

src/acp/transport.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export class StdioTransport {
3434
const trimmed = line.trim();
3535
if (!trimmed) continue;
3636
try {
37+
if (process.env.CODEEP_ACP_DEBUG) {
38+
process.stderr.write(`[ACP←client] ${trimmed}\n`);
39+
}
3740
const msg = JSON.parse(trimmed) as JsonRpcRequest | JsonRpcResponse | JsonRpcNotification;
3841
// Check if this is a response to one of our outbound requests
3942
if ('result' in msg || 'error' in msg) {
@@ -53,7 +56,11 @@ export class StdioTransport {
5356
}
5457

5558
send(msg: JsonRpcResponse | JsonRpcNotification): void {
56-
process.stdout.write(JSON.stringify(msg) + '\n');
59+
const line = JSON.stringify(msg);
60+
if (process.env.CODEEP_ACP_DEBUG) {
61+
process.stderr.write(`[ACP→client] ${line}\n`);
62+
}
63+
process.stdout.write(line + '\n');
5764
}
5865

5966
respond(id: number | string, result: unknown): void {

0 commit comments

Comments
 (0)