chat: send cwd on every message instead of reading it back from session metadata

Simpler + more efficient than the previous per-turn GET /session: the client already
has the selected cwd, so it now sends it on every message (it's constant for a session).
The server uses msg.cwd directly for OpenCode's per-turn working-directory system prompt,
and still tags the cwd at creation for listing. Drops the getSession round-trip.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-25 12:26:41 +00:00
co-authored by Claude Opus 4.8
parent 2a940de76a
commit d8e0dc79ef
3 changed files with 30 additions and 28 deletions
-6
View File
@@ -146,12 +146,6 @@ class ServerConnection {
return (await res.json()) as OpenCodeSessionInfo[];
}
async getSession(sessionId: string): Promise<OpenCodeSessionInfo | null> {
const res = await fetch(`${this.baseUrl}/session/${sessionId}`);
if (!res.ok) return null;
return (await res.json()) as OpenCodeSessionInfo;
}
async getMessages(sessionId: string): Promise<OpenCodeStoredMessage[]> {
const res = await fetch(`${this.baseUrl}/session/${sessionId}/message`);
if (!res.ok) throw new Error(`opencode GET /session/${sessionId}/message → ${res.status}`);