|
| 1 | +export function createDashboardComputed() { |
| 2 | +import { getProviderDisplayUrl } from './provider-url-display.mjs'; |
| 3 | + return { |
| 4 | + agentsDiffHasChanges() { |
| 5 | + if (this.agentsDiffTruncated) { |
| 6 | + return !!this.agentsDiffHasChangesValue; |
| 7 | + } |
| 8 | + const stats = this.agentsDiffStats || {}; |
| 9 | + const added = Number(stats.added || 0); |
| 10 | + const removed = Number(stats.removed || 0); |
| 11 | + return added > 0 || removed > 0; |
| 12 | + }, |
| 13 | + configTemplateDiffHasChanges() { |
| 14 | + const stats = this.configTemplateDiffStats || {}; |
| 15 | + const added = Number(stats.added || 0); |
| 16 | + const removed = Number(stats.removed || 0); |
| 17 | + if (this.configTemplateDiffHasChangesValue !== undefined && this.configTemplateDiffHasChangesValue !== null) { |
| 18 | + return !!this.configTemplateDiffHasChangesValue; |
| 19 | + } |
| 20 | + return added > 0 || removed > 0; |
| 21 | + }, |
| 22 | + claudeModelHasList() { |
| 23 | + return this.claudeModelOptions.length > 0; |
| 24 | + }, |
| 25 | + claudeModelOptions() { |
| 26 | + const list = Array.isArray(this.claudeModels) ? [...this.claudeModels] : []; |
| 27 | + const current = (this.currentClaudeModel || '').trim(); |
| 28 | + if (current && !list.includes(current)) { |
| 29 | + list.unshift(current); |
| 30 | + } |
| 31 | + return list; |
| 32 | + }, |
| 33 | + displayCurrentProvider() { |
| 34 | + const switching = String(this.providerSwitchDisplayTarget || '').trim(); |
| 35 | + if (switching) return switching; |
| 36 | + const current = String(this.currentProvider || '').trim(); |
| 37 | + return current; |
| 38 | + }, |
| 39 | + displayProvidersList() { |
| 40 | + |
| 41 | + displayProviderUrl() { |
| 42 | + return (provider) => getProviderDisplayUrl(provider, this.upstreamUrlCache || {}); |
| 43 | + }, |
| 44 | + const list = Array.isArray(this.providersList) ? this.providersList : []; |
| 45 | + return list; |
| 46 | + }, |
| 47 | + installTargetCards() { |
| 48 | + const targets = Array.isArray(this.installStatusTargets) && this.installStatusTargets.length |
| 49 | + ? this.installStatusTargets |
| 50 | + : [ |
| 51 | + { |
| 52 | + id: 'claude', |
| 53 | + name: 'Claude Code CLI', |
| 54 | + packageName: '@anthropic-ai/claude-code', |
| 55 | + installed: false, |
| 56 | + bin: 'claude', |
| 57 | + version: '', |
| 58 | + commandPath: '', |
| 59 | + error: '' |
| 60 | + }, |
| 61 | + { |
| 62 | + id: 'codebuddy', |
| 63 | + name: 'CodeBuddy Code', |
| 64 | + packageName: '@tencent-ai/codebuddy-code', |
| 65 | + installed: false, |
| 66 | + bin: 'codebuddy', |
| 67 | + version: '', |
| 68 | + commandPath: '', |
| 69 | + error: '' |
| 70 | + }, |
| 71 | + { |
| 72 | + id: 'gemini', |
| 73 | + name: 'Gemini CLI', |
| 74 | + packageName: '@google/gemini-cli', |
| 75 | + installed: false, |
| 76 | + bin: 'gemini', |
| 77 | + version: '', |
| 78 | + commandPath: '', |
| 79 | + error: '' |
| 80 | + }, |
| 81 | + { |
| 82 | + id: 'codex', |
| 83 | + name: 'Codex CLI', |
| 84 | + packageName: '@openai/codex', |
| 85 | + installed: false, |
| 86 | + bin: 'codex', |
| 87 | + version: '', |
| 88 | + commandPath: '', |
| 89 | + error: '' |
| 90 | + } |
| 91 | + ]; |
| 92 | + const action = this.normalizeInstallAction(this.installCommandAction); |
| 93 | + return targets.map((target) => { |
| 94 | + const id = target && typeof target.id === 'string' ? target.id : ''; |
| 95 | + const termuxCommand = id === 'codex' |
| 96 | + ? this.getInstallCommand(id, action, 'termux') |
| 97 | + : ''; |
| 98 | + return { |
| 99 | + ...target, |
| 100 | + command: this.getInstallCommand(id, action), |
| 101 | + termuxCommand |
| 102 | + }; |
| 103 | + }); |
| 104 | + }, |
| 105 | + installRegistryPreview() { |
| 106 | + return this.resolveInstallRegistryUrl(this.installRegistryPreset, this.installRegistryCustom); |
| 107 | + }, |
| 108 | + inspectorBusyStatus() { |
| 109 | + const tasks = []; |
| 110 | + if (this.loading) tasks.push(this.t('dashboard.busy.init')); |
| 111 | + if (this.sessionsLoading) tasks.push(this.t('dashboard.busy.sessions')); |
| 112 | + if (this.codexModelsLoading || this.claudeModelsLoading) tasks.push(this.t('dashboard.busy.models')); |
| 113 | + if (this.codexApplying || this.configTemplateApplying || this.openclawApplying) tasks.push(this.t('dashboard.busy.configApply')); |
| 114 | + if (this.agentsSaving) tasks.push(this.t('dashboard.busy.agents')); |
| 115 | + if (this.skillsLoading || this.skillsDeleting || this.skillsScanningImports || this.skillsImporting || this.skillsZipImporting || this.skillsExporting) tasks.push(this.t('dashboard.busy.skills')); |
| 116 | + if (this.taskOrchestration && (this.taskOrchestration.loading || this.taskOrchestration.planning || this.taskOrchestration.running || this.taskOrchestration.queueAdding || this.taskOrchestration.queueStarting || this.taskOrchestration.retrying || this.taskOrchestration.selectedRunLoading)) { |
| 117 | + tasks.push(this.t('dashboard.busy.tasks')); |
| 118 | + } |
| 119 | + return tasks.length ? tasks.join(' / ') : this.t('dashboard.busy.idle'); |
| 120 | + }, |
| 121 | + inspectorMessageSummary() { |
| 122 | + const value = typeof this.message === 'string' ? this.message.trim() : ''; |
| 123 | + return value || this.t('dashboard.message.none'); |
| 124 | + }, |
| 125 | + inspectorSessionSourceLabel() { |
| 126 | + if (this.sessionFilterSource === 'codex') return this.t('dashboard.sessionSource.codex'); |
| 127 | + if (this.sessionFilterSource === 'claude') return this.t('dashboard.sessionSource.claude'); |
| 128 | + if (this.sessionFilterSource === 'gemini') return this.t('dashboard.sessionSource.gemini'); |
| 129 | + if (this.sessionFilterSource === 'codebuddy') return this.t('dashboard.sessionSource.codebuddy'); |
| 130 | + return this.t('dashboard.sessionSource.all'); |
| 131 | + }, |
| 132 | + inspectorSessionPathLabel() { |
| 133 | + const value = typeof this.sessionPathFilter === 'string' ? this.sessionPathFilter.trim() : ''; |
| 134 | + return value || this.t('dashboard.sessionPath.all'); |
| 135 | + }, |
| 136 | + inspectorSessionQueryLabel() { |
| 137 | + if (!this.isSessionQueryEnabled) return this.t('dashboard.sessionQuery.unsupported'); |
| 138 | + const value = typeof this.sessionQuery === 'string' ? this.sessionQuery.trim() : ''; |
| 139 | + return value || this.t('dashboard.sessionQuery.unset'); |
| 140 | + }, |
| 141 | + inspectorHealthStatus() { |
| 142 | + if (this.initError) return this.t('dashboard.healthStatus.failRead'); |
| 143 | + if (this.loading) return this.t('dashboard.healthStatus.initializing'); |
| 144 | + return this.t('dashboard.healthStatus.ok'); |
| 145 | + }, |
| 146 | + inspectorHealthTone() { |
| 147 | + if (this.initError) return 'error'; |
| 148 | + if (this.loading) return 'warn'; |
| 149 | + return 'ok'; |
| 150 | + }, |
| 151 | + inspectorModelLoadStatus() { |
| 152 | + if (this.codexModelsLoading || this.claudeModelsLoading) { |
| 153 | + return this.t('dashboard.modelStatus.loading'); |
| 154 | + } |
| 155 | + if (this.modelsSource === 'error' || this.claudeModelsSource === 'error') { |
| 156 | + return this.t('dashboard.modelStatus.error'); |
| 157 | + } |
| 158 | + return this.t('dashboard.modelStatus.ok'); |
| 159 | + }, |
| 160 | + installTroubleshootingTips() { |
| 161 | + const platform = this.resolveInstallPlatform(); |
| 162 | + if (platform === 'win32') { |
| 163 | + return [ |
| 164 | + this.t('docs.tip.win.1'), |
| 165 | + this.t('docs.tip.win.2'), |
| 166 | + this.t('docs.tip.win.3') |
| 167 | + ]; |
| 168 | + } |
| 169 | + return [ |
| 170 | + this.t('docs.tip.unix.1'), |
| 171 | + this.t('docs.tip.unix.2'), |
| 172 | + this.t('docs.tip.unix.3') |
| 173 | + ]; |
| 174 | + } |
| 175 | + }; |
| 176 | +} |
0 commit comments