@shuind/dsh-codex-harness 0.3.1 → 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 +29 -0
- package/README.md +21 -43
- package/docs/preset-library.md +2 -2
- package/docs/tool-policy.md +1 -1
- package/lib/client.js +1738 -327
- package/lib/compact-command.js +7 -1
- package/lib/compaction.js +7 -1
- package/lib/hybrid-executor.js +23 -12
- package/lib/index.js +1266 -36
- 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 +191 -126
- package/lib/types/client/index.d.ts +104 -28
- 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 +80 -20
- package/lib/types/client/policy-locale.js +197 -80
- 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 +7 -2
- package/lib/types/client/tool-policy.js +48 -6
- 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 +52 -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/compact-checkpoint.js +3 -10
- package/lib/types/responses/fetch-transport.js +24 -9
- package/lib/types/responses/remote-compact.js +39 -11
- 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 +370 -153
- package/src/client/index.tsx +122 -22
- package/src/client/policy-drafts.ts +45 -0
- package/src/client/policy-locale.ts +197 -80
- package/src/client/preset-manager.tsx +125 -4
- package/src/client/preset-requests.ts +185 -1
- package/src/client/tool-policy.tsx +63 -9
- package/src/contracts/preset-editor-schema.ts +44 -0
- package/src/contracts/settings.ts +20 -1
- package/src/contracts/ui-contracts.ts +91 -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/compact-checkpoint.ts +2 -8
- package/src/responses/fetch-transport.ts +28 -9
- package/src/responses/remote-compact.ts +41 -11
- 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 } 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,157 +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
|
-
export function bindCodexConnectScope(configForms: DesktopSettingsContext['configForms']): CodexConnectScope {
|
|
64
|
-
const form = configForms.get(OPENAI_CODEX_SETTINGS_NAMESPACE)
|
|
65
|
-
const mirror = configForms.describe?.()
|
|
66
|
-
void Promise.resolve(mirror?.ensure?.()).catch(() => {})
|
|
67
|
-
let lastFormSnap: unknown
|
|
68
|
-
let lastMirrorSnap: unknown
|
|
69
|
-
let projected: CodexConnectSnapshot = { status: 'loading', writable: false }
|
|
70
|
-
const getSnapshot = (): CodexConnectSnapshot => {
|
|
71
|
-
const formSnap = form.getSnapshot() as CodexSettingsSnapshot & { readonly base?: Record<string, unknown> }
|
|
72
|
-
const mirrorSnap = mirror?.getSnapshot()
|
|
73
|
-
if (formSnap === lastFormSnap && mirrorSnap === lastMirrorSnap) return projected
|
|
74
|
-
lastFormSnap = formSnap
|
|
75
|
-
lastMirrorSnap = mirrorSnap
|
|
76
|
-
const formRecord = formSnap.status === 'ready' ? asRecord(formSnap.value) : undefined
|
|
77
|
-
if (formRecord !== undefined) {
|
|
78
|
-
return projected = {
|
|
79
|
-
status: 'ready',
|
|
80
|
-
writable: formSnap.writable,
|
|
81
|
-
overrides: asOverrides(formRecord.contextWindowOverrides),
|
|
82
|
-
baseOverrides: asOverrides(asRecord(formSnap.base)?.contextWindowOverrides),
|
|
83
|
-
...(typeof formRecord.enableNativeCompaction === 'boolean'
|
|
84
|
-
? { nativeCompaction: formRecord.enableNativeCompaction }
|
|
85
|
-
: {}),
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const view = mirrorSnap?.view
|
|
89
|
-
if (view !== undefined) {
|
|
90
|
-
const row = view.namespaces?.find(candidate => candidate.ns === OPENAI_CODEX_SETTINGS_NAMESPACE)
|
|
91
|
-
const rowRecord = row === undefined ? undefined : asRecord(row.value)
|
|
92
|
-
if (row === undefined || rowRecord === undefined) return projected = { status: 'unavailable', writable: false }
|
|
93
|
-
return projected = {
|
|
94
|
-
status: 'ready',
|
|
95
|
-
writable: view.writable ?? formSnap.writable,
|
|
96
|
-
overrides: asOverrides(rowRecord.contextWindowOverrides),
|
|
97
|
-
baseOverrides: asOverrides(asRecord(row.base)?.contextWindowOverrides),
|
|
98
|
-
...(typeof rowRecord.enableNativeCompaction === 'boolean'
|
|
99
|
-
? { nativeCompaction: rowRecord.enableNativeCompaction }
|
|
100
|
-
: {}),
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return projected = { status: formSnap.status, writable: formSnap.writable }
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
getSnapshot,
|
|
107
|
-
subscribe: listener => {
|
|
108
|
-
const stopForm = form.subscribe(listener)
|
|
109
|
-
const stopMirror = mirror?.subscribe(listener)
|
|
110
|
-
return () => { stopForm(); stopMirror?.() }
|
|
111
|
-
},
|
|
112
|
-
setModelOverride: async (modelId, tokens) => {
|
|
113
|
-
const snap = getSnapshot()
|
|
114
|
-
const next = nextOpenAICodexOverrides(snap.overrides, snap.baseOverrides, modelId, tokens)
|
|
115
|
-
const accepted = next === undefined
|
|
116
|
-
? await form.unset('contextWindowOverrides')
|
|
117
|
-
: await form.set('contextWindowOverrides', next)
|
|
118
|
-
if (!accepted) throw new Error('The host did not accept the settings change.')
|
|
119
|
-
},
|
|
120
|
-
setNativeCompaction: async enabled => {
|
|
121
|
-
const accepted = await form.set('enableNativeCompaction', enabled)
|
|
122
|
-
if (!accepted) throw new Error('The host did not accept the settings change.')
|
|
123
|
-
},
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
export function adaptConfigForm(form: Pick<DesktopConfigForm, 'getSnapshot' | 'subscribe' | 'set' | 'unset'>): CodexScope {
|
|
127
|
-
const accepted = async (result: Promise<boolean>) => { if (!await result) throw new Error('The host did not accept the settings change.') }
|
|
128
|
-
return { getSnapshot: () => form.getSnapshot(), subscribe: listener => form.subscribe(listener),
|
|
129
|
-
set: (field, value) => accepted(form.set(field, value)), unset: field => accepted(form.unset(field)) }
|
|
130
|
-
}
|
|
131
|
-
export async function saveDesktopSettings(form: Pick<DesktopConfigForm, 'mutate'>, edits: Record<string, unknown>, expectedRevision?: number | string): Promise<void> {
|
|
132
|
-
const ops = Object.entries(edits).map(([field, value]) => value === undefined ? { op: 'unset' as const, path: [field] } : { op: 'set' as const, path: [field], value })
|
|
133
|
-
if (!ops.length) return
|
|
134
|
-
const accepted = expectedRevision === undefined ? await form.mutate(ops) : await form.mutate(ops, expectedRevision)
|
|
135
|
-
if (!accepted) throw new Error('The host did not accept the settings change.')
|
|
42
|
+
updateStore?: HarnessUpdateStore
|
|
136
43
|
}
|
|
137
44
|
|
|
138
45
|
type DesktopSettingsProps = InjectFace<DesktopSettingsActions> & PropsLocale<'codex'>
|
|
139
|
-
type SettingsPage = 'tools' | 'runtime'
|
|
46
|
+
type SettingsPage = 'tools' | 'runtime' | 'help'
|
|
47
|
+
|
|
48
|
+
const DEFAULT_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'] as const
|
|
49
|
+
|
|
140
50
|
const desktopStyles = `
|
|
141
51
|
.codex-harness-settings { max-width:760px; min-width:0; font-size:13px; color:var(--dsw-alias-label-primary); }
|
|
142
52
|
.codex-harness-settings h3 { font-size:14px; margin:0 0 10px; }
|
|
143
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); }
|
|
144
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; }
|
|
145
56
|
.codex-harness-settings .codex-harness-nav button[aria-pressed=true] { color:var(--dsw-alias-label-primary); font-weight:500; }
|
|
146
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; }
|
|
147
66
|
.codex-harness-settings button { box-sizing:border-box; min-width:0; max-width:100%; font:inherit; color:inherit; }
|
|
148
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; }
|
|
149
68
|
.codex-harness-settings .codex-harness-btn:disabled { opacity:.48; cursor:default; }
|
|
150
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; }
|
|
151
|
-
.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; }
|
|
152
71
|
.codex-harness-settings fieldset { min-width:0; border:0; padding:0; margin:0; display:flex; flex-direction:column; gap:12px; }
|
|
153
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; }
|
|
154
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); }
|
|
155
78
|
.codex-harness-settings .codex-harness-group h4 { margin:0 0 6px; font-size:12px; font-weight:600; color:var(--dsw-alias-label-secondary); }
|
|
156
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); }
|
|
157
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; }
|
|
158
92
|
.codex-harness-settings .codex-harness-note { margin:0 0 12px; color:var(--dsw-alias-label-secondary); font-size:12px; line-height:1.5; }
|
|
159
|
-
.codex-harness-settings .codex-harness-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:4px; }
|
|
160
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; }
|
|
161
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; }
|
|
162
96
|
.codex-harness-settings input[role=switch]:checked { background:var(--dsw-alias-label-primary); border-color:transparent; }
|
|
163
97
|
.codex-harness-settings input[role=switch]:checked:before { left:16.5px; background:var(--dsw-alias-bg-base); }
|
|
@@ -168,60 +102,335 @@ export function DesktopSettingsCard({ t }: DesktopSettingsProps & { view: 'summa
|
|
|
168
102
|
return <section><p>{t('settingsBundleSummary')}</p><p>{t('settingsBundlePath')}</p></section>
|
|
169
103
|
}
|
|
170
104
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
|
174
122
|
const snapshot = useSettings(state => state)
|
|
175
|
-
const [
|
|
176
|
-
const [saving, setSaving] = useState(false)
|
|
123
|
+
const [busyField, setBusyField] = useState<string | null>(null)
|
|
177
124
|
const [error, setError] = useState('')
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
|
|
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))
|
|
182
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
|
+
|
|
183
200
|
const groups = [
|
|
184
201
|
{ label: 'globalGroupRequest', fields: [['fast', 'fast'], ['hostedWebSearchEnabled', 'settingsPreferHostedSearch'], ['remoteCompactionEnabled', 'settingsPreferRemoteCompaction']] },
|
|
185
|
-
{ label: 'globalGroupDisplay', fields: [['contextWindowControlEnabled', 'contextWindowControl'], ['fastModeControlEnabled', 'fastModeControl'], ['activityIndicatorEnabled', 'capabilityActivity']] },
|
|
202
|
+
{ label: 'globalGroupDisplay', fields: [['contextWindowControlEnabled', 'contextWindowControl'], ['proModeControlEnabled', 'proModeControl'], ['fastModeControlEnabled', 'fastModeControl'], ['activityIndicatorEnabled', 'capabilityActivity']] },
|
|
186
203
|
] as const
|
|
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>
|
|
229
|
+
</div>
|
|
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>}
|
|
318
|
+
</section>
|
|
319
|
+
}
|
|
320
|
+
|
|
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
|
+
}) {
|
|
187
329
|
if (!active) return null
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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>}
|
|
206
365
|
</div>
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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>
|
|
210
374
|
</section>
|
|
211
375
|
}
|
|
212
376
|
|
|
213
377
|
export function CodexSettingsTab(props: DesktopSettingsProps & { initialPage?: SettingsPage }) {
|
|
214
|
-
const { toolPolicy, presetManager, t } = props
|
|
378
|
+
const { toolPolicy, presetManager, getCodexConnectScope, updateStore, t } = props
|
|
215
379
|
const [page, setPage] = useState<SettingsPage>(props.initialPage ?? 'tools')
|
|
380
|
+
const [toolsVersion, setToolsVersion] = useState(0)
|
|
381
|
+
const settingsSnapshot = typeof props.useSettings === 'function'
|
|
382
|
+
? props.useSettings(state => state as CodexSettingsSnapshot)
|
|
383
|
+
: undefined
|
|
384
|
+
const connectScope = getCodexConnectScope?.()
|
|
385
|
+
const connectSnapshot = useSyncExternalStore(
|
|
386
|
+
connectScope ? connectScope.subscribe : EMPTY_CONNECT_SUBSCRIBE,
|
|
387
|
+
connectScope ? connectScope.getSnapshot : EMPTY_CONNECT_SNAPSHOT,
|
|
388
|
+
connectScope ? connectScope.getSnapshot : EMPTY_CONNECT_SNAPSHOT,
|
|
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])
|
|
407
|
+
const gptCapabilities = resolveGptCapabilities(settingsSnapshot?.value, connectSnapshot)
|
|
216
408
|
const mode: ToolPolicyMode = page === 'tools' ? 'tools' : 'inactive'
|
|
217
409
|
return <section className="codex-harness-settings">
|
|
218
410
|
<style>{desktopStyles}</style>
|
|
219
411
|
<nav className="codex-harness-nav" aria-label={t('settingsTabLabel')}>
|
|
220
412
|
<button type="button" aria-pressed={page === 'tools'} onClick={() => setPage('tools')}>{t('settingsToolsPage')}</button>
|
|
221
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>
|
|
222
417
|
</nav>
|
|
223
|
-
{
|
|
224
|
-
|
|
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} />
|
|
225
434
|
</section>
|
|
226
435
|
}
|
|
227
436
|
|
|
@@ -229,14 +438,20 @@ export const inject = ['commandUi', 'sessions', 'slots', 'locale', 'configForms'
|
|
|
229
438
|
export function apply(ctx: Context): void {
|
|
230
439
|
let form: DesktopConfigForm
|
|
231
440
|
let connectScope: CodexConnectScope | undefined
|
|
441
|
+
let llmProvidersScope: LlmProvidersScope | undefined
|
|
232
442
|
const getCodexConnectScope = (): CodexConnectScope | undefined => {
|
|
233
443
|
try { return connectScope ??= bindCodexConnectScope((ctx as unknown as DesktopSettingsContext).configForms) }
|
|
234
444
|
catch { return undefined }
|
|
235
445
|
}
|
|
446
|
+
const getLlmProvidersScope = (): LlmProvidersScope | undefined => {
|
|
447
|
+
try { return llmProvidersScope ??= bindLlmProvidersScope((ctx as unknown as DesktopSettingsContext).configForms) }
|
|
448
|
+
catch { return undefined }
|
|
449
|
+
}
|
|
236
450
|
applyWithSettingsApi(ctx, {
|
|
237
451
|
bind: host => { form = (host as unknown as DesktopSettingsContext).configForms.get('codex'); return adaptConfigForm(form) },
|
|
238
452
|
getCodexConnectScope,
|
|
239
|
-
|
|
453
|
+
getLlmProvidersScope,
|
|
454
|
+
register: (host, settings, manager, updateStore) => {
|
|
240
455
|
const desktop = host as unknown as DesktopSettingsContext
|
|
241
456
|
const presetManager = { ...manager, remote: (host as unknown as { remote: PresetClientRemote }).remote }
|
|
242
457
|
const t = host.locale.bind('codex'); const toolPolicy = bindToolPolicy(host, host.configForms)
|
|
@@ -246,6 +461,8 @@ export function apply(ctx: Context): void {
|
|
|
246
461
|
unsetSetting: field => settings.unset(field),
|
|
247
462
|
presetManager,
|
|
248
463
|
toolPolicy,
|
|
464
|
+
updateStore,
|
|
465
|
+
getCodexConnectScope,
|
|
249
466
|
saveSettings: async (edits, revision) => {
|
|
250
467
|
await saveDesktopSettings(form, edits, revision)
|
|
251
468
|
if (typeof edits.remoteCompactionEnabled === 'boolean') {
|