@coda-console/claude 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/agent/session.mjs +12 -2
  2. package/package.json +1 -1
package/agent/session.mjs CHANGED
@@ -77,7 +77,12 @@ export class ClaudeSession {
77
77
  .onRequest('session/set_config_option', ({ params }) => this.configure(params.configId, params.value))
78
78
  .onRequest('session/set_mode', async ({ params }) => { await this.configure('mode', params.modeId); return {}; })
79
79
  .onRequest('session/prompt', ({ params }) => this.prompt(params))
80
- .onNotification('session/cancel', ({ params }) => { if (params.sessionId === this.sessionId) void this.query?.interrupt().catch(() => {}); })
80
+ .onNotification('session/cancel', ({ params }) => {
81
+ if (params.sessionId !== this.sessionId) return;
82
+ // While the session moves to another query there is none to interrupt: the turn waiting on the move is stopped there.
83
+ if (this.rerouting) this.cancelling = true;
84
+ void this.query?.interrupt().catch(() => {});
85
+ })
81
86
  .onRequest('_coda/wait/stop', params => params, ({ params }) => this.stopWait(params))
82
87
  .connect(stream);
83
88
  this.client = this.connection.client;
@@ -229,7 +234,12 @@ export class ClaudeSession {
229
234
  // Answered when the native result that names this input arrives; accepting it into the input says nothing yet.
230
235
  async prompt({ prompt }) {
231
236
  if (this.phase !== 'running') throw failure('Claude 会话未在运行', -32001);
232
- if (this.rerouted()) await (this.rerouting ??= this.reroute().finally(() => { this.rerouting = null; }));
237
+ if (this.rerouted()) {
238
+ if (!this.rerouting) { this.cancelling = false; this.rerouting = this.reroute().finally(() => { this.rerouting = null; }); }
239
+ await this.rerouting;
240
+ // Stopped while it moved: the input is not given to the new query.
241
+ if (this.cancelling) { this.cancelling = false; return { stopReason: 'cancelled' }; }
242
+ }
233
243
  const id = randomUUID(), content = prompt.filter(block => block.type === 'text').map(block => block.text).join('\n');
234
244
  const answered = new Promise((resolve, reject) => this.prompts.set(id, { resolve, reject }));
235
245
  this.input.push({ type: 'user', uuid: id, session_id: this.sessionId, parent_tool_use_id: null, message: { role: 'user', content } });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "id": "claude",
4
4
  "displayName": "Claude",
5
5
  "description": "Claude SDK Agent:Coda 基于 Claude Agent SDK 写的 ACP 入口,一个进程一个 SDK 会话;资源页的「Claude」面板显示会话报告的额度,可从 Coda 登录。",
6
- "version": "1.4.0",
6
+ "version": "1.4.1",
7
7
  "dependencies": {
8
8
  "@agentclientprotocol/sdk": "1.4.0",
9
9
  "@anthropic-ai/claude-agent-sdk": "0.3.296"