chat: OpenCode /chat cwd = general_chat_sessions (match Claude), drop home special-case

Both harnesses now use the resolved chat cwd as their working directory: Claude runs
in it natively, and OpenCode is told the same via its system prompt. Removes the
earlier special-case that pointed OpenCode at the user's home for /chat, so `workingDir`
collapses into `cwd` — which now both tags the session (metadata.officer.cwd) and drives
the Officer system prompt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-25 12:00:34 +00:00
co-authored by Claude Opus 4.8
parent 0c3f270419
commit 88b74b2888
2 changed files with 3 additions and 9 deletions
+1 -6
View File
@@ -4,7 +4,7 @@ import type { ClientMessage, ServerMessage, Message, ChatEvent } from './types';
import { sessionManager } from './session-manager';
import { sendClaudeCodeStreaming } from '@@/channels/send-claude-code';
import { sendOpenCodeStreaming } from '@@/channels/send-opencode';
import { ensureGeneralChatSessionsCwd, getGeneralChatSessionsCwd } from './claude-sessions';
import { ensureGeneralChatSessionsCwd } from './claude-sessions';
import * as sidecar from '@@/sidecar-registry';
import { join } from 'path';
import { getHomeDirForRole, getEmailAccountsDir } from '../../../servers/data-path';
@@ -459,10 +459,6 @@ async function handleOpenCodeChat(
const onEvent = createEventHandler(sessionId, model, cwd);
// The dir the OpenCode model should treat as its cwd (via the Officer system prompt). For the general
// /chat, the resolved cwd is just the general_chat_sessions grouping placeholder, so use the user's home.
const workingDir = cwd === getGeneralChatSessionsCwd(email) ? getHomeDirForRole(email, ws.data.role) : cwd;
try {
const handle = await sendOpenCodeStreaming({
userId,
@@ -471,7 +467,6 @@ async function handleOpenCodeChat(
prompt: effectivePrompt,
sessionKey: sessionId,
cwd,
workingDir,
model,
role: ws.data.role,
resumeSessionId: msg.resumeSessionId,
+2 -3
View File
@@ -14,8 +14,7 @@ type OpenCodeStreamingParams = {
username: string;
prompt: string;
sessionKey: string;
cwd?: string; // logical cwd for session tagging/listing (metadata.officer.cwd)
workingDir?: string; // the dir the model should treat as its cwd (Officer system prompt)
cwd?: string; // the session's working dir: tags it (metadata.officer.cwd) + told to the model (system prompt)
model?: string;
role?: string;
resumeSessionId?: string;
@@ -73,7 +72,7 @@ export async function sendOpenCodeStreaming(params: OpenCodeStreamingParams): Pr
unsub = conn.subscribe(sessionId, mapper);
const { providerID, modelID } = splitModel(params.model ?? '');
const system = params.workingDir ? officerSystemPrompt(params.workingDir) : undefined;
const system = params.cwd ? officerSystemPrompt(params.cwd) : undefined;
// Fire the turn; assistant tokens + tool calls stream back over the SSE subscription above.
conn.postMessage(sessionId, providerID, modelID, params.prompt, system).catch((err) => {