@shuind/dsh-codex-harness 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +21 -41
- package/docs/preset-library.md +2 -2
- package/docs/tool-policy.md +1 -1
- package/lib/client.js +1826 -545
- package/lib/compact-command.js +7 -1
- package/lib/compaction.js +7 -1
- package/lib/hybrid-executor.js +23 -12
- package/lib/index.js +1229 -17
- package/lib/preferences.js +21 -2
- package/lib/tool-policy.js +11 -2
- package/lib/typert.js +42 -1
- package/lib/types/client/desktop.d.ts +20 -42
- package/lib/types/client/desktop.js +184 -127
- package/lib/types/client/index.d.ts +104 -39
- package/lib/types/client/index.js +97 -15
- package/lib/types/client/policy-drafts.d.ts +18 -0
- package/lib/types/client/policy-drafts.js +27 -0
- package/lib/types/client/policy-locale.d.ts +81 -32
- package/lib/types/client/policy-locale.js +197 -107
- package/lib/types/client/preset-manager.d.ts +25 -2
- package/lib/types/client/preset-manager.js +89 -5
- package/lib/types/client/preset-requests.d.ts +44 -1
- package/lib/types/client/preset-requests.js +150 -0
- package/lib/types/client/tool-policy.d.ts +6 -15
- package/lib/types/client/tool-policy.js +24 -39
- package/lib/types/contracts/preset-editor-schema.d.ts +35 -0
- package/lib/types/contracts/preset-editor-schema.js +39 -0
- package/lib/types/contracts/settings.d.ts +12 -0
- package/lib/types/contracts/settings.js +10 -1
- package/lib/types/contracts/ui-contracts.d.ts +48 -0
- package/lib/types/contracts/ui-contracts.js +58 -0
- package/lib/types/contracts/update.d.ts +73 -0
- package/lib/types/contracts/update.js +291 -0
- package/lib/types/entries/index.js +20 -2
- package/lib/types/entries/preferences.d.ts +2 -0
- package/lib/types/entries/preferences.js +9 -0
- package/lib/types/hybrid/hybrid-sdk.d.ts +1 -1
- package/lib/types/hybrid/hybrid-sdk.js +27 -13
- package/lib/types/presets/preset-editor.d.ts +13 -1
- package/lib/types/presets/preset-editor.js +24 -1
- package/lib/types/presets/pro-mode-store.d.ts +13 -0
- package/lib/types/presets/pro-mode-store.js +69 -0
- package/lib/types/responses/background-sse-codec.d.ts +23 -0
- package/lib/types/responses/background-sse-codec.js +230 -0
- package/lib/types/responses/background-stream.d.ts +28 -0
- package/lib/types/responses/background-stream.js +351 -0
- package/lib/types/responses/fetch-transport.js +24 -9
- package/lib/types/responses/wire-rewrite.d.ts +4 -0
- package/lib/types/responses/wire-rewrite.js +30 -4
- package/lib/types/tools/codex-subagent.d.ts +14 -0
- package/lib/types/tools/codex-subagent.js +269 -0
- package/lib/types/update/checker.d.ts +14 -0
- package/lib/types/update/checker.js +166 -0
- package/locale/en.json +1 -1
- package/locale/hybrid-executor/en.json +1 -1
- package/locale/hybrid-executor/zh.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +6 -2
- package/src/client/desktop.tsx +359 -160
- package/src/client/index.tsx +122 -22
- package/src/client/policy-drafts.ts +45 -0
- package/src/client/policy-locale.ts +198 -106
- package/src/client/preset-manager.tsx +125 -4
- package/src/client/preset-requests.ts +185 -1
- package/src/client/tool-policy.tsx +29 -63
- package/src/contracts/preset-editor-schema.ts +44 -0
- package/src/contracts/settings.ts +20 -1
- package/src/contracts/ui-contracts.ts +87 -0
- package/src/contracts/update.ts +307 -0
- package/src/entries/index.ts +25 -2
- package/src/entries/preferences.ts +9 -0
- package/src/hybrid/hybrid-sdk.ts +28 -12
- package/src/presets/preset-editor.ts +31 -3
- package/src/presets/pro-mode-store.ts +80 -0
- package/src/responses/background-sse-codec.ts +237 -0
- package/src/responses/background-stream.ts +371 -0
- package/src/responses/fetch-transport.ts +28 -9
- package/src/responses/wire-rewrite.ts +34 -3
- package/src/tools/codex-subagent.ts +290 -0
- package/src/update/checker.ts +193 -0
- package/tsdown.config.ts +4 -0
package/src/client/desktop.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** A single Settings workspace; the bundle page is only a signpost. */
|
|
2
|
-
import { useState, useSyncExternalStore } from 'react'
|
|
2
|
+
import { useEffect, useRef, useState, useSyncExternalStore } from 'react'
|
|
3
3
|
import type { Context } from '@deepseek-ai/cordis'
|
|
4
4
|
import type { InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
|
|
5
5
|
import type {} from '@deepseek-ai/dsh-client-ui-plugin-manager/client'
|
|
@@ -7,161 +7,91 @@ import { applyWithSettingsApi } from './index.tsx'
|
|
|
7
7
|
import type {
|
|
8
8
|
CodexConnectScope,
|
|
9
9
|
CodexConnectSnapshot,
|
|
10
|
-
CodexScope,
|
|
11
10
|
CodexSettings,
|
|
12
11
|
CodexSettingsSnapshot,
|
|
13
12
|
InputSettingsControlInjected,
|
|
14
13
|
} from './index.tsx'
|
|
15
14
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
CODEX_SUBAGENT_DEFAULT_PRESET,
|
|
16
|
+
CODEX_SUBAGENT_PRESET_INHERIT,
|
|
17
|
+
CODEX_SUBAGENT_TOOL_NAME,
|
|
18
18
|
} from '../contracts/ui-contracts.ts'
|
|
19
|
+
import type { CodexSubagentModelCatalog } from '../contracts/ui-contracts.ts'
|
|
20
|
+
import { CODEX_CONNECT_PACKAGE_NAME, CODEX_CONNECT_REPO_URL, CODEX_HARNESS_RELEASES_URL, HarnessUpdateStore } from '../contracts/update.ts'
|
|
21
|
+
import type { HarnessUpdateSnapshot } from '../contracts/update.ts'
|
|
19
22
|
import type { PresetClientRemote } from './preset-manager.tsx'
|
|
20
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
adaptConfigForm,
|
|
25
|
+
bindCodexConnectScope,
|
|
26
|
+
bindLlmProvidersScope,
|
|
27
|
+
invalidatePresetTools,
|
|
28
|
+
requestCodexSubagentModels,
|
|
29
|
+
saveDesktopSettings,
|
|
30
|
+
} from './preset-requests.ts'
|
|
31
|
+
import type { DesktopConfigForm, DesktopSettingsContext } from './preset-requests.ts'
|
|
32
|
+
import type { LlmProvidersScope } from '../contracts/ui-contracts.ts'
|
|
33
|
+
import { bindToolPolicy, formatGptImageBadge, resolveGptCapabilities, ToolPolicySection } from './tool-policy.tsx'
|
|
21
34
|
import type { ToolPolicyBinding, ToolPolicyMode } from './tool-policy.tsx'
|
|
22
35
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
mutate(ops: Array<{ op: 'set'; path: string[]; value: unknown } | { op: 'unset'; path: string[] }>, expectedRevision?: number | string): Promise<boolean>
|
|
27
|
-
}
|
|
36
|
+
export { adaptConfigForm, bindCodexConnectScope, saveDesktopSettings }
|
|
37
|
+
export type { DesktopConfigForm }
|
|
38
|
+
|
|
28
39
|
interface DesktopSettingsActions extends InputSettingsControlInjected {
|
|
29
40
|
saveSettings(edits: Record<string, unknown>, expectedRevision?: number | string): Promise<void>
|
|
30
41
|
toolPolicy?: ToolPolicyBinding
|
|
31
|
-
|
|
32
|
-
interface MirrorNamespaceRow {
|
|
33
|
-
readonly ns: string
|
|
34
|
-
readonly value?: unknown
|
|
35
|
-
readonly base?: unknown
|
|
36
|
-
}
|
|
37
|
-
interface ConfigMirror {
|
|
38
|
-
getSnapshot(): { readonly status?: string; readonly view?: { readonly writable?: boolean; readonly namespaces?: readonly MirrorNamespaceRow[] } }
|
|
39
|
-
subscribe(listener: () => void): () => void
|
|
40
|
-
ensure?(): unknown
|
|
41
|
-
}
|
|
42
|
-
interface DesktopSettingsContext {
|
|
43
|
-
configForms: {
|
|
44
|
-
get(entryId: string): DesktopConfigForm
|
|
45
|
-
describe?(): ConfigMirror
|
|
46
|
-
whileServed(namespaces: string[], register: () => () => void): () => void
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function asRecord(value: unknown): Record<string, unknown> | undefined {
|
|
50
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
51
|
-
? value as Record<string, unknown>
|
|
52
|
-
: undefined
|
|
53
|
-
}
|
|
54
|
-
function asOverrides(value: unknown): Record<string, number | null> | undefined {
|
|
55
|
-
const record = asRecord(value)
|
|
56
|
-
if (record === undefined) return undefined
|
|
57
|
-
const out: Record<string, number | null> = {}
|
|
58
|
-
for (const [k, v] of Object.entries(record)) {
|
|
59
|
-
if (v === null || (typeof v === 'number' && Number.isSafeInteger(v) && v > 0)) out[k] = v
|
|
60
|
-
}
|
|
61
|
-
return out
|
|
62
|
-
}
|
|
63
|
-
function projectCodexConnectRecord(
|
|
64
|
-
record: Record<string, unknown>,
|
|
65
|
-
baseRecord: Record<string, unknown> | undefined,
|
|
66
|
-
writable: boolean,
|
|
67
|
-
): CodexConnectSnapshot {
|
|
68
|
-
const searchModel = typeof record.searchModel === 'string' && record.searchModel.trim() ? record.searchModel.trim() : undefined
|
|
69
|
-
const imageModelHint = typeof record.imageModelHint === 'string' ? record.imageModelHint.trim() : undefined
|
|
70
|
-
return {
|
|
71
|
-
status: 'ready',
|
|
72
|
-
writable,
|
|
73
|
-
overrides: asOverrides(record.contextWindowOverrides),
|
|
74
|
-
baseOverrides: asOverrides(baseRecord?.contextWindowOverrides),
|
|
75
|
-
...(typeof record.enableNativeCompaction === 'boolean' ? { nativeCompaction: record.enableNativeCompaction } : {}),
|
|
76
|
-
...(typeof record.enableSearch === 'boolean' ? { searchEnabled: record.enableSearch } : {}),
|
|
77
|
-
...(searchModel !== undefined ? { searchModel } : {}),
|
|
78
|
-
...(typeof record.enableImageGeneration === 'boolean' ? { imageGenerationEnabled: record.enableImageGeneration } : {}),
|
|
79
|
-
...(imageModelHint !== undefined ? { imageModelHint } : {}),
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function bindCodexConnectScope(configForms: DesktopSettingsContext['configForms']): CodexConnectScope {
|
|
84
|
-
const form = configForms.get(OPENAI_CODEX_SETTINGS_NAMESPACE)
|
|
85
|
-
const mirror = configForms.describe?.()
|
|
86
|
-
void Promise.resolve(mirror?.ensure?.()).catch(() => {})
|
|
87
|
-
let lastFormSnap: unknown
|
|
88
|
-
let lastMirrorSnap: unknown
|
|
89
|
-
let projected: CodexConnectSnapshot = { status: 'loading', writable: false }
|
|
90
|
-
const getSnapshot = (): CodexConnectSnapshot => {
|
|
91
|
-
const formSnap = form.getSnapshot() as CodexSettingsSnapshot & { readonly base?: Record<string, unknown> }
|
|
92
|
-
const mirrorSnap = mirror?.getSnapshot()
|
|
93
|
-
if (formSnap === lastFormSnap && mirrorSnap === lastMirrorSnap) return projected
|
|
94
|
-
lastFormSnap = formSnap
|
|
95
|
-
lastMirrorSnap = mirrorSnap
|
|
96
|
-
const formRecord = formSnap.status === 'ready' ? asRecord(formSnap.value) : undefined
|
|
97
|
-
if (formRecord !== undefined) {
|
|
98
|
-
return projected = projectCodexConnectRecord(formRecord, asRecord(formSnap.base), formSnap.writable)
|
|
99
|
-
}
|
|
100
|
-
const view = mirrorSnap?.view
|
|
101
|
-
if (view !== undefined) {
|
|
102
|
-
const row = view.namespaces?.find(candidate => candidate.ns === OPENAI_CODEX_SETTINGS_NAMESPACE)
|
|
103
|
-
const rowRecord = row === undefined ? undefined : asRecord(row.value)
|
|
104
|
-
if (row === undefined || rowRecord === undefined) return projected = { status: 'unavailable', writable: false }
|
|
105
|
-
return projected = projectCodexConnectRecord(rowRecord, asRecord(row.base), view.writable ?? formSnap.writable)
|
|
106
|
-
}
|
|
107
|
-
return projected = { status: formSnap.status, writable: formSnap.writable }
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
getSnapshot,
|
|
111
|
-
subscribe: listener => {
|
|
112
|
-
const stopForm = form.subscribe(listener)
|
|
113
|
-
const stopMirror = mirror?.subscribe(listener)
|
|
114
|
-
return () => { stopForm(); stopMirror?.() }
|
|
115
|
-
},
|
|
116
|
-
setModelOverride: async (modelId, tokens) => {
|
|
117
|
-
const snap = getSnapshot()
|
|
118
|
-
const next = nextOpenAICodexOverrides(snap.overrides, snap.baseOverrides, modelId, tokens)
|
|
119
|
-
const accepted = next === undefined
|
|
120
|
-
? await form.unset('contextWindowOverrides')
|
|
121
|
-
: await form.set('contextWindowOverrides', next)
|
|
122
|
-
if (!accepted) throw new Error('The host did not accept the settings change.')
|
|
123
|
-
},
|
|
124
|
-
setNativeCompaction: async enabled => {
|
|
125
|
-
const accepted = await form.set('enableNativeCompaction', enabled)
|
|
126
|
-
if (!accepted) throw new Error('The host did not accept the settings change.')
|
|
127
|
-
},
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
export function adaptConfigForm(form: Pick<DesktopConfigForm, 'getSnapshot' | 'subscribe' | 'set' | 'unset'>): CodexScope {
|
|
131
|
-
const accepted = async (result: Promise<boolean>) => { if (!await result) throw new Error('The host did not accept the settings change.') }
|
|
132
|
-
return { getSnapshot: () => form.getSnapshot(), subscribe: listener => form.subscribe(listener),
|
|
133
|
-
set: (field, value) => accepted(form.set(field, value)), unset: field => accepted(form.unset(field)) }
|
|
134
|
-
}
|
|
135
|
-
export async function saveDesktopSettings(form: Pick<DesktopConfigForm, 'mutate'>, edits: Record<string, unknown>, expectedRevision?: number | string): Promise<void> {
|
|
136
|
-
const ops = Object.entries(edits).map(([field, value]) => value === undefined ? { op: 'unset' as const, path: [field] } : { op: 'set' as const, path: [field], value })
|
|
137
|
-
if (!ops.length) return
|
|
138
|
-
const accepted = expectedRevision === undefined ? await form.mutate(ops) : await form.mutate(ops, expectedRevision)
|
|
139
|
-
if (!accepted) throw new Error('The host did not accept the settings change.')
|
|
42
|
+
updateStore?: HarnessUpdateStore
|
|
140
43
|
}
|
|
141
44
|
|
|
142
45
|
type DesktopSettingsProps = InjectFace<DesktopSettingsActions> & PropsLocale<'codex'>
|
|
143
|
-
type SettingsPage = 'tools' | 'runtime'
|
|
46
|
+
type SettingsPage = 'tools' | 'runtime' | 'help'
|
|
47
|
+
|
|
48
|
+
const DEFAULT_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'] as const
|
|
49
|
+
|
|
144
50
|
const desktopStyles = `
|
|
145
51
|
.codex-harness-settings { max-width:760px; min-width:0; font-size:13px; color:var(--dsw-alias-label-primary); }
|
|
146
52
|
.codex-harness-settings h3 { font-size:14px; margin:0 0 10px; }
|
|
147
53
|
.codex-harness-settings .codex-harness-nav { display:flex; align-items:flex-end; gap:20px; margin-bottom:14px; border-bottom:0.5px solid var(--dsw-alias-border-l2); }
|
|
148
54
|
.codex-harness-settings .codex-harness-nav button { position:relative; border:0; padding:7px 1px 9px; background:transparent; color:var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary)); font:inherit; font-size:13px; line-height:20px; cursor:pointer; }
|
|
55
|
+
.codex-harness-settings .codex-harness-nav button[data-nav-align=end] { margin-left:auto; }
|
|
149
56
|
.codex-harness-settings .codex-harness-nav button[aria-pressed=true] { color:var(--dsw-alias-label-primary); font-weight:500; }
|
|
150
57
|
.codex-harness-settings .codex-harness-nav button[aria-pressed=true]::after { position:absolute; right:0; bottom:-1px; left:0; height:2px; border-radius:2px 2px 0 0; background:var(--dsw-alias-label-primary); content:''; }
|
|
58
|
+
.codex-harness-settings .codex-harness-help-list { margin:0; padding:0; list-style:none; display:flex; flex-direction:column; gap:8px; }
|
|
59
|
+
.codex-harness-settings .codex-harness-help-list li { display:flex; flex-direction:column; gap:2px; padding-top:8px; border-top:0.5px solid var(--dsw-alias-border-l1); }
|
|
60
|
+
.codex-harness-settings .codex-harness-help-list li:first-child { padding-top:0; border-top:0; }
|
|
61
|
+
.codex-harness-settings .codex-harness-help-list strong { font-size:13px; font-weight:600; }
|
|
62
|
+
.codex-harness-settings .codex-harness-help-list span { font-size:12px; color:var(--dsw-alias-label-secondary); line-height:1.5; }
|
|
63
|
+
.codex-harness-settings .codex-harness-link { color:var(--dsw-alias-brand-primary); text-decoration:underline; text-underline-offset:2px; font-size:12px; }
|
|
64
|
+
.codex-harness-settings .codex-harness-inline-row { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; }
|
|
65
|
+
.codex-harness-settings .codex-harness-update-bar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; margin-bottom:12px; padding:8px 12px; border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-state-success-bg, rgba(16,163,127,0.1)); border:0.5px solid var(--dsw-alias-border-l2); font-size:12px; }
|
|
151
66
|
.codex-harness-settings button { box-sizing:border-box; min-width:0; max-width:100%; font:inherit; color:inherit; }
|
|
152
67
|
.codex-harness-settings .codex-harness-btn { background:var(--dsw-alias-bg-layer-2); border:0.5px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-md, 8px); padding:6px 12px; font-size:12px; cursor:pointer; }
|
|
153
68
|
.codex-harness-settings .codex-harness-btn:disabled { opacity:.48; cursor:default; }
|
|
154
69
|
.codex-harness-settings .codex-harness-primary { background:var(--dsw-alias-label-primary); color:var(--dsw-alias-bg-base); border-color:transparent; font-weight:500; }
|
|
155
|
-
.codex-harness-settings :is(input,button):focus-visible { outline:2px solid var(--dsw-focus-ring-color, var(--dsw-alias-brand-primary)); outline-offset:2px; }
|
|
70
|
+
.codex-harness-settings :is(input,select,button):focus-visible { outline:2px solid var(--dsw-focus-ring-color, var(--dsw-alias-brand-primary)); outline-offset:2px; }
|
|
156
71
|
.codex-harness-settings fieldset { min-width:0; border:0; padding:0; margin:0; display:flex; flex-direction:column; gap:12px; }
|
|
157
72
|
.codex-harness-settings .codex-harness-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr)); gap:12px; }
|
|
73
|
+
.codex-harness-settings .codex-harness-stack { display:flex; flex-direction:column; gap:12px; }
|
|
158
74
|
.codex-harness-settings .codex-harness-card { border:0.5px solid var(--dsw-alias-settings-card-stroke, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-xl, 12px); background:var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-1)); padding:12px 16px; }
|
|
75
|
+
.codex-harness-settings details.codex-harness-collapse > summary { display:flex; align-items:center; justify-content:space-between; gap:8px; cursor:pointer; list-style:none; user-select:none; font-size:13px; font-weight:500; }
|
|
76
|
+
.codex-harness-settings details.codex-harness-collapse > summary::-webkit-details-marker { display:none; }
|
|
77
|
+
.codex-harness-settings details.codex-harness-collapse[open] > summary { padding-bottom:8px; margin-bottom:8px; border-bottom:0.5px solid var(--dsw-alias-border-l1); }
|
|
159
78
|
.codex-harness-settings .codex-harness-group h4 { margin:0 0 6px; font-size:12px; font-weight:600; color:var(--dsw-alias-label-secondary); }
|
|
160
79
|
.codex-harness-settings .codex-harness-setting-row { min-width:0; display:flex; gap:12px; justify-content:space-between; align-items:center; padding:8px 0; border-bottom:0.5px solid var(--dsw-alias-border-l1); }
|
|
161
80
|
.codex-harness-settings .codex-harness-setting-row:last-child { border-bottom:0; }
|
|
81
|
+
.codex-harness-settings .codex-harness-cap-row { min-width:0; display:flex; gap:12px; justify-content:space-between; align-items:flex-start; padding:10px 0; border-bottom:0.5px solid var(--dsw-alias-border-l1); }
|
|
82
|
+
.codex-harness-settings .codex-harness-cap-row:last-child { border-bottom:0; }
|
|
83
|
+
.codex-harness-settings .codex-harness-cap-info { min-width:0; flex:1 1 240px; display:flex; flex-direction:column; gap:4px; }
|
|
84
|
+
.codex-harness-settings .codex-harness-cap-head { display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
|
|
85
|
+
.codex-harness-settings .codex-harness-cap-title { font-size:13px; font-weight:600; }
|
|
86
|
+
.codex-harness-settings .codex-harness-cap-detail { font-size:12px; color:var(--dsw-alias-label-secondary); line-height:1.45; }
|
|
87
|
+
.codex-harness-settings .codex-harness-subagent-controls { display:flex; flex-wrap:wrap; gap:8px; margin-top:4px; }
|
|
88
|
+
.codex-harness-settings .codex-harness-subagent-field { display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--dsw-alias-label-secondary); }
|
|
89
|
+
.codex-harness-settings .codex-harness-subagent-field select { height:28px; padding:0 8px; border:0.5px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); border-radius:var(--dsw-radius-md, 8px); background:var(--dsw-alias-bg-layer-2); color:var(--dsw-alias-label-primary); font:inherit; font-size:12px; }
|
|
90
|
+
.codex-harness-settings .codex-harness-badge { font-size:11px; line-height:16px; padding:1px 7px; border-radius:999px; background:var(--dsw-alias-bg-layer-2); color:var(--dsw-alias-label-secondary); border:0.5px solid var(--dsw-alias-border-l2); }
|
|
91
|
+
.codex-harness-settings .codex-harness-badge[data-tone=ok] { background:var(--dsw-alias-state-success-bg, rgba(16,163,127,0.12)); color:var(--dsw-alias-state-success-primary, #10a37f); border-color:transparent; font-weight:500; }
|
|
162
92
|
.codex-harness-settings .codex-harness-note { margin:0 0 12px; color:var(--dsw-alias-label-secondary); font-size:12px; line-height:1.5; }
|
|
163
|
-
.codex-harness-settings .codex-harness-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:4px; }
|
|
164
93
|
.codex-harness-settings input[role=switch] { appearance:none; width:34px; height:20px; border:0.5px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); border-radius:16px; background:var(--dsw-alias-bg-layer-2); position:relative; cursor:pointer; flex-shrink:0; margin:0; transition:background .15s; }
|
|
94
|
+
.codex-harness-settings input[role=switch]:disabled { opacity:.45; cursor:default; }
|
|
165
95
|
.codex-harness-settings input[role=switch]:before { content:''; position:absolute; width:14px; height:14px; top:2.5px; left:2.5px; border-radius:50%; background:var(--dsw-alias-label-secondary); transition:left .15s, background .15s; }
|
|
166
96
|
.codex-harness-settings input[role=switch]:checked { background:var(--dsw-alias-label-primary); border-color:transparent; }
|
|
167
97
|
.codex-harness-settings input[role=switch]:checked:before { left:16.5px; background:var(--dsw-alias-bg-base); }
|
|
@@ -172,54 +102,282 @@ export function DesktopSettingsCard({ t }: DesktopSettingsProps & { view: 'summa
|
|
|
172
102
|
return <section><p>{t('settingsBundleSummary')}</p><p>{t('settingsBundlePath')}</p></section>
|
|
173
103
|
}
|
|
174
104
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
105
|
+
const EMPTY_CONNECT_SUBSCRIBE = () => () => {}
|
|
106
|
+
const EMPTY_CONNECT_SNAPSHOT = (): CodexConnectSnapshot | undefined => undefined
|
|
107
|
+
|
|
108
|
+
/** Unified environment-wide settings: live subscription registrations, model requests, and display toggles. */
|
|
109
|
+
export function RuntimeSettingsEditor({
|
|
110
|
+
active,
|
|
111
|
+
connectScope,
|
|
112
|
+
connectSnapshot,
|
|
113
|
+
onImageRegistrationChanged,
|
|
114
|
+
...props
|
|
115
|
+
}: DesktopSettingsProps & {
|
|
116
|
+
active: boolean
|
|
117
|
+
connectScope?: CodexConnectScope | undefined
|
|
118
|
+
connectSnapshot?: CodexConnectSnapshot | undefined
|
|
119
|
+
onImageRegistrationChanged?: (() => void) | undefined
|
|
120
|
+
}) {
|
|
121
|
+
const { useSettings, saveSettings, presetManager, t } = props
|
|
178
122
|
const snapshot = useSettings(state => state)
|
|
179
|
-
const [
|
|
180
|
-
const [saving, setSaving] = useState(false)
|
|
123
|
+
const [busyField, setBusyField] = useState<string | null>(null)
|
|
181
124
|
const [error, setError] = useState('')
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
|
|
125
|
+
const [capBusy, setCapBusy] = useState<'search' | 'image' | null>(null)
|
|
126
|
+
const [capError, setCapError] = useState('')
|
|
127
|
+
const [subagentModels, setSubagentModels] = useState<CodexSubagentModelCatalog>()
|
|
128
|
+
const [subagentModelsStatus, setSubagentModelsStatus] = useState<'idle' | 'loading' | 'ready' | 'error'>('idle')
|
|
129
|
+
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (!active || presetManager === undefined) return undefined
|
|
132
|
+
let alive = true
|
|
133
|
+
setSubagentModelsStatus(current => current === 'ready' ? 'ready' : 'loading')
|
|
134
|
+
void requestCodexSubagentModels(presetManager)
|
|
135
|
+
.then(result => {
|
|
136
|
+
if (!alive) return
|
|
137
|
+
setSubagentModels(result)
|
|
138
|
+
setSubagentModelsStatus('ready')
|
|
139
|
+
})
|
|
140
|
+
.catch(() => {
|
|
141
|
+
if (alive) setSubagentModelsStatus('error')
|
|
142
|
+
})
|
|
143
|
+
return () => { alive = false }
|
|
144
|
+
}, [active, presetManager])
|
|
145
|
+
|
|
146
|
+
if (!active) return null
|
|
147
|
+
|
|
148
|
+
const value = (field: keyof CodexSettings) => {
|
|
149
|
+
const raw = snapshot.value?.[field]
|
|
150
|
+
if (typeof raw === 'boolean') return raw
|
|
151
|
+
return field !== 'fast' && field !== 'codexSubagentEnabled'
|
|
152
|
+
}
|
|
153
|
+
const saveCodex = (key: string, edits: Record<string, unknown>, refreshTools = false) => {
|
|
154
|
+
if (busyField !== null || !snapshot.writable || snapshot.status !== 'ready') return
|
|
155
|
+
setBusyField(key)
|
|
156
|
+
setError('')
|
|
157
|
+
void saveSettings(edits, snapshot.revision)
|
|
158
|
+
.then(() => { if (refreshTools) onImageRegistrationChanged?.() })
|
|
159
|
+
.catch(() => setError(t('settingsSharedFailed')))
|
|
160
|
+
.finally(() => setBusyField(current => current === key ? null : current))
|
|
186
161
|
}
|
|
162
|
+
|
|
163
|
+
const connectReady = connectSnapshot?.status === 'ready'
|
|
164
|
+
const connectLoading = connectSnapshot?.status === 'loading'
|
|
165
|
+
const searchRegistered = connectReady && connectSnapshot.searchEnabled === true
|
|
166
|
+
const imageRegistered = connectReady && connectSnapshot.imageGenerationEnabled === true
|
|
167
|
+
const hostedWebSearch = value('hostedWebSearchEnabled')
|
|
168
|
+
const canToggleSearch = connectReady && connectSnapshot.writable && connectScope?.setSearchEnabled !== undefined && capBusy === null
|
|
169
|
+
const canToggleImage = connectReady && connectSnapshot.writable && connectScope?.setImageGenerationEnabled !== undefined && capBusy === null
|
|
170
|
+
|
|
171
|
+
const subagentAvailable = connectReady || subagentModels?.available === true
|
|
172
|
+
const subagentNeedsRestart = subagentModelsStatus === 'error'
|
|
173
|
+
const subagentEnabled = subagentAvailable && value('codexSubagentEnabled')
|
|
174
|
+
const subagentModel = snapshot.value?.codexSubagentModel?.trim() || ''
|
|
175
|
+
const subagentEffort = snapshot.value?.codexSubagentEffort?.trim() || ''
|
|
176
|
+
const subagentPreset = snapshot.value?.codexSubagentPreset?.trim() || CODEX_SUBAGENT_DEFAULT_PRESET
|
|
177
|
+
const availableModels = subagentModels?.models ?? []
|
|
178
|
+
const effectiveModelId = subagentModel || availableModels[0]?.id || ''
|
|
179
|
+
const selectedModelMeta = availableModels.find(model => model.id === effectiveModelId)
|
|
180
|
+
const effortChoices = selectedModelMeta && selectedModelMeta.efforts.length > 0 ? selectedModelMeta.efforts : DEFAULT_EFFORTS
|
|
181
|
+
const canEditSubagent = subagentAvailable && !subagentNeedsRestart && snapshot.writable && snapshot.status === 'ready' && busyField === null
|
|
182
|
+
|
|
183
|
+
const toggleRegistration = (kind: 'search' | 'image', next: boolean) => {
|
|
184
|
+
const write = kind === 'search' ? connectScope?.setSearchEnabled : connectScope?.setImageGenerationEnabled
|
|
185
|
+
if (!write || capBusy !== null || !connectReady || !connectSnapshot.writable) return
|
|
186
|
+
setCapBusy(kind)
|
|
187
|
+
setCapError('')
|
|
188
|
+
void write(next)
|
|
189
|
+
.then(() => { if (kind === 'image') onImageRegistrationChanged?.() })
|
|
190
|
+
.catch(() => setCapError(t('capabilityWriteFailed')))
|
|
191
|
+
.finally(() => setCapBusy(current => current === kind ? null : current))
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const registrationBadge = (registered: boolean, available = connectReady) => (
|
|
195
|
+
<span className="codex-harness-badge" data-tone={registered ? 'ok' : undefined}>
|
|
196
|
+
{available ? t(registered ? 'capabilityRegistered' : 'capabilityNotRegistered') : t('capabilityUnavailable')}
|
|
197
|
+
</span>
|
|
198
|
+
)
|
|
199
|
+
|
|
187
200
|
const groups = [
|
|
188
201
|
{ label: 'globalGroupRequest', fields: [['fast', 'fast'], ['hostedWebSearchEnabled', 'settingsPreferHostedSearch'], ['remoteCompactionEnabled', 'settingsPreferRemoteCompaction']] },
|
|
189
|
-
{ label: 'globalGroupDisplay', fields: [['contextWindowControlEnabled', 'contextWindowControl'], ['fastModeControlEnabled', 'fastModeControl'], ['activityIndicatorEnabled', 'capabilityActivity']] },
|
|
202
|
+
{ label: 'globalGroupDisplay', fields: [['contextWindowControlEnabled', 'contextWindowControl'], ['proModeControlEnabled', 'proModeControl'], ['fastModeControlEnabled', 'fastModeControl'], ['activityIndicatorEnabled', 'capabilityActivity']] },
|
|
190
203
|
] as const
|
|
191
|
-
|
|
192
|
-
return <section aria-label={t('settingsRuntimePage')}>
|
|
193
|
-
<
|
|
194
|
-
<
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
<
|
|
204
|
+
|
|
205
|
+
return <section aria-label={t('settingsRuntimePage')} className="codex-harness-stack">
|
|
206
|
+
<p className="codex-harness-note" style={{ marginBottom: 0 }}>{t('settingsRuntimeScope')}</p>
|
|
207
|
+
<fieldset disabled={!snapshot.writable || snapshot.status !== 'ready' || busyField !== null}>
|
|
208
|
+
<div className="codex-harness-grid">{groups.map(group => <div key={group.label} className="codex-harness-card codex-harness-group">
|
|
209
|
+
<h4>{t(group.label)}</h4>{group.fields.map(([field, label]) => <label key={field} className="codex-harness-setting-row">
|
|
210
|
+
<span>{t(label)}</span><input type="checkbox" role="switch" aria-label={t(label)} aria-checked={value(field)}
|
|
211
|
+
checked={value(field)} onChange={event => saveCodex(field, { [field]: event.target.checked })} />
|
|
212
|
+
</label>)}
|
|
213
|
+
</div>)}</div>
|
|
214
|
+
</fieldset>
|
|
215
|
+
{!snapshot.writable && <p className="codex-harness-note">{t('promptReadOnly')}</p>}
|
|
216
|
+
{error && <p role="alert">{error}</p>}
|
|
217
|
+
{subagentAvailable ? <div className="codex-harness-card codex-harness-group" data-capability-group="connect">
|
|
218
|
+
<h4>{t('capabilitiesConnectHeading')}</h4>
|
|
219
|
+
<p className="codex-harness-note">{t('capabilitiesConnectNote')}</p>
|
|
220
|
+
<div className="codex-harness-cap-row" data-global-capability="web_search">
|
|
221
|
+
<div className="codex-harness-cap-info">
|
|
222
|
+
<div className="codex-harness-cap-head">
|
|
223
|
+
<span className="codex-harness-cap-title">{t('capabilitySearchTitle')}</span>
|
|
224
|
+
<code>web_search</code>
|
|
225
|
+
{registrationBadge(searchRegistered)}
|
|
226
|
+
{connectReady && connectSnapshot.searchModel && <span className="codex-harness-badge">{connectSnapshot.searchModel}</span>}
|
|
227
|
+
</div>
|
|
228
|
+
<span className="codex-harness-cap-detail">{t(hostedWebSearch ? 'capabilitySearchNoteFallback' : 'capabilitySearchNoteAll')}</span>
|
|
210
229
|
</div>
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
230
|
+
<input type="checkbox" role="switch" aria-label={t('capabilitySearchTitle')} aria-checked={searchRegistered}
|
|
231
|
+
checked={searchRegistered} disabled={!canToggleSearch} onChange={event => toggleRegistration('search', event.target.checked)} />
|
|
232
|
+
</div>
|
|
233
|
+
<div className="codex-harness-cap-row" data-global-capability="codex_connect_image_generate">
|
|
234
|
+
<div className="codex-harness-cap-info">
|
|
235
|
+
<div className="codex-harness-cap-head">
|
|
236
|
+
<span className="codex-harness-cap-title">{t('capabilityImageTitle')}</span>
|
|
237
|
+
<code>codex_connect_image_generate</code>
|
|
238
|
+
{registrationBadge(imageRegistered)}
|
|
239
|
+
{connectReady && <span className="codex-harness-badge">{formatGptImageBadge(connectSnapshot.imageModelHint)}</span>}
|
|
240
|
+
</div>
|
|
241
|
+
<span className="codex-harness-cap-detail">{t('capabilityImageNote')}</span>
|
|
242
|
+
</div>
|
|
243
|
+
<input type="checkbox" role="switch" aria-label={t('capabilityImageTitle')} aria-checked={imageRegistered}
|
|
244
|
+
checked={imageRegistered} disabled={!canToggleImage} onChange={event => toggleRegistration('image', event.target.checked)} />
|
|
245
|
+
</div>
|
|
246
|
+
<div className="codex-harness-cap-row" data-global-capability={CODEX_SUBAGENT_TOOL_NAME}>
|
|
247
|
+
<div className="codex-harness-cap-info">
|
|
248
|
+
<div className="codex-harness-cap-head">
|
|
249
|
+
<span className="codex-harness-cap-title">{t('capabilitySubagentTitle')}</span>
|
|
250
|
+
<code>{CODEX_SUBAGENT_TOOL_NAME}</code>
|
|
251
|
+
{registrationBadge(subagentEnabled, subagentAvailable)}
|
|
252
|
+
{effectiveModelId && <span className="codex-harness-badge">{effectiveModelId}{subagentEffort ? ` · ${subagentEffort}` : ''}</span>}
|
|
253
|
+
</div>
|
|
254
|
+
<span className="codex-harness-cap-detail">{t('capabilitySubagentNote')}</span>
|
|
255
|
+
<div className="codex-harness-subagent-controls">
|
|
256
|
+
<label className="codex-harness-subagent-field">
|
|
257
|
+
<span>{t('capabilitySubagentModel')}</span>
|
|
258
|
+
<select aria-label={t('capabilitySubagentModel')} value={effectiveModelId} disabled={!canEditSubagent || (availableModels.length === 0 && !subagentModel)} onChange={event => {
|
|
259
|
+
const nextModel = event.target.value
|
|
260
|
+
if (!nextModel) return
|
|
261
|
+
const targetMeta = availableModels.find(model => model.id === nextModel)
|
|
262
|
+
const keepEffort = !subagentEffort || !targetMeta?.efforts.length || targetMeta.efforts.includes(subagentEffort)
|
|
263
|
+
saveCodex('codexSubagentModel', {
|
|
264
|
+
codexSubagentModel: nextModel,
|
|
265
|
+
...(keepEffort ? {} : { codexSubagentEffort: undefined }),
|
|
266
|
+
})
|
|
267
|
+
}}>
|
|
268
|
+
{availableModels.length === 0 && !subagentModel && (
|
|
269
|
+
<option value="">{t(subagentNeedsRestart ? 'capabilitySubagentRestart' : subagentModelsStatus === 'loading' ? 'capabilityLoading' : 'capabilitySubagentNoModels')}</option>
|
|
270
|
+
)}
|
|
271
|
+
{subagentModel && !availableModels.some(model => model.id === subagentModel) && <option value={subagentModel}>{subagentModel}</option>}
|
|
272
|
+
{availableModels.map(model => <option key={model.id} value={model.id}>{model.id}</option>)}
|
|
273
|
+
</select>
|
|
274
|
+
</label>
|
|
275
|
+
<label className="codex-harness-subagent-field">
|
|
276
|
+
<span>{t('capabilitySubagentEffort')}</span>
|
|
277
|
+
<select aria-label={t('capabilitySubagentEffort')} value={subagentEffort} disabled={!canEditSubagent} onChange={event => {
|
|
278
|
+
saveCodex('codexSubagentEffort', { codexSubagentEffort: event.target.value || undefined })
|
|
279
|
+
}}>
|
|
280
|
+
<option value="">{t('capabilitySubagentEffortDefault')}</option>
|
|
281
|
+
{subagentEffort && !effortChoices.includes(subagentEffort) && <option value={subagentEffort}>{subagentEffort}</option>}
|
|
282
|
+
{effortChoices.map(effort => <option key={effort} value={effort}>{effort}</option>)}
|
|
283
|
+
</select>
|
|
284
|
+
</label>
|
|
285
|
+
<label className="codex-harness-subagent-field">
|
|
286
|
+
<span>{t('capabilitySubagentPreset')}</span>
|
|
287
|
+
<select aria-label={t('capabilitySubagentPreset')} value={subagentPreset} disabled={!canEditSubagent} onChange={event => {
|
|
288
|
+
saveCodex('codexSubagentPreset', { codexSubagentPreset: event.target.value })
|
|
289
|
+
}}>
|
|
290
|
+
<option value={CODEX_SUBAGENT_DEFAULT_PRESET}>{t('capabilitySubagentPresetHybrid')}</option>
|
|
291
|
+
<option value={CODEX_SUBAGENT_PRESET_INHERIT}>{t('capabilitySubagentPresetInherit')}</option>
|
|
292
|
+
{subagentPreset !== CODEX_SUBAGENT_DEFAULT_PRESET && subagentPreset !== CODEX_SUBAGENT_PRESET_INHERIT && <option value={subagentPreset}>{subagentPreset}</option>}
|
|
293
|
+
</select>
|
|
294
|
+
</label>
|
|
295
|
+
</div>
|
|
296
|
+
</div>
|
|
297
|
+
<input type="checkbox" role="switch" aria-label={t('capabilitySubagentTitle')} aria-checked={subagentEnabled}
|
|
298
|
+
checked={subagentEnabled} disabled={!canEditSubagent} onChange={event => {
|
|
299
|
+
const next = event.target.checked
|
|
300
|
+
saveCodex('codexSubagentEnabled', {
|
|
301
|
+
codexSubagentEnabled: next,
|
|
302
|
+
...(next && !subagentModel && effectiveModelId ? { codexSubagentModel: effectiveModelId } : {}),
|
|
303
|
+
}, true)
|
|
304
|
+
}} />
|
|
305
|
+
</div>
|
|
306
|
+
{connectReady && !connectSnapshot.writable && <p className="codex-harness-note">{t('promptReadOnly')}</p>}
|
|
307
|
+
{capError && <p role="alert">{capError}</p>}
|
|
308
|
+
</div> : <details className="codex-harness-card codex-harness-collapse" data-capability-group="connect" data-collapsed="true">
|
|
309
|
+
<summary>
|
|
310
|
+
<span>{t('capabilitiesConnectCollapsedTitle')}</span>
|
|
311
|
+
{connectLoading && <span className="codex-harness-badge">{t('capabilityLoading')}</span>}
|
|
312
|
+
</summary>
|
|
313
|
+
<div className="codex-harness-inline-row">
|
|
314
|
+
<span className="codex-harness-cap-detail">{t('capabilitiesConnectInstallHint')}</span>
|
|
315
|
+
<a className="codex-harness-link" href={CODEX_CONNECT_REPO_URL} target="_blank" rel="noopener noreferrer">github.com/shuind/dsh-codex-connect</a>
|
|
316
|
+
</div>
|
|
317
|
+
</details>}
|
|
214
318
|
</section>
|
|
215
319
|
}
|
|
216
320
|
|
|
217
|
-
const
|
|
218
|
-
|
|
321
|
+
const EMPTY_UPDATE_SNAPSHOT = (): HarnessUpdateSnapshot | undefined => undefined
|
|
322
|
+
|
|
323
|
+
export function HelpGuideSection({ active, updateStore, updateSnapshot, t }: {
|
|
324
|
+
active: boolean
|
|
325
|
+
updateStore?: HarnessUpdateStore | undefined
|
|
326
|
+
updateSnapshot?: HarnessUpdateSnapshot | undefined
|
|
327
|
+
t: PropsLocale<'codex'>['t']
|
|
328
|
+
}) {
|
|
329
|
+
if (!active) return null
|
|
330
|
+
const cards = [
|
|
331
|
+
{ id: 'faq', heading: 'helpFaqHeading', items: [
|
|
332
|
+
['helpDeferDisabledTitle', 'helpDeferDisabledDesc'],
|
|
333
|
+
['helpDeferLifecycleTitle', 'helpDeferLifecycleDesc'],
|
|
334
|
+
['helpNativeSearchTitle', 'helpNativeSearchDesc'],
|
|
335
|
+
] },
|
|
336
|
+
{ id: 'connect', heading: 'helpConnectHeading', items: [
|
|
337
|
+
['helpRegistrationScopeTitle', 'helpRegistrationScopeDesc'],
|
|
338
|
+
['helpProComboTitle', 'helpProComboDesc'],
|
|
339
|
+
['helpConnectContextTitle', 'helpConnectContextDesc'],
|
|
340
|
+
] },
|
|
341
|
+
] as const
|
|
342
|
+
const status = updateSnapshot?.status ?? 'idle'
|
|
343
|
+
const currentVersion = updateSnapshot?.currentVersion
|
|
344
|
+
const hasUpdate = status === 'update-available' && updateSnapshot?.latestVersion !== undefined
|
|
345
|
+
return <section aria-label={t('settingsHelpPage')} className="codex-harness-stack">
|
|
346
|
+
{cards.map(card => <div key={card.id} className="codex-harness-card codex-harness-group" data-help-section={card.id}>
|
|
347
|
+
<h4>{t(card.heading)}</h4>
|
|
348
|
+
<ul className="codex-harness-help-list">
|
|
349
|
+
{card.items.map(([titleKey, descKey]) => <li key={titleKey}><strong>{t(titleKey)}</strong><span>{t(descKey)}</span></li>)}
|
|
350
|
+
</ul>
|
|
351
|
+
{card.id === 'connect' && <div className="codex-harness-inline-row" style={{ marginTop: 10, paddingTop: 8, borderTop: '0.5px solid var(--dsw-alias-border-l1)' }}>
|
|
352
|
+
<span className="codex-harness-cap-detail">{t('helpConnectLinkLabel')} · <code>{CODEX_CONNECT_PACKAGE_NAME}</code></span>
|
|
353
|
+
<a className="codex-harness-link" href={CODEX_CONNECT_REPO_URL} target="_blank" rel="noopener noreferrer">github.com/shuind/dsh-codex-connect</a>
|
|
354
|
+
</div>}
|
|
355
|
+
</div>)}
|
|
356
|
+
<div className="codex-harness-card codex-harness-group" data-help-section="updates">
|
|
357
|
+
<h4>{t('helpUpdateHeading')}</h4>
|
|
358
|
+
<div className="codex-harness-inline-row" style={{ marginBottom: 8 }}>
|
|
359
|
+
<div className="codex-harness-cap-head">
|
|
360
|
+
<span className="codex-harness-cap-title">Codex Harness{currentVersion ? ` v${currentVersion}` : ''}</span>
|
|
361
|
+
{hasUpdate && <span className="codex-harness-badge" data-tone="ok">{t('updateAvailable')} v{updateSnapshot.latestVersion}</span>}
|
|
362
|
+
{status === 'up-to-date' && <span className="codex-harness-badge">{t('updateUpToDate')}</span>}
|
|
363
|
+
{status === 'checking' && <span className="codex-harness-badge">{t('updateChecking')}</span>}
|
|
364
|
+
{status === 'unavailable' && <span className="codex-harness-badge">{t('updateUnavailable')}</span>}
|
|
365
|
+
</div>
|
|
366
|
+
{updateStore && <button type="button" className="codex-harness-btn" disabled={status === 'checking'} onClick={() => { void updateStore.refresh(true) }}>{t('updateCheckNow')}</button>}
|
|
367
|
+
</div>
|
|
368
|
+
<p className="codex-harness-note" style={{ marginBottom: 6 }}>{t('updateHowTo')}</p>
|
|
369
|
+
<div className="codex-harness-cap-head">
|
|
370
|
+
{hasUpdate && updateSnapshot.releaseUrl && <a className="codex-harness-link" href={updateSnapshot.releaseUrl} target="_blank" rel="noopener noreferrer">{t('updateOpenRelease')} (v{updateSnapshot.latestVersion})</a>}
|
|
371
|
+
<a className="codex-harness-link" href={CODEX_HARNESS_RELEASES_URL} target="_blank" rel="noopener noreferrer">GitHub Releases</a>
|
|
372
|
+
</div>
|
|
373
|
+
</div>
|
|
374
|
+
</section>
|
|
375
|
+
}
|
|
219
376
|
|
|
220
377
|
export function CodexSettingsTab(props: DesktopSettingsProps & { initialPage?: SettingsPage }) {
|
|
221
|
-
const { toolPolicy, presetManager, getCodexConnectScope, t } = props
|
|
378
|
+
const { toolPolicy, presetManager, getCodexConnectScope, updateStore, t } = props
|
|
222
379
|
const [page, setPage] = useState<SettingsPage>(props.initialPage ?? 'tools')
|
|
380
|
+
const [toolsVersion, setToolsVersion] = useState(0)
|
|
223
381
|
const settingsSnapshot = typeof props.useSettings === 'function'
|
|
224
382
|
? props.useSettings(state => state as CodexSettingsSnapshot)
|
|
225
383
|
: undefined
|
|
@@ -229,6 +387,23 @@ export function CodexSettingsTab(props: DesktopSettingsProps & { initialPage?: S
|
|
|
229
387
|
connectScope ? connectScope.getSnapshot : EMPTY_CONNECT_SNAPSHOT,
|
|
230
388
|
connectScope ? connectScope.getSnapshot : EMPTY_CONNECT_SNAPSHOT,
|
|
231
389
|
)
|
|
390
|
+
const updateSnapshot = useSyncExternalStore(
|
|
391
|
+
updateStore ? updateStore.subscribe : EMPTY_CONNECT_SUBSCRIBE,
|
|
392
|
+
updateStore ? updateStore.getSnapshot : EMPTY_UPDATE_SNAPSHOT,
|
|
393
|
+
updateStore ? updateStore.getSnapshot : EMPTY_UPDATE_SNAPSHOT,
|
|
394
|
+
)
|
|
395
|
+
const hasUpdate = updateSnapshot?.status === 'update-available' && updateSnapshot.latestVersion !== undefined
|
|
396
|
+
const imageEnabled = connectSnapshot?.status === 'ready' ? connectSnapshot.imageGenerationEnabled === true : undefined
|
|
397
|
+
const subagentEnabled = settingsSnapshot?.status === 'ready' ? settingsSnapshot.value?.codexSubagentEnabled === true : undefined
|
|
398
|
+
const prevRegistration = useRef<string>()
|
|
399
|
+
const registrationKey = `${String(imageEnabled)}:${String(subagentEnabled)}`
|
|
400
|
+
useEffect(() => {
|
|
401
|
+
if (prevRegistration.current !== undefined && prevRegistration.current !== registrationKey) {
|
|
402
|
+
if (presetManager !== undefined) invalidatePresetTools(presetManager)
|
|
403
|
+
setToolsVersion(version => version + 1)
|
|
404
|
+
}
|
|
405
|
+
prevRegistration.current = registrationKey
|
|
406
|
+
}, [registrationKey, presetManager])
|
|
232
407
|
const gptCapabilities = resolveGptCapabilities(settingsSnapshot?.value, connectSnapshot)
|
|
233
408
|
const mode: ToolPolicyMode = page === 'tools' ? 'tools' : 'inactive'
|
|
234
409
|
return <section className="codex-harness-settings">
|
|
@@ -236,9 +411,26 @@ export function CodexSettingsTab(props: DesktopSettingsProps & { initialPage?: S
|
|
|
236
411
|
<nav className="codex-harness-nav" aria-label={t('settingsTabLabel')}>
|
|
237
412
|
<button type="button" aria-pressed={page === 'tools'} onClick={() => setPage('tools')}>{t('settingsToolsPage')}</button>
|
|
238
413
|
<button type="button" aria-pressed={page === 'runtime'} onClick={() => setPage('runtime')}>{t('settingsRuntimePage')}</button>
|
|
414
|
+
<button type="button" data-nav-align="end" aria-pressed={page === 'help'} onClick={() => setPage('help')}>
|
|
415
|
+
{hasUpdate ? <>{t('settingsHelpPage')}<span className="codex-harness-badge" data-tone="ok" style={{ marginLeft: 6 }}>{t('updateBadge')}</span></> : t('settingsHelpPage')}
|
|
416
|
+
</button>
|
|
239
417
|
</nav>
|
|
240
|
-
{
|
|
241
|
-
|
|
418
|
+
{hasUpdate && <div className="codex-harness-update-bar" role="status" data-codex-update-banner>
|
|
419
|
+
<span>Codex Harness {t('updateAvailable')} v{updateSnapshot.latestVersion}</span>
|
|
420
|
+
{updateSnapshot.releaseUrl && <a className="codex-harness-link" href={updateSnapshot.releaseUrl} target="_blank" rel="noopener noreferrer">{t('updateOpenRelease')}</a>}
|
|
421
|
+
</div>}
|
|
422
|
+
{toolPolicy !== undefined && <ToolPolicySection binding={toolPolicy} presetManager={presetManager} mode={mode} gptCapabilities={gptCapabilities} toolsVersion={toolsVersion} t={t} />}
|
|
423
|
+
<RuntimeSettingsEditor
|
|
424
|
+
{...props}
|
|
425
|
+
active={page === 'runtime'}
|
|
426
|
+
connectScope={connectScope}
|
|
427
|
+
connectSnapshot={connectSnapshot}
|
|
428
|
+
onImageRegistrationChanged={() => {
|
|
429
|
+
if (presetManager !== undefined) invalidatePresetTools(presetManager)
|
|
430
|
+
setToolsVersion(version => version + 1)
|
|
431
|
+
}}
|
|
432
|
+
/>
|
|
433
|
+
<HelpGuideSection active={page === 'help'} updateStore={updateStore} updateSnapshot={updateSnapshot} t={t} />
|
|
242
434
|
</section>
|
|
243
435
|
}
|
|
244
436
|
|
|
@@ -246,14 +438,20 @@ export const inject = ['commandUi', 'sessions', 'slots', 'locale', 'configForms'
|
|
|
246
438
|
export function apply(ctx: Context): void {
|
|
247
439
|
let form: DesktopConfigForm
|
|
248
440
|
let connectScope: CodexConnectScope | undefined
|
|
441
|
+
let llmProvidersScope: LlmProvidersScope | undefined
|
|
249
442
|
const getCodexConnectScope = (): CodexConnectScope | undefined => {
|
|
250
443
|
try { return connectScope ??= bindCodexConnectScope((ctx as unknown as DesktopSettingsContext).configForms) }
|
|
251
444
|
catch { return undefined }
|
|
252
445
|
}
|
|
446
|
+
const getLlmProvidersScope = (): LlmProvidersScope | undefined => {
|
|
447
|
+
try { return llmProvidersScope ??= bindLlmProvidersScope((ctx as unknown as DesktopSettingsContext).configForms) }
|
|
448
|
+
catch { return undefined }
|
|
449
|
+
}
|
|
253
450
|
applyWithSettingsApi(ctx, {
|
|
254
451
|
bind: host => { form = (host as unknown as DesktopSettingsContext).configForms.get('codex'); return adaptConfigForm(form) },
|
|
255
452
|
getCodexConnectScope,
|
|
256
|
-
|
|
453
|
+
getLlmProvidersScope,
|
|
454
|
+
register: (host, settings, manager, updateStore) => {
|
|
257
455
|
const desktop = host as unknown as DesktopSettingsContext
|
|
258
456
|
const presetManager = { ...manager, remote: (host as unknown as { remote: PresetClientRemote }).remote }
|
|
259
457
|
const t = host.locale.bind('codex'); const toolPolicy = bindToolPolicy(host, host.configForms)
|
|
@@ -263,6 +461,7 @@ export function apply(ctx: Context): void {
|
|
|
263
461
|
unsetSetting: field => settings.unset(field),
|
|
264
462
|
presetManager,
|
|
265
463
|
toolPolicy,
|
|
464
|
+
updateStore,
|
|
266
465
|
getCodexConnectScope,
|
|
267
466
|
saveSettings: async (edits, revision) => {
|
|
268
467
|
await saveDesktopSettings(form, edits, revision)
|