diff --git a/src/locales/modules/chat.js b/src/locales/modules/chat.js index 264a827..581edae 100644 --- a/src/locales/modules/chat.js +++ b/src/locales/modules/chat.js @@ -106,6 +106,24 @@ export default { cmdHelp: _('帮助信息', 'Help', '幫助資訊'), cmdStatus: _('系统状态', 'System status', '系統狀態'), cmdContext: _('上下文信息', 'Context info', '上下文資訊'), + workspace: _('工作区', 'Workspace', '工作區'), + openWorkspace: _('打开工作区文件面板', 'Open workspace files panel', '打開工作區檔案面板'), + workspaceFiles: _('工作区文件', 'Workspace Files', '工作區檔案'), + coreFiles: _('核心文件', 'Core Files', '核心檔案'), + workspaceExplorer: _('工作区浏览', 'Workspace Explorer', '工作區瀏覽'), + selectWorkspaceFile: _('选择一个工作区文件开始查看或编辑', 'Select a workspace file to view or edit', '選擇一個工作區檔案開始檢視或編輯'), + reloadWorkspaceFile: _('重新加载', 'Reload file', '重新載入'), + previewWorkspaceFile: _('预览', 'Preview', '預覽'), + editWorkspaceFile: _('编辑', 'Edit', '編輯'), + workspaceEmptyState: _('当前 Agent 工作区已就绪,可从左侧选择文件', 'Workspace ready. Pick a file from the left to start.', '目前 Agent 工作區已就緒,可從左側選擇檔案'), + workspaceLoadFailed: _('加载工作区失败', 'Failed to load workspace', '載入工作區失敗'), + workspaceOpenFailed: _('打开文件失败', 'Failed to open file', '開啟檔案失敗'), + workspaceUnavailable: _('工作区暂不可用', 'Workspace is unavailable', '工作區暫時不可用'), + workspaceNoCoreFiles: _('暂无可展示的核心文件', 'No core files available', '暫無可展示的核心檔案'), + workspaceTreeEmpty: _('当前目录为空', 'This folder is empty', '目前資料夾為空'), + workspaceDraftHint: _('该文件尚不存在,保存后会在当前 Agent 工作区中创建', 'This file does not exist yet. Saving will create it in the current Agent workspace.', '此檔案尚不存在,儲存後會在目前 Agent 工作區中建立'), + confirmDiscardWorkspaceChanges: _('当前文件有未保存修改,确定继续吗?', 'You have unsaved changes in the current file. Continue?', '目前檔案有未儲存修改,確定繼續嗎?'), + workspaceFileCreated: _('工作区文件已创建', 'Workspace file created', '工作區檔案已建立'), hostedAgent: _('托管 Agent', 'Hosted Agent'), hostedBadge: _('托管', 'Hosted'), taskGoal: _('任务目标', 'Task Goal', '任務目標'), diff --git a/src/pages/chat.js b/src/pages/chat.js index 784b0ab..8f0b4e6 100644 --- a/src/pages/chat.js +++ b/src/pages/chat.js @@ -17,6 +17,7 @@ const STORAGE_SESSION_KEY = 'clawpanel-last-session' const STORAGE_MODEL_KEY = 'clawpanel-chat-selected-model' const STORAGE_SIDEBAR_KEY = 'clawpanel-chat-sidebar-open' const STORAGE_SESSION_NAMES_KEY = 'clawpanel-chat-session-names' +const STORAGE_WORKSPACE_PANEL_KEY = 'clawpanel-chat-workspace-open' const COMMANDS = [ { title: 'chat.cmdSession', commands: [ @@ -106,6 +107,14 @@ let _hostedAbort = null let _hostedLastTargetTs = 0 let _hostedAutoStopTimer = null let _hostedStartTime = 0 +let _workspaceBtn = null, _workspacePanelEl = null, _workspaceAgentBadgeEl = null, _workspaceAgentTitleEl = null +let _workspacePathEl = null, _workspaceCoreListEl = null, _workspaceTreeEl = null, _workspaceCurrentFileEl = null +let _workspaceMetaEl = null, _workspaceEditorEl = null, _workspacePreviewEl = null, _workspaceEmptyEl = null +let _workspaceSaveBtn = null, _workspaceReloadBtn = null, _workspacePreviewBtn = null +let _workspaceInfo = null, _workspaceCoreFiles = [], _workspaceTreeCache = new Map(), _workspaceExpandedDirs = new Set() +let _workspaceCurrentAgentId = 'main', _workspaceCurrentFile = null, _workspacePreviewMode = false, _workspaceDirty = false +let _workspaceLoadedContent = '', _workspaceLoading = false +let _workspaceLoadSeq = 0, _workspaceOpenSeq = 0 export async function render() { const page = document.createElement('div') @@ -146,6 +155,11 @@ export async function render() { + @@ -154,6 +168,48 @@ export async function render() { +