The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
/**
* Workspace resolver — shared lookup for Codex + Agent (Underlying
* unification, Sprint C 2026-05).
*
* Lookup order:
* 1. Per-chat workspace from `agentModeStore`
* 2. `settings.defaultWorkspace`
* 3. `null` — caller falls back to sandbox / per-thread cwd
*/
import type { AgentWorkspace } from '../../types/agent-workspace'
import { isMobile } from '../../lib/device-kind'
export interface ResolveInput {
perChat: AgentWorkspace | undefined
defaultWorkspace: AgentWorkspace | null
}
export function resolveWorkspace({ perChat, defaultWorkspace }: ResolveInput): AgentWorkspace | null {
// A phone has no folder to pick: the agent always works in the sandbox of
// this app, whatever an old store or a synced setting says.
if (isMobile()) return null
if (perChat) return perChat
if (defaultWorkspace) return defaultWorkspace
return null
}
/**
* Folder-path extraction with the same precedence as resolveWorkspace.
* Returns `null` when neither layer pinned a real path (sandbox or unset).
*/
export function resolveWorkspacePath({ perChat, defaultWorkspace }: ResolveInput): string | null {
const ws = resolveWorkspace({ perChat, defaultWorkspace })
if (!ws || ws.kind !== 'folder' || !ws.path) return null
return ws.path
}