Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions apps/codex-plus-manager/src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ pub struct RelayProfileTestPayload {
pub response_preview: String,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StepwiseTestPayload {
pub item_count: usize,
pub error: String,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RelayProfileModelsPayload {
Expand Down Expand Up @@ -2087,6 +2094,44 @@ pub async fn test_relay_profile(profile: RelayProfile) -> CommandResult<RelayPro
}
}

#[tauri::command]
pub async fn test_stepwise_settings(
settings: BackendSettings,
) -> CommandResult<StepwiseTestPayload> {
match codex_plus_core::stepwise::test_connection(&settings).await {
Ok(result) => {
let error = result
.get("error")
.and_then(Value::as_str)
.unwrap_or_default()
.to_string();
let item_count = result
.get("items")
.and_then(Value::as_array)
.map(Vec::len)
.unwrap_or_default();
if error.is_empty() {
ok(
&format!("Stepwise 连接正常,测试返回 {item_count} 条建议。"),
StepwiseTestPayload { item_count, error },
)
} else {
failed(
&format!("Stepwise 测试失败:{error}"),
StepwiseTestPayload { item_count, error },
)
}
}
Err(error) => failed(
&format!("Stepwise 测试失败:{error}"),
StepwiseTestPayload {
item_count: 0,
error: error.to_string(),
},
),
}
}

#[tauri::command]
pub async fn fetch_relay_profile_models(
profile: RelayProfile,
Expand Down
1 change: 1 addition & 0 deletions apps/codex-plus-manager/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pub fn run() {
commands::delete_context_entry,
commands::extract_relay_common_config,
commands::test_relay_profile,
commands::test_stepwise_settings,
commands::fetch_relay_profile_models,
commands::switch_relay_profile,
commands::apply_relay_injection,
Expand Down
123 changes: 123 additions & 0 deletions apps/codex-plus-manager/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ type BackendSettings = {
codexAppNativeMenuPlacement: boolean;
codexAppNativeMenuLocalization: boolean;
codexAppServiceTierControls: boolean;
codexAppStepwiseEnabled: boolean;
codexAppStepwiseDirectSend: boolean;
codexAppStepwiseBaseUrl: string;
codexAppStepwiseApiKey: string;
codexAppStepwiseApiKeyEnv: string;
codexAppStepwiseModel: string;
codexAppStepwiseMaxItems: number;
codexAppStepwiseMaxInputChars: number;
codexAppStepwiseMaxOutputTokens: number;
codexAppStepwiseTimeoutMs: number;
codexAppImageOverlayEnabled: boolean;
codexAppImageOverlayPath: string;
codexAppImageOverlayOpacity: number;
Expand Down Expand Up @@ -372,6 +382,11 @@ type RelayProfileTestResult = CommandResult<{
responsePreview: string;
}>;

type StepwiseTestResult = CommandResult<{
itemCount: number;
error: string;
}>;

type RelayProfileModelsResult = CommandResult<{
models: string[];
endpoint: string;
Expand Down Expand Up @@ -640,6 +655,16 @@ const defaultSettings: BackendSettings = {
codexAppNativeMenuPlacement: true,
codexAppNativeMenuLocalization: true,
codexAppServiceTierControls: false,
codexAppStepwiseEnabled: false,
codexAppStepwiseDirectSend: false,
codexAppStepwiseBaseUrl: "",
codexAppStepwiseApiKey: "",
codexAppStepwiseApiKeyEnv: "CODEX_STEPWISE_API_KEY",
codexAppStepwiseModel: "",
codexAppStepwiseMaxItems: 6,
codexAppStepwiseMaxInputChars: 6000,
codexAppStepwiseMaxOutputTokens: 500,
codexAppStepwiseTimeoutMs: 8000,
codexAppImageOverlayEnabled: false,
codexAppImageOverlayPath: "",
codexAppImageOverlayOpacity: 35,
Expand Down Expand Up @@ -1498,6 +1523,11 @@ export function App() {
if (result) showNotice("供应商测试", result.message, result.status);
};

const testStepwiseSettings = async (settings: BackendSettings) => {
const result = await run(() => call<StepwiseTestResult>("test_stepwise_settings", { settings }));
if (result) showNotice("Stepwise 测试", result.message, result.status);
};

const fetchRelayProfileModels = async (profile: RelayProfile) => {
const result = await run(() => call<RelayProfileModelsResult>("fetch_relay_profile_models", { profile }));
if (result) showNotice("模型列表", result.message, result.status);
Expand Down Expand Up @@ -1853,6 +1883,7 @@ export function App() {
deleteContextEntry,
extractRelayCommonConfig,
testRelayProfile,
testStepwiseSettings,
fetchRelayProfileModels,
switchRelayProfile,
relaySwitching,
Expand Down Expand Up @@ -2125,6 +2156,7 @@ type Actions = {
deleteContextEntry: (settings: BackendSettings, kind: ContextKind, id: string) => Promise<BackendSettings | null>;
extractRelayCommonConfig: (configContents: string) => Promise<ExtractRelayCommonConfigResult | null>;
testRelayProfile: (profile: RelayProfile) => Promise<void>;
testStepwiseSettings: (settings: BackendSettings) => Promise<void>;
fetchRelayProfileModels: (profile: RelayProfile) => Promise<string[] | null>;
switchRelayProfile: (settings: BackendSettings, previousActiveRelayId?: string) => Promise<void>;
relaySwitching: boolean;
Expand Down Expand Up @@ -2515,6 +2547,8 @@ function EnhanceScreen({
<FeatureToggle title="插件列表全量展示" detail="进入插件页后自动连续展开“更多”,尽量一次显示完整插件列表。" checked={form.codexAppPluginAutoExpand} disabled={!masterEnabled} onChange={(value) => setEnhanceFlag("codexAppPluginAutoExpand", value)} />
<FeatureToggle title="模型白名单解锁" detail="从环境变量和 config.toml 的 /v1/models 拉取模型并补进模型列表。" checked={form.codexAppModelWhitelistUnlock} disabled={!masterEnabled} onChange={(value) => setEnhanceFlag("codexAppModelWhitelistUnlock", value)} />
<FeatureToggle title="Fast 按钮" detail="显示服务模式切换按钮;Fast 仅支持 gpt-5.4 / gpt-5.5,其他模型按 Standard 发送。" checked={form.codexAppServiceTierControls} disabled={!masterEnabled} onChange={(value) => setEnhanceFlag("codexAppServiceTierControls", value)} />
<FeatureToggle title="Stepwise" detail="在 Codex 页面显示可拖动的后续建议浮层;建议由单独配置的 Stepwise API 生成。" checked={form.codexAppStepwiseEnabled} disabled={!masterEnabled} onChange={(value) => setEnhanceFlag("codexAppStepwiseEnabled", value)} />
<FeatureToggle title="Stepwise 直接发送" detail="点击建议后自动发送;关闭时只填入输入框。" checked={form.codexAppStepwiseDirectSend} disabled={!masterEnabled || !form.codexAppStepwiseEnabled} onChange={(value) => setEnhanceFlag("codexAppStepwiseDirectSend", value)} />
<FeatureToggle title="会话删除" detail="在会话列表悬停显示删除按钮,并支持撤销。" checked={form.codexAppSessionDelete} disabled={!masterEnabled} onChange={(value) => setEnhanceFlag("codexAppSessionDelete", value)} />
<FeatureToggle title="Markdown 导出" detail="在会话列表显示导出按钮,导出带时间戳的 Markdown。" checked={form.codexAppMarkdownExport} disabled={!masterEnabled} onChange={(value) => setEnhanceFlag("codexAppMarkdownExport", value)} />
<FeatureToggle title="粘贴修复" detail="从 Word 等富文本粘贴到 Codex composer 时只保留纯文本,避免被识别为图片/文件附件。需重启 Codex 才生效。" checked={form.codexAppPasteFix} disabled={!masterEnabled} onChange={(value) => setEnhanceFlag("codexAppPasteFix", value)} />
Expand Down Expand Up @@ -3254,6 +3288,91 @@ function SettingsScreen({
onChange={(event) => onFormChange({ ...form, cliWrapperApiKey: event.currentTarget.value })}
/>
</Field>
<div className="settings-block stepwise-settings-block">
<div className="section-title">Stepwise</div>
<div className="stepwise-settings-section">连接</div>
<div className="form-row">
<Field label="Base URL">
<Input
value={form.codexAppStepwiseBaseUrl}
onChange={(event) => onFormChange({ ...form, codexAppStepwiseBaseUrl: event.currentTarget.value })}
placeholder="https://api.example.com/v1"
/>
</Field>
<Field label="Model">
<Input
value={form.codexAppStepwiseModel}
onChange={(event) => onFormChange({ ...form, codexAppStepwiseModel: event.currentTarget.value })}
placeholder="例如 gpt-5.4-mini"
/>
</Field>
</div>
<Field label="API Key">
<Input
type="password"
value={form.codexAppStepwiseApiKey}
onChange={(event) => onFormChange({ ...form, codexAppStepwiseApiKey: event.currentTarget.value })}
/>
</Field>
<details className="stepwise-advanced">
<summary>高级参数</summary>
<div className="form-row">
<Field label="API Key 环境变量">
<Input
value={form.codexAppStepwiseApiKeyEnv}
onChange={(event) => onFormChange({ ...form, codexAppStepwiseApiKeyEnv: event.currentTarget.value })}
/>
</Field>
<Field label="最多建议数">
<Input
max={6}
min={0}
type="number"
value={form.codexAppStepwiseMaxItems}
onChange={(event) =>
onFormChange({ ...form, codexAppStepwiseMaxItems: clampNumber(Number(event.currentTarget.value), 0, 6) })
}
/>
</Field>
</div>
<div className="form-row">
<Field label="超时毫秒">
<Input
min={1000}
type="number"
value={form.codexAppStepwiseTimeoutMs}
onChange={(event) =>
onFormChange({ ...form, codexAppStepwiseTimeoutMs: clampNumber(Number(event.currentTarget.value), 1000, 60000) })
}
/>
</Field>
<Field label="最大输入字符">
<Input
min={1000}
type="number"
value={form.codexAppStepwiseMaxInputChars}
onChange={(event) =>
onFormChange({ ...form, codexAppStepwiseMaxInputChars: clampNumber(Number(event.currentTarget.value), 1000, 24000) })
}
/>
</Field>
</div>
<Field label="最大输出 tokens">
<Input
min={100}
type="number"
value={form.codexAppStepwiseMaxOutputTokens}
onChange={(event) =>
onFormChange({ ...form, codexAppStepwiseMaxOutputTokens: clampNumber(Number(event.currentTarget.value), 100, 4000) })
}
/>
</Field>
</details>
<div className="toolbar stepwise-settings-actions">
<Button variant="secondary" onClick={() => void actions.testStepwiseSettings(form)}>测试连接</Button>
<Button onClick={() => void actions.saveSettings()}>保存设置</Button>
</div>
</div>
<div className="settings-block">
<label className="check-row">
<input
Expand Down Expand Up @@ -5626,6 +5745,10 @@ function normalizeSettings(settings: BackendSettings): BackendSettings {
relayProfilesEnabled: settings.relayProfilesEnabled !== false,
computerUseGuardEnabled: settings.computerUseGuardEnabled === true,
codexAppImageOverlayOpacity: clampNumber(settings.codexAppImageOverlayOpacity || 35, 1, 100),
codexAppStepwiseMaxItems: clampNumber(settings.codexAppStepwiseMaxItems ?? 6, 0, 6),
codexAppStepwiseMaxInputChars: clampNumber(settings.codexAppStepwiseMaxInputChars || 6000, 1000, 24000),
codexAppStepwiseMaxOutputTokens: clampNumber(settings.codexAppStepwiseMaxOutputTokens || 500, 100, 4000),
codexAppStepwiseTimeoutMs: clampNumber(settings.codexAppStepwiseTimeoutMs || 8000, 1000, 60000),
relayCommonConfigContents,
relayContextConfigContents,
relayProfiles: profiles,
Expand Down
55 changes: 55 additions & 0 deletions apps/codex-plus-manager/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,61 @@ body {
align-items: end;
}

.settings-block .section-title {
margin-bottom: 12px;
color: hsl(var(--foreground));
font-size: 13px;
font-weight: 700;
}

.stepwise-settings-block .form-row {
grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stepwise-settings-section {
margin: -4px 0 12px;
color: hsl(var(--muted-foreground));
font-size: 12px;
font-weight: 700;
}

.stepwise-advanced {
margin-top: 2px;
border-top: 1px solid hsl(var(--border));
}

.stepwise-advanced summary {
display: flex;
align-items: center;
min-height: 36px;
color: hsl(var(--muted-foreground));
cursor: pointer;
font-size: 12px;
font-weight: 700;
list-style: none;
}

.stepwise-advanced summary::-webkit-details-marker {
display: none;
}

.stepwise-advanced summary::after {
content: "›";
margin-left: 6px;
font-size: 15px;
transform: rotate(90deg);
transition: transform 120ms ease;
}

.stepwise-advanced[open] summary::after {
transform: rotate(270deg);
}

.stepwise-settings-actions {
justify-content: flex-end;
margin-top: 2px;
}

.settings-block .toolbar {
margin-top: 0;
margin-bottom: 12px;
Expand Down
Loading
Loading