๐คฏ LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
๐ fix(agent): handle missing working directories (#18071)
Arvin Xub168cd4044f0
diff --git a/apps/cli/src/commands/hetero.test.ts b/apps/cli/src/commands/hetero.test.tsindex c3c464b9e08..ba5064a8bef 100644--- a/apps/cli/src/commands/hetero.test.ts+++ b/apps/cli/src/commands/hetero.test.ts@@ -788,6 +788,38 @@ describe('hetero exec command', () => {expect(exitSpy).toHaveBeenCalledWith(1);});+ it('preserves a working-directory error when spawnAgent rejects before streaming', async () => {+ mockSpawnAgent.mockRejectedValue(+ Object.assign(new Error('Working directory does not exist: /deleted/worktree'), {+ code: 'HETERO_WORKING_DIRECTORY_NOT_FOUND',+ }),+ );++ await runCmd([+ 'hetero',+ 'exec',+ '--type',+ 'codex',+ '--prompt',+ 'hi',+ '--topic',+ 'topic-1',+ '--operation-id',+ 'op-server',+ '--render',+ 'none',+ ]);++ expect(mockHeteroFinishMutate.mock.calls[0][0]).toMatchObject({+ error: {+ body: { code: 'working_directory_not_found' },+ type: 'AgentRuntimeError',+ },+ result: 'error',+ });+ expect(exitSpy).toHaveBeenCalledWith(1);+ });+it('finishes server-ingest runs with error when the agent event stream fails', async () => {mockSpawnAgent.mockReturnValue(createFakeHandle({ eventsError: new Error('adapter choked on malformed JSONL') }),diff --git a/apps/cli/src/commands/hetero.ts b/apps/cli/src/commands/hetero.tsindex ebf6469f3af..36fa95243d5 100644--- a/apps/cli/src/commands/hetero.ts+++ b/apps/cli/src/commands/hetero.ts@@ -598,12 +598,16 @@ const exec = async (options: ExecOptions): Promise<void> => {} catch (err) {await dumpAttempt?.close();const message = err instanceof Error ? err.message : String(err);+ const errnoCode =+ typeof err === 'object' && err && 'code' in err && typeof err.code === 'string'+ ? err.code+ : undefined;log.error('Failed to start agent:', message);if (serverIngester && sink) {try {await serverIngester.drain();await sink.finish({- error: buildFinishError(message, 'AgentRuntimeError'),+ error: buildFinishError(message, 'AgentRuntimeError', errnoCode),result: 'error',});} catch {diff --git a/apps/desktop/src/main/controllers/HeterogeneousAgentImpl.ts b/apps/desktop/src/main/controllers/HeterogeneousAgentImpl.tsindex c29f4582a76..ee785b9f538 100644--- a/apps/desktop/src/main/controllers/HeterogeneousAgentImpl.ts+++ b/apps/desktop/src/main/controllers/HeterogeneousAgentImpl.ts@@ -404,6 +404,23 @@ export default class HeterogeneousAgentCtr {});}+ private resolveSessionWorkingDirectory(session: AgentSession): string {+ return session.cwd || electronApp.getPath('desktop');+ }++ private buildWorkingDirectoryMissingError(+ session: AgentSession,+ workingDirectory: string,+ ): HeterogeneousAgentSessionError {+ return {+ agentType: session.agentType,+ code: HeterogeneousAgentSessionErrorCode.WorkingDirectoryNotFound,+ command: this.resolveSessionCommand(session),+ message: `Working directory does not exist: ${workingDirectory}`,+ workingDirectory,+ };+ }+private buildCliAuthRequiredError(session: AgentSession,stderr: string,@@ -492,6 +509,11 @@ export default class HeterogeneousAgentCtr {private getSessionErrorPayload(error: unknown, session: AgentSession): SessionErrorPayload {if (typeof error === 'object' && error && 'code' in error && error.code === 'ENOENT') {+ const workingDirectory = this.resolveSessionWorkingDirectory(session);+ if (!existsSync(workingDirectory)) {+ return this.buildWorkingDirectoryMissingError(session, workingDirectory);+ }+const cliMissingError = this.buildCliMissingError(session);if (cliMissingError) return cliMissingError;}@@ -551,6 +573,11 @@ export default class HeterogeneousAgentCtr {private async getSpawnPreflightError(session: AgentSession,): Promise<HeterogeneousAgentSessionError | undefined> {+ const workingDirectory = this.resolveSessionWorkingDirectory(session);+ if (!existsSync(workingDirectory)) {+ return this.buildWorkingDirectoryMissingError(session, workingDirectory);+ }+const defaultCommand = getHeterogeneousAgentConfigOrThrow(session.agentType).defaultCommand;const command = this.resolveSessionCommand(session);diff --git a/apps/desktop/src/main/controllers/__tests__/HeterogeneousAgentCtr.test.ts b/apps/desktop/src/main/controllers/__tests__/HeterogeneousAgentCtr.test.tsindex 7dc64bbd403..f538de94b8f 100644--- a/apps/desktop/src/main/controllers/__tests__/HeterogeneousAgentCtr.test.ts+++ b/apps/desktop/src/main/controllers/__tests__/HeterogeneousAgentCtr.test.ts@@ -266,6 +266,7 @@ describe('HeterogeneousAgentCtr', () => {codexAppServerInterruptMock.mockReset();mockGetAllWindows.mockReset();platformMock.mockReturnValue('linux');+ vi.mocked(existsSync).mockReturnValue(true);delete process.env.LOBE_CLAUDE_CODE_SDK;delete process.env.LOBE_CODEX_APP_SERVER;});@@ -897,6 +898,53 @@ describe('HeterogeneousAgentCtr', () => {expect(spawnCalls).toHaveLength(0);});+ it('validates the default desktop directory when the session cwd is omitted', async () => {+ vi.mocked(existsSync).mockImplementation((candidate) => candidate === FAKE_DESKTOP_PATH);+ const detect = vi.fn().mockResolvedValue({ available: false });+ const ctr = new HeterogeneousAgentCtr({+ appStoragePath,+ storeManager: { get: vi.fn() },+ binaryManager: { detect },+ } as any);+ const { sessionId } = await ctr.startSession({+ agentType: 'codex',+ command: 'codex',+ });++ await expect(+ ctr.sendPrompt({ operationId: 'op-test', prompt: 'hello', sessionId }),+ ).rejects.toThrow('Codex CLI was not found');++ expect(existsSync).toHaveBeenCalledWith(FAKE_DESKTOP_PATH);+ expect(detect).toHaveBeenCalledWith('codex', true);+ });++ it('reports a missing working directory instead of claiming the Codex CLI is missing', async () => {+ const missingCwd = '/tmp/lobehub-deleted-worktree';+ vi.mocked(existsSync).mockImplementation((candidate) => candidate !== missingCwd);+ const detect = vi.fn().mockResolvedValue({+ available: true,+ path: '/Applications/ChatGPT.app/Contents/Resources/codex',+ });+ const ctr = new HeterogeneousAgentCtr({+ appStoragePath,+ storeManager: { get: vi.fn() },+ binaryManager: { detect },+ } as any);+ const { sessionId } = await ctr.startSession({+ agentType: 'codex',+ command: 'codex',+ cwd: missingCwd,+ });++ await expect(+ ctr.sendPrompt({ operationId: 'op-test', prompt: 'hello', sessionId }),+ ).rejects.toThrow(`Working directory does not exist: ${missingCwd}`);++ expect(detect).not.toHaveBeenCalled();+ expect(spawnCalls).toHaveLength(0);+ });+it('fails fast when Claude Code CLI is unavailable instead of attempting spawn', async () => {const detect = vi.fn().mockResolvedValue({ available: false });const ctr = new HeterogeneousAgentCtr({diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 03e15d2e136..597a47eab97 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -1763,6 +1763,10 @@"workflow.toolDisplayName.writeDocument": "Wrote a document","workflow.toolDisplayName.writeLocalFile": "Wrote a file","workflow.working": "Working...",+ "workingDirectoryGuide.actions.retry": "Retry",+ "workingDirectoryGuide.desc": "The working directory saved for this conversation no longer exists.",+ "workingDirectoryGuide.hint": "Choose an existing folder from the working directory selector, then retry this message.",+ "workingDirectoryGuide.title": "Working directory unavailable","workingPanel.agentDocuments": "Agent Documents","workingPanel.browser.actions.back": "Back","workingPanel.browser.actions.capture": "Add screenshot to chat input",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 236072966d3..c6e9b353839 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -1763,6 +1763,10 @@"workflow.toolDisplayName.writeDocument": "ๆฐๅไบๆๆกฃ","workflow.toolDisplayName.writeLocalFile": "ๅๅ ฅไบๆไปถ","workflow.working": "ๅค็ไธญ...",+ "workingDirectoryGuide.actions.retry": "้่ฏ",+ "workingDirectoryGuide.desc": "ๆญคไผ่ฏไฟๅญ็ๅทฅไฝ็ฎๅฝๅทฒไธๅญๅจใ",+ "workingDirectoryGuide.hint": "่ฏทไปๅทฅไฝ็ฎๅฝ้ๆฉๅจไธญ้ๆฉไธไธชไป็ถๅญๅจ็็ฎๅฝ๏ผ็ถๅ้่ฏ่ฟๆกๆถๆฏใ",+ "workingDirectoryGuide.title": "ๅทฅไฝ็ฎๅฝไธๅฏ็จ","workingPanel.agentDocuments": "ไปฃ็ๆๆกฃ","workingPanel.browser.actions.back": "ๅ้","workingPanel.browser.actions.capture": "ๆชๅพๅนถๆทปๅ ๅฐ่พๅ ฅๆก",diff --git a/packages/electron-client-ipc/src/types/heterogeneousAgent.ts b/packages/electron-client-ipc/src/types/heterogeneousAgent.tsindex d0cb0199f54..ae01e0f3242 100644--- a/packages/electron-client-ipc/src/types/heterogeneousAgent.ts+++ b/packages/electron-client-ipc/src/types/heterogeneousAgent.ts@@ -25,6 +25,7 @@ export const HeterogeneousAgentSessionErrorCode = {RateLimit: 'rate_limit',ResumeCwdMismatch: 'resume_cwd_mismatch',ResumeThreadNotFound: 'resume_thread_not_found',+ WorkingDirectoryNotFound: 'working_directory_not_found',} as const;export type HeterogeneousAgentSessionErrorCode =diff --git a/packages/heterogeneous-agents/package.json b/packages/heterogeneous-agents/package.jsonindex 2764d73887e..4d03726adc4 100644--- a/packages/heterogeneous-agents/package.json+++ b/packages/heterogeneous-agents/package.json@@ -27,7 +27,7 @@"@anthropic-ai/sdk": "^0.93.0","@lobechat/agent-gateway-client": "workspace:*","@lobechat/types": "workspace:*",- "@lobehub/icons": "^5.11.0",+ "@lobehub/icons": "^5.15.0","@modelcontextprotocol/sdk": "^1.29.0","diff": "^8.0.4","zod": "^4.4.3"diff --git a/packages/heterogeneous-agents/src/errors/specs.test.ts b/packages/heterogeneous-agents/src/errors/specs.test.tsindex 58134970bcd..86b8c0911ad 100644--- a/packages/heterogeneous-agents/src/errors/specs.test.ts+++ b/packages/heterogeneous-agents/src/errors/specs.test.ts@@ -31,7 +31,13 @@ describe('hetero error taxonomy', () => {});it('only emits guide codes the client can actually render', () => {- const renderable = new Set(['auth_required', 'cli_not_found', 'overloaded', 'rate_limit']);+ const renderable = new Set([+ 'auth_required',+ 'cli_not_found',+ 'overloaded',+ 'rate_limit',+ 'working_directory_not_found',+ ]);for (const spec of specs) {if (spec.guideCode) expect(renderable).toContain(spec.guideCode);}diff --git a/packages/heterogeneous-agents/src/errors/specs.ts b/packages/heterogeneous-agents/src/errors/specs.tsindex a2c64dfa77b..71f418f4250 100644--- a/packages/heterogeneous-agents/src/errors/specs.ts+++ b/packages/heterogeneous-agents/src/errors/specs.ts@@ -34,6 +34,7 @@ export type HeteroErrorKind =| 'resume_cwd_mismatch'// environment| 'cli_not_found'+ | 'working_directory_not_found'// provider| 'model_unavailable'| 'agent_failed';@@ -239,6 +240,18 @@ export const HETERO_ERROR_SPECS: Record<HeteroErrorKind, HeteroErrorSpec> = {retryable: false,severity: 'warning',},+ working_directory_not_found: {+ attribution: 'user',+ category: 'environment',+ countAsFailure: false,+ description:+ 'The configured working directory was removed or is otherwise no longer available before the CLI could start.',+ guideCode: 'working_directory_not_found',+ kind: 'working_directory_not_found',+ numericId: 8002,+ retryable: false,+ severity: 'warning',+ },// โโโ 9xxx Provider โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโmodel_unavailable: {diff --git a/packages/heterogeneous-agents/src/errors/taxonomy.ts b/packages/heterogeneous-agents/src/errors/taxonomy.tsindex 71c40a169ca..32aa8e06700 100644--- a/packages/heterogeneous-agents/src/errors/taxonomy.ts+++ b/packages/heterogeneous-agents/src/errors/taxonomy.ts@@ -60,7 +60,8 @@ export type HeteroErrorAttribution = 'user' | 'provider' | 'harness' | 'system';* (`src/features/Conversation/Error/heterogeneous.ts`) and* `STATUS_GUIDE_ERROR_CODES` (`../spawn/classifyProcessFailure.ts`).*/-export type HeteroGuideCode = 'auth_required' | 'cli_not_found' | 'overloaded' | 'rate_limit';+export type HeteroGuideCode =+ 'auth_required' | 'cli_not_found' | 'overloaded' | 'rate_limit' | 'working_directory_not_found';/*** Mapping of category โ leading digit of the `numericId`.diff --git a/packages/heterogeneous-agents/src/spawn/classifyProcessFailure.test.ts b/packages/heterogeneous-agents/src/spawn/classifyProcessFailure.test.tsindex 64d3a1e1601..6f0efce2d2a 100644--- a/packages/heterogeneous-agents/src/spawn/classifyProcessFailure.test.ts+++ b/packages/heterogeneous-agents/src/spawn/classifyProcessFailure.test.ts@@ -14,6 +14,13 @@ describe('isHeteroStatusGuideErrorData', () => {message: 'API Error: 529 Overloaded',}),).toBe(true);+ expect(+ isHeteroStatusGuideErrorData({+ agentType: 'codex',+ code: 'working_directory_not_found',+ message: 'Working directory does not exist: /tmp/gone',+ }),+ ).toBe(true);expect(isHeteroStatusGuideErrorData({agentType: 'codex',@@ -63,6 +70,20 @@ describe('isHeteroStatusGuideErrorData', () => {});describe('classifyHeteroProcessFailure', () => {+ it('classifies a preflight working-directory failure separately from a missing CLI', () => {+ const result = classifyHeteroProcessFailure({+ agentType: 'codex',+ detail: 'Working directory does not exist: /tmp/gone',+ errnoCode: 'HETERO_WORKING_DIRECTORY_NOT_FOUND',+ });++ expect(result).toMatchObject({+ agentType: 'codex',+ code: 'working_directory_not_found',+ message: 'Working directory does not exist: /tmp/gone',+ });+ });+it('classifies a raw spawn ErrnoException code as cli_not_found', () => {const result = classifyHeteroProcessFailure({agentType: 'claude-code',diff --git a/packages/heterogeneous-agents/src/spawn/classifyProcessFailure.ts b/packages/heterogeneous-agents/src/spawn/classifyProcessFailure.tsindex e4cabbdd685..48688b3b61e 100644--- a/packages/heterogeneous-agents/src/spawn/classifyProcessFailure.ts+++ b/packages/heterogeneous-agents/src/spawn/classifyProcessFailure.ts@@ -20,7 +20,8 @@ import type { HeterogeneousTerminalErrorData } from '../types';** This helper mirrors the desktop in-process classifier* (`HeterogeneousAgentCtr.getSessionErrorPayload`) for the two guide codes a- * process-level failure can produce: `cli_not_found` and `auth_required`.+ * process-level failure can produce: `cli_not_found`,+ * `working_directory_not_found`, and `auth_required`.* The returned shape is persisted verbatim as the `ChatMessageError.body`, so* it must carry `agentType` + `code` โ that pair is what* `isHeterogeneousAgentStatusGuideError` gates the dedicated UI on.@@ -30,12 +31,12 @@ import type { HeterogeneousTerminalErrorData } from '../types';* Node reports a missing executable as an `ErrnoException` with* `code: 'ENOENT'` and message `spawn <command> ENOENT`. When only stderr text* is available (the raw error object was already flattened into the stderr- * tail), match the message shape instead. Note ENOENT is also raised for a- * missing `cwd` โ same behavior as the desktop classifier; both mean "this- * machine can't start the CLI as configured".+ * tail), match the message shape instead. A missing `cwd` also produces+ * ENOENT, so spawn sites validate it first and surface a distinct code.*/const SPAWN_ENOENT_PATTERN = /\bspawn .+ ENOENT\b/;+export const HETERO_WORKING_DIRECTORY_NOT_FOUND = 'HETERO_WORKING_DIRECTORY_NOT_FOUND';/*** Codes/agent types the client renders the dedicated status-guide card for.* Must stay in sync with `HETEROGENEOUS_AGENT_STATUS_GUIDE_ERROR_CODES` in@@ -47,6 +48,7 @@ const STATUS_GUIDE_ERROR_CODES = new Set(['cli_not_found','overloaded','rate_limit',+ 'working_directory_not_found',]);const STATUS_GUIDE_AGENT_TYPES = new Set(HETEROGENEOUS_AGENT_CONFIGS.map(({ type }) => type as string),@@ -100,6 +102,15 @@ export const classifyHeteroProcessFailure = (// Unknown agent type โ the client guide can't render it; don't classify.if (!isLocalHeterogeneousType(agentType)) return;+ if (errnoCode === HETERO_WORKING_DIRECTORY_NOT_FOUND) {+ return {+ agentType,+ code: 'working_directory_not_found',+ message: detail || 'The configured working directory no longer exists.',+ ...(detail ? { stderr: detail } : {}),+ };+ }+if (errnoCode === 'ENOENT' || (detail && SPAWN_ENOENT_PATTERN.test(detail))) {return buildHeterogeneousAgentCliNotFoundError({agentType,diff --git a/packages/heterogeneous-agents/src/spawn/index.ts b/packages/heterogeneous-agents/src/spawn/index.tsindex 625cb1100f3..58b708f0818 100644--- a/packages/heterogeneous-agents/src/spawn/index.ts+++ b/packages/heterogeneous-agents/src/spawn/index.ts@@ -21,6 +21,7 @@ export {export {classifyHeteroProcessFailure,type ClassifyHeteroProcessFailureParams,+ HETERO_WORKING_DIRECTORY_NOT_FOUND,isHeteroStatusGuideErrorData,} from './classifyProcessFailure';export {diff --git a/packages/heterogeneous-agents/src/spawn/spawnAgent.test.ts b/packages/heterogeneous-agents/src/spawn/spawnAgent.test.tsindex 1aefd2ea8a7..af7f49c6b1c 100644--- a/packages/heterogeneous-agents/src/spawn/spawnAgent.test.ts+++ b/packages/heterogeneous-agents/src/spawn/spawnAgent.test.ts@@ -153,6 +153,24 @@ describe('spawnAgent', () => {for (const event of events) expect(event.operationId).toBe('op-1');});+ it('fails before spawn when the configured working directory no longer exists', async () => {+ const missingCwd = path.join(os.tmpdir(), `lobehub-missing-cwd-${Date.now()}`);+ const { spawnAgent } = await import('./spawnAgent');++ await expect(+ spawnAgent({+ agentType: 'codex',+ cwd: missingCwd,+ operationId: 'op-missing-cwd',+ prompt: 'hello',+ }),+ ).rejects.toMatchObject({+ code: 'HETERO_WORKING_DIRECTORY_NOT_FOUND',+ workingDirectory: missingCwd,+ });+ expect(spawnCalls).toHaveLength(0);+ });+it('passes --include-partial-messages only when includePartialMessages=true', async () => {nextFakeProc = createFakeProc().proc;const { spawnAgent } = await import('./spawnAgent');diff --git a/packages/heterogeneous-agents/src/spawn/spawnAgent.ts b/packages/heterogeneous-agents/src/spawn/spawnAgent.tsindex 54bcedf47ad..ba95b096cad 100644--- a/packages/heterogeneous-agents/src/spawn/spawnAgent.ts+++ b/packages/heterogeneous-agents/src/spawn/spawnAgent.ts@@ -1,10 +1,12 @@import type { ChildProcess } from 'node:child_process';import { spawn } from 'node:child_process';+import { existsSync } from 'node:fs';import type { AgentStreamEvent } from '@lobechat/agent-gateway-client';import { resolveHeterogeneousAgentCommand } from '../config';import { AgentStreamPipeline, type UploadHeterogeneousImage } from './agentStreamPipeline';+import { HETERO_WORKING_DIRECTORY_NOT_FOUND } from './classifyProcessFailure';import { resolveCliSpawnPlan } from './cliSpawn';import { readCodexSessionModel, resolveCodexInitialModel } from './codexModel';import type { AgentPromptInput, BuildAgentInputOptions } from './input';@@ -347,6 +349,12 @@ export const spawnAgent = async (options: SpawnAgentOptions): Promise<SpawnAgentresumeSessionId: options.resumeSessionId,});const cwd = options.cwd || process.cwd();+ if (!existsSync(cwd)) {+ throw Object.assign(new Error(`Working directory does not exist: ${cwd}`), {+ code: HETERO_WORKING_DIRECTORY_NOT_FOUND,+ workingDirectory: cwd,+ });+ }const childEnv = { ...process.env, ...options.env };const initialModel =options.agentType === 'codex'diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex dbe8820df94..ca7280a483d 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -798,6 +798,12 @@ export default {'codexInstallGuide.menuNotification.title': 'Codex CLI not found','codexInstallGuide.reason': 'LobeHub could not start Codex: {{message}}','codexInstallGuide.title': 'Install Codex CLI',+ 'workingDirectoryGuide.actions.retry': 'Retry',+ 'workingDirectoryGuide.desc':+ 'The working directory saved for this conversation no longer exists.',+ 'workingDirectoryGuide.hint':+ 'Choose an existing folder from the working directory selector, then retry this message.',+ 'workingDirectoryGuide.title': 'Working directory unavailable','opencodeInstallGuide.actions.openDocs': 'Open Install Guide','opencodeInstallGuide.actions.openSystemTools': 'Open System Tools','opencodeInstallGuide.afterInstall':diff --git a/src/features/Conversation/Error/heterogeneous.ts b/src/features/Conversation/Error/heterogeneous.tsindex 324d0d3c788..d63c118cd04 100644--- a/src/features/Conversation/Error/heterogeneous.ts+++ b/src/features/Conversation/Error/heterogeneous.ts@@ -16,6 +16,7 @@ export const HETEROGENEOUS_AGENT_STATUS_GUIDE_ERROR_CODES = new Set<string>([HeterogeneousAgentSessionErrorCode.CliNotFound,HeterogeneousAgentSessionErrorCode.Overloaded,HeterogeneousAgentSessionErrorCode.RateLimit,+ HeterogeneousAgentSessionErrorCode.WorkingDirectoryNotFound,]);export const isHeterogeneousAgentStatusGuideError = (diff --git a/src/features/Conversation/Error/index.test.tsx b/src/features/Conversation/Error/index.test.tsxindex 0a11a5f18af..be6f0fde89b 100644--- a/src/features/Conversation/Error/index.test.tsx+++ b/src/features/Conversation/Error/index.test.tsx@@ -453,6 +453,28 @@ describe('ErrorMessageExtra', () => {expect(screen.getByText('guide:claude-code:rate_limit')).toBeInTheDocument();});+ it('renders the working-directory guide instead of the CLI install guide', () => {+ render(+ <ErrorMessageExtra+ error={{ message: 'response.undefined' }}+ data={{+ error: {+ body: {+ agentType: 'codex',+ code: HeterogeneousAgentSessionErrorCode.WorkingDirectoryNotFound,+ message: 'Working directory does not exist: /tmp/deleted-worktree',+ workingDirectory: '/tmp/deleted-worktree',+ },+ message: 'Working directory does not exist: /tmp/deleted-worktree',+ } as any,+ id: 'msg-working-directory',+ }}+ />,+ );++ expect(screen.getByText('guide:codex:working_directory_not_found')).toBeInTheDocument();+ });+it('dismisses only the current heterogeneous error field', () => {render(<ErrorMessageExtradiff --git a/src/features/Electron/HeterogeneousAgent/StatusGuide/index.tsx b/src/features/Electron/HeterogeneousAgent/StatusGuide/index.tsxindex 89a24b2d67f..d0683f1c300 100644--- a/src/features/Electron/HeterogeneousAgent/StatusGuide/index.tsx+++ b/src/features/Electron/HeterogeneousAgent/StatusGuide/index.tsx@@ -8,6 +8,7 @@ import AuthRequiredState from './states/AuthRequiredState';import CliInstallState from './states/CliInstallState';import OverloadedState from './states/OverloadedState';import RateLimitState from './states/RateLimitState';+import WorkingDirectoryState from './states/WorkingDirectoryState';import type { HeterogeneousAgentStatusGuideProps } from './types';const HeterogeneousAgentStatusGuide = memo<HeterogeneousAgentStatusGuideProps>(@@ -49,6 +50,10 @@ const HeterogeneousAgentStatusGuide = memo<HeterogeneousAgentStatusGuideProps>(return <OverloadedState {...stateProps} />;}+ case HeterogeneousAgentSessionErrorCode.WorkingDirectoryNotFound: {+ return <WorkingDirectoryState {...stateProps} />;+ }+default: {return <CliInstallState {...stateProps} />;}diff --git a/src/features/Electron/HeterogeneousAgent/StatusGuide/states/WorkingDirectoryState.tsx b/src/features/Electron/HeterogeneousAgent/StatusGuide/states/WorkingDirectoryState.tsxnew file mode 100644index 00000000000..fb8b1760be4--- /dev/null+++ b/src/features/Electron/HeterogeneousAgent/StatusGuide/states/WorkingDirectoryState.tsx@@ -0,0 +1,34 @@+import { Text } from '@lobehub/ui';+import { FolderX } from 'lucide-react';+import { useTranslation } from 'react-i18next';++import GuideActions from '../GuideActions';+import GuideShell from '../GuideShell';+import type { HeterogeneousAgentGuideStateProps } from '../types';++const WorkingDirectoryState = ({ error, onRetry, variant }: HeterogeneousAgentGuideStateProps) => {+ const { t } = useTranslation('chat');++ return (+ <GuideShell+ headerDescription={<Text type="secondary">{t('workingDirectoryGuide.desc')}</Text>}+ icon={<FolderX size={24} />}+ title={t('workingDirectoryGuide.title')}+ variant={variant}+ actions={+ <GuideActions+ retryPrimary+ retryLabel={t('workingDirectoryGuide.actions.retry')}+ onRetry={onRetry}+ />+ }+ >+ {error?.workingDirectory && <Text code>{error.workingDirectory}</Text>}+ <Text style={{ fontSize: 12 }} type="secondary">+ {t('workingDirectoryGuide.hint')}+ </Text>+ </GuideShell>+ );+};++export default WorkingDirectoryState;