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:
@@ -4,7 +4,7 @@ import type { ClientMessage, ServerMessage, Message, ChatEvent } from './types';
|
|||||||
import { sessionManager } from './session-manager';
|
import { sessionManager } from './session-manager';
|
||||||
import { sendClaudeCodeStreaming } from '@@/channels/send-claude-code';
|
import { sendClaudeCodeStreaming } from '@@/channels/send-claude-code';
|
||||||
import { sendOpenCodeStreaming } from '@@/channels/send-opencode';
|
import { sendOpenCodeStreaming } from '@@/channels/send-opencode';
|
||||||
import { ensureGeneralChatSessionsCwd, getGeneralChatSessionsCwd } from './claude-sessions';
|
import { ensureGeneralChatSessionsCwd } from './claude-sessions';
|
||||||
import * as sidecar from '@@/sidecar-registry';
|
import * as sidecar from '@@/sidecar-registry';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { getHomeDirForRole, getEmailAccountsDir } from '../../../servers/data-path';
|
import { getHomeDirForRole, getEmailAccountsDir } from '../../../servers/data-path';
|
||||||
@@ -459,10 +459,6 @@ async function handleOpenCodeChat(
|
|||||||
|
|
||||||
const onEvent = createEventHandler(sessionId, model, cwd);
|
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 {
|
try {
|
||||||
const handle = await sendOpenCodeStreaming({
|
const handle = await sendOpenCodeStreaming({
|
||||||
userId,
|
userId,
|
||||||
@@ -471,7 +467,6 @@ async function handleOpenCodeChat(
|
|||||||
prompt: effectivePrompt,
|
prompt: effectivePrompt,
|
||||||
sessionKey: sessionId,
|
sessionKey: sessionId,
|
||||||
cwd,
|
cwd,
|
||||||
workingDir,
|
|
||||||
model,
|
model,
|
||||||
role: ws.data.role,
|
role: ws.data.role,
|
||||||
resumeSessionId: msg.resumeSessionId,
|
resumeSessionId: msg.resumeSessionId,
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ type OpenCodeStreamingParams = {
|
|||||||
username: string;
|
username: string;
|
||||||
prompt: string;
|
prompt: string;
|
||||||
sessionKey: string;
|
sessionKey: string;
|
||||||
cwd?: string; // logical cwd for session tagging/listing (metadata.officer.cwd)
|
cwd?: string; // the session's working dir: tags it (metadata.officer.cwd) + told to the model (system prompt)
|
||||||
workingDir?: string; // the dir the model should treat as its cwd (Officer system prompt)
|
|
||||||
model?: string;
|
model?: string;
|
||||||
role?: string;
|
role?: string;
|
||||||
resumeSessionId?: string;
|
resumeSessionId?: string;
|
||||||
@@ -73,7 +72,7 @@ export async function sendOpenCodeStreaming(params: OpenCodeStreamingParams): Pr
|
|||||||
unsub = conn.subscribe(sessionId, mapper);
|
unsub = conn.subscribe(sessionId, mapper);
|
||||||
|
|
||||||
const { providerID, modelID } = splitModel(params.model ?? '');
|
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.
|
// Fire the turn; assistant tokens + tool calls stream back over the SSE subscription above.
|
||||||
conn.postMessage(sessionId, providerID, modelID, params.prompt, system).catch((err) => {
|
conn.postMessage(sessionId, providerID, modelID, params.prompt, system).catch((err) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user