Skip to content

fix: 保留 Claude profile 用户字段 + 消除 powershell 弹窗 + 修复开机自启 - #36

Closed
zhushihao wants to merge 94 commits into
BigStrongSun:mainfrom
zhushihao:fix/preserve-user-extras
Closed

fix: 保留 Claude profile 用户字段 + 消除 powershell 弹窗 + 修复开机自启#36
zhushihao wants to merge 94 commits into
BigStrongSun:mainfrom
zhushihao:fix/preserve-user-extras

Conversation

@zhushihao

@zhushihao zhushihao commented Aug 8, 2026

Copy link
Copy Markdown

概述

本 PR 合并四项修复(对应 issue #35 / #38 / #40 / #41),均在 fork 分支 fix/preserve-user-extras 上完成并打包验证:

  1. 顶层非托管字段保留(autoModeEnabled 等)
  2. per-model 的 prefer1m(Default to 1M context)保留
  3. powershell 探测弹窗一闪一闪(CREATE_NO_WINDOW 缺失)
  4. 设置"开机自动启动"后重启系统未自动启动

修复 1:顶层非托管字段保留(issue #35

切换 Claude provider 时 cc-switch 全量重写 profile(configLibrary/*.json),用户手动添加的非托管字段(autoModeEnabled / toolSearchEnabled / inferenceCredentialKind)被覆盖丢失。

新增 preserve_user_profile_extras:写入 profile 前把现有 profile 中的非托管字段合并回来,只覆盖 cc-switch 托管的网关字段。

修复 2:per-model 的 prefer1m 保留(issue #38

顶层字段修复后,"Default to 1M context"(prefer1m)仍被覆盖——它是 inferenceModels 条目内的 per-model 字段,而 inferenceModels 数组是托管字段、应用 Provider 时按路由整体重建。

新增 preserve_inference_model_extras:按模型 name 匹配重建前后的 inferenceModels 条目,合并条目内未在新建条目中出现的用户字段(如 prefer1m);托管字段(labelOverride、supports1m)仍按路由更新。

提交:0fd46f7d

修复 3:powershell 周期性弹窗(issue #40

Codex 守护每 3 秒 spawn 一次 powershell 探测 Codex/ChatGPT 主进程(detect_running_codex_main_process),spawn 未加 CREATE_NO_WINDOW,Windows 给子进程分配可见控制台窗口 → 桌面一直一闪一闪。

给三处 powershell 探测补 .creation_flags(CREATE_NO_WINDOW)0x08000000)——codex_desktop.rs 两处 + commands/proxy.rs 一处,与 codex_history_migration.rs 既有写法一致。

提交:bb7d8dee

修复 4:开机自启重启失效(issue #41

auto-launch 0.5.0 的 Windows 实现有两处缺陷:

  1. enable()HKCU\...\CurrentVersion\Run 值时路径不加引号,装在含空格路径(如 Program Files)时登录按空格截断,启动失败;
  2. disable() 只删 Run 值、不清除 StartupApproved\Run 覆盖项,残留假启用状态(Run 无值但 StartupApproved 仍显示 enabled)。

修复:Windows 分支绕过 auto-launch crate,用 winreg 直接操作注册表——

  • 开启:写引号包裹的 exe 路径 + 同步写 StartupApproved enabled 标记;
  • 关闭:删 Run 值 + 清 StartupApproved 覆盖项;
  • 状态查询:严格校验 Run 值等于当前 exe 路径,避免残留旧路径误报。

macOS/Linux 继续用 auto-launch crate。

提交:dbfe6273

测试

  • claude_desktop_apply_preserves_user_profile_extra_fields:顶层字段回归。
  • claude_desktop_apply_preserves_per_model_1m_preference:per-model prefer1m 回归——应用 Provider → 注入 prefer1m: true → 重新应用 → prefer1m 保留 + 托管字段仍按路由更新。
  • cargo check --lib 通过(仅既有 openai_cache_read_tokens unused 警告)。

验证包

fork release:v3.19.1-15(prefer1m + powershell)与 v3.19.1-16(自启),GitHub Actions 构建 Windows x64/arm64 + macOS + Linux。

变更文件

  • src-tauri/src/claude_desktop_config.rs(保留逻辑 + 测试)
  • src-tauri/src/codex_desktop.rs(CREATE_NO_WINDOW ×2)
  • src-tauri/src/commands/proxy.rs(CREATE_NO_WINDOW ×1)
  • src-tauri/src/auto_launch.rs(winreg 重写 Windows 自启逻辑 + 测试)

BigStrongSun and others added 30 commits August 3, 2026 18:36
Document the confirmed constraints that reasoning must stream live, remain solely in Codex history, and survive a full return to the built-in OpenAI WebSocket path without CCSM runtime participation.

Specify a provider-scoped, stateless raw-reasoning-to-summary response bridge plus request-side reversal, including strict official-route isolation, item lifecycle preservation, no conversation persistence, TDD coverage, live DeepSeek-to-official-to-DeepSeek acceptance, and a stop condition if the private backend rejects long summaries or pairing.

Record the architecture and unresolved protocol risks in project memory so later debugging does not repeat the discarded proxy shim, sidecar storage, or destructive rollout migration proposals.

本次提交由BigStrongsSun完成
Remove the Markdown trailing whitespace and final redundant blank line detected after the design commit so the branch returns to a clean diff-check baseline before implementation planning.

本次提交由BigStrongsSun完成
Document the TDD sequence for provider opt-in, stateless JSON and SSE conversion, reversible request restoration, direct official WebSocket validation, privacy checks, rollback, and final review. The plan keeps existing polluted rollouts out of scope and requires a real DeepSeek to official to DeepSeek acceptance run before declaring compatibility. 本次提交由BigStrongsSun完成
- reuse the configured HTTP/SOCKS proxy for all Tauri updater checks and downloads\n- consolidate remaining product and recovery links on CCSwitchMulti\n- prepare the 3.19.1-3 update with release notes and regression coverage\n\n本次提交由BigStrongsSun完成
- add bounded native Responses reconnection with scaffold dedup and keepalive comments\n- wire same-request reconnect factories into native Codex passthrough only\n- preserve no-replay boundary after output items, tools, deltas, and terminal events\n- release as v3.19.1-4 with plan, notes, and project memory\n\n本次提交由BigStrongsSun完成
Record the evidence that session 019fbd59 reached official Responses with valid encrypted history, while failures began only after request body growth to roughly 16.8 MB and were transport-stage errors.\n\n本次提交由BigStrongsSun完成
Trace evidence shows official Codex requests through CCSM fail before headers far more often than other routes, but encrypted history and body size are not sufficient causes. Preserve the sanitized reqwest source chain after stripping URLs so the next failure identifies the actual transport layer without logging prompts or credentials. Correct the project root-cause record to distinguish proven evidence from pending validation.

本次提交由BigStrongsSun完成
Correlate the native OpenAI Bad Request turn with the earlier CCSM 16.8 MB request failures. Record that post-compaction custom tool outputs contain 15.7 MB of inline data-image payloads while encrypted data is only 0.08 MB, and trace the Codex source path that preserves supported images into every retry. Document the official issue cross-check and the schema-safe repair boundary.

本次提交由BigStrongsSun完成
Replace the overbroad inline-image root-cause claim with field-level and counterfactual evidence from session 019fbd59. Record that the full Responses-Lite replay, including all images, encrypted reasoning, compaction, and tools, succeeds against the official endpoint in both plain and Zstd forms. Distinguish the transient official generic 400 from CCSM's confirmed Zstd-to-plain upstream expansion and preserve the remaining OpenAI-internal uncertainty by request ID.

本次提交由BigStrongsSun完成
Root cause: CCSM decoded native Codex Zstd bodies for routing, then forwarded the final official Responses request as expanded plaintext. The observed request grew from about 10.87 MB on the native wire to 16.79 MB through reqwest, materially increasing pre-status timeouts and disconnects.

Recompress only native Codex POST requests to official ChatGPT Responses/compact endpoints after all JSON transformations. Keep third-party and protocol-transformed routes unchanged; apply the same encoding boundary to Responses-Lite fallback retries so headers always match the transmitted bytes.

Verification: 137 forwarder tests and 9 content-encoding tests passed; cargo check, rustfmt check, and git diff check passed. Project memory records the corrected root-cause boundary and implementation evidence.

本次提交由BigStrongsSun完成
Record the verified regression from v3.16.5-22: managed provider projection later forced Codex stream_max_retries from its default five attempts to zero, leaving no recovery owner after semantic output.

Choose an explicit two-layer design: CCSM keeps transparent retry before semantic output, while Codex regains ownership of post-semantic sampling retry. Include the TDD, documentation, and verification steps without adding proxy-side event replay.

本次提交由BigStrongsSun完成
Regression: v3.16.5-22 inherited Codex's default five stream retries, but 72c8ca2 later projected stream_max_retries=0 for every managed provider. Once CCSM crossed its semantic-output replay boundary, neither layer owned recovery and the turn terminated.

Restore stream_max_retries=5 while keeping request_max_retries=2. CCSM still reconnects only before semantic output; incomplete streams after text, reasoning, or tool events are returned to Codex so its session-aware sampling retry handles them.

TDD evidence: the new contract test first failed with left=0/right=5, then passed. All 114 codex_config tests and 75 services::proxy tests pass.

本次提交由BigStrongsSun完成
Correct the prior overbroad claim that managed Codex stream retries must remain disabled. The proxy still never replays after semantic output, but Codex now retains its official five-attempt sampling retry because it owns session, turn, item, and tool state.

Record the v3.16.5-22 to 72c8ca2 regression, mark the older pre-semantic recovery plan as superseded only at the client retry boundary, and update the end-to-end Responses and Chat diagrams.

本次提交由BigStrongsSun完成
Accept upstream PR farion1231#6078 on the CCSwitchMulti v3.19.1-2 baseline. Windows Claude Desktop resolves its live configuration through LOCALAPPDATA rather than HOME, USERPROFILE, or CC_SWITCH_TEST_HOME, so integration tests must redirect LOCALAPPDATA into the isolated test home before switching fixture providers.

Validated with profile_roundtrip: 8 passed, 0 failed; real Claude Desktop configuration hashes remained unchanged during the isolated audit.

Original contribution by wanwan-doudou (upstream commit dfa3f8e).

本次提交由BigStrongsSun完成
Give every integration test process a distinct temporary home, redirect Windows LOCALAPPDATA through that root, and teach reset_test_fs to remove isolated AppData so stale Claude Desktop 3P profiles cannot leak between tests.

Add real filesystem safety regressions for LOCALAPPDATA projection, process-unique roots, and AppData cleanup. The new tests were observed failing on the missing behaviors, then passing after the minimal helper changes; removing the upstream redirect also makes the path regression fail against the real LOCALAPPDATA.

Record the farion1231#6077/farion1231#6078 root cause, validation boundary, and separate runtime-repair requirement in repository memory.

Validation: cargo test (2794 passed, 0 failed, 2 ignored plus all integration groups); support_safety 3/3; profile_roundtrip 8/8; pnpm typecheck; cargo fmt --check; git diff --check; real Claude Desktop config hashes unchanged.

本次提交由BigStrongsSun完成
Publish the accumulated Multi updater/link corrections, native Responses pre-semantic SSE recovery, official Codex Zstd wire restoration, and restoration of Codex-owned stream_max_retries=5.

Document the evidence-backed encrypted/image boundary, retry ownership, complete validation matrix, upgrade path, downloads, and the remaining non-retryable official error boundary. Bump package, Cargo, lockfile, and Tauri versions in sync.

本次提交由BigStrongsSun完成
Release verification found the preset inference regression expecting decimal 1,000,000 after upstream had already aligned the production preset with DeepSeek's exact 1,048,576-token catalog value.

Keep production behavior unchanged, update the stale assertion, and document the Vitest worktree-discovery and file-parallelism boundaries. RED was the exact 1,000,000 versus 1,048,576 failure; GREEN is the isolated root test at 5/5.

本次提交由BigStrongsSun完成
The WebDAV mock processes only one request per TCP socket but previously emitted HTTP/1.1 responses without a Connection header. Reqwest could therefore pool and reuse a socket the mock had already closed, causing nondeterministic request failures only in the complete test suite.\n\nDeclare Connection: close as required by RFC 9112, record the root cause in repository memory, and add the verified frontend suite count to the v3.19.1-5 release notes. The four-request WebDAV group now passes 20 consecutive serial repetitions.\n\n本次提交由BigStrongsSun完成
Record the completed v3.19.1-5 release-gate evidence after the WebDAV mock protocol correction: twenty consecutive four-case WebDAV repetitions and two complete serial Rust test runs, each with 2803 passing library tests and all integration targets green.\n\n本次提交由BigStrongsSun完成
Record the immutable release tag target, successful seven-job GitHub Actions run, nineteen published assets, Latest Release state, and the six signed updater platform entries verified from the remote latest.json manifest. This commit intentionally follows the release tag and does not move it.\n\n本次提交由BigStrongsSun完成
Document the root cause of the capture-provider poisoning: codex exec --ephemeral resume persisted temporary thread settings and synchronized them into state_5.sqlite despite the diagnostic provider existing only for the child process.

Record the backup-first byte-boundary recovery, coordinated single-row database restoration, exact hashes and lengths, Desktop idle-state proof, rollback path, and the rule that future request capture must use a disposable or forked session rather than a production session ID.

本次提交由BigStrongsSun完成
Add a regression that resolves a mixed MultiRouter request to an official target provider, materializes the retry attempt, and requires the cross-provider V2 plaintext delivery policy to remain active. The test currently fails at the policy predicate, matching the live 0.146.0-alpha.9.2 child rollouts where spawn_agent.message became encrypted_content and Qwen reported an empty payload.

本次提交由BigStrongsSun完成
Root cause: the retry-layer route resolution introduced on August 3 materializes a mixed MultiRouter route into its target provider before forward(), while the August 1 collaboration rewrite still inferred policy from the outer codexRouting object. Target materialization preserved parent identity but discarded that transport decision, so official parents kept message.encrypted and third-party children received only an encrypted_content block.

Snapshot the mixed-router plaintext V2 policy into request-local route metadata and preserve it through target-provider materialization. The final rewrite remains constrained to Codex official OAuth requests, leaving all-official routers, third-party outbound requests, disabled routes, and unrelated encrypted parameters unchanged.

Record the live Codex 0.146 reproduction, regression boundary, and required post-install verification in repository memory.

本次提交由BigStrongsSun完成
Add a regression case matching Codex 0.146 Multi-Agent V2 namespace tools. The test proves the existing plaintext policy skips collaboration functions nested under a namespace while preserving unrelated functions, namespaces, and private encrypted properties.

本次提交由BigStrongsSun完成
Teach the mixed-MultiRouter plaintext transport policy to enter Codex 0.146 type=namespace collaboration tool containers before applying the existing spawn_agent/send_message/followup_task allowlist. Preserve non-collaboration namespaces, ordinary tools, private encrypted properties, all-official routers, and third-party outbound behavior. Record the two-layer route-materialization plus nested-schema root cause and validation boundary in repository memory.

本次提交由BigStrongsSun完成
Document the session evidence, the three-stage conversion failure, upstream/fork ownership, and the role-aware repair boundary. No production source, configuration, session, or database is changed.

本次提交由BigStrongsSun完成
Specify the root cause, tool-preserving Chat projection, role-aware null boundary, TDD coverage, and upstream Issue/PR delivery scope.

本次提交由BigStrongsSun完成
Define the TDD sequence for preserving input additional_tools, preventing invalid non-assistant null content, validating the fork, and preparing a clean upstream contribution.\n\nDocument the worktree, sanitization, verification, and GitHub delivery boundaries so the fix remains reviewable and does not mix fork-only changes.\n\n本次提交由BigStrongsSun完成
Add real Responses-to-Chat regression coverage showing that input additional_tools are dropped and misprojected as messages.\n\nLock custom and namespace conversion, cross-source deduplication, non-assistant missing/null content normalization, and the legal assistant tool-call null exception before changing production behavior.\n\nRED evidence: both additional-tools tests and the role-aware null-content test fail against the inherited v3.19.1 conversion path.\n\n本次提交由BigStrongsSun完成
Collect input additional_tools recursively into the existing CodexToolContext so function, custom, namespace, hosted, and tool-search conversion share one normalization and deduplication path.

Consume additional_tools as structural request metadata instead of treating its developer role as a message. Normalize missing or explicit null content to an empty string for non-assistant messages while preserving legal assistant tool-call content:null.

Verification: the three RED regressions now pass, and all 122 transform_codex_chat tests pass.

本次提交由BigStrongsSun完成
cc-switch 切换 Claude provider 时全量重写 configLibrary profile,
用户手动加的字段(如 autoModeEnabled / toolSearchEnabled / prefer1m /
inferenceCredentialKind)不在托管字段列表,会被覆盖丢失。

新增 preserve_user_profile_extras: 写入前合并现有 profile 中
非托管字段回来,只覆盖 cc-switch 托管的网关字段。

含回归测试 claude_desktop_apply_preserves_user_profile_extra_fields。
@zhushihao
zhushihao force-pushed the fix/preserve-user-extras branch from e36ddc1 to e48510f Compare August 8, 2026 03:38
@github-actions github-actions Bot added documentation Improvements or additions to documentation proxy frontend dependencies labels Aug 8, 2026
zhushihao and others added 2 commits August 8, 2026 12:32
上一修复只做顶层合并;inferenceModels 是托管键,切换 provider 时整组
按路由重建,条目内用户字段(如 Claude Desktop「Default to 1M context」
写入的 prefer1m)仍会被覆盖丢失。

新增 preserve_inference_model_extras:重建时按 name 匹配既有条目,
并回新条目中没有的字段。含回归测试
claude_desktop_apply_preserves_per_model_1m_preference。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zhushihao

Copy link
Copy Markdown
Author

补充修复:上一版只做顶层合并,inferenceModels 是托管键,切换时整组按路由重建,条目内用户字段(Claude Desktop「Default to 1M context」写入的 prefer1m)仍被覆盖。

新增 preserve_inference_model_extras:重建 inferenceModels 时按 name 匹配既有条目,并回新条目中没有的字段。含回归测试 claude_desktop_apply_preserves_per_model_1m_preference

测试:claude_desktop_config 模块 25 项通过,cargo fmt --check 通过。

包含 prefer1m(Default to 1M context)per-model 保留修复(0fd46f7d),
fork 分支 fix/preserve-user-extras 上发布验证。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
zhushihao and others added 2 commits August 8, 2026 20:11
Codex guardian 每 3 秒 spawn powershell 探测进程(detect_running_codex_main_process),
未加 CREATE_NO_WINDOW 导致每 3 秒弹一个可见 powershell 窗口一闪一闪。
补齐 codex_desktop.rs 两处 + commands/proxy.rs 一处;与 codex_history_migration.rs
既有写法一致(const CREATE_NO_WINDOW = 0x08000000)。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
包含 prefer1m per-model 保留修复(0fd46f7d)与 powershell 弹窗修复(bb7d8dee),
fork 分支 fix/preserve-user-extras 上发布验证。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zhushihao zhushihao changed the title fix: 切换 provider 重写 Claude profile 时保留用户非托管字段(autoModeEnabled 等) fix: 切换 provider 保留 Claude profile 用户字段 + 消除 powershell 周期性弹窗 Aug 8, 2026
zhushihao and others added 2 commits August 8, 2026 21:42
auto-launch 0.5.0 的 Windows 实现有两处缺陷导致"设置开机自启后重启不生效":
1. enable() 写 Run 值时路径不加引号,装在含空格路径(如 Program Files)时登录按空格截断;
2. disable() 只删 Run 值、不清除 StartupApproved 覆盖项,残留假启用状态。

改为 Windows 分支直接用 winreg 操作注册表,绕开 crate:
- enable() 写引号包裹的 exe 路径,并写 StartupApproved enabled 标记;
- disable() 同步清理 Run 值与 StartupApproved,消除假状态;
- is_enabled() 严格校验 Run 值等于当前 exe 路径。

macOS/Linux 继续用 auto-launch crate。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zhushihao zhushihao changed the title fix: 切换 provider 保留 Claude profile 用户字段 + 消除 powershell 周期性弹窗 fix: 保留 Claude profile 用户字段 + 消除 powershell 弹窗 + 修复开机自启 Aug 8, 2026
BigStrongSun added a commit that referenced this pull request Aug 8, 2026
记录原 PR 混入 94 个提交而不可直接合并的原因、四个相关贡献的取舍、三笔干净提交映射、Windows 自启状态语义修正、TDD 与定向验证证据,以及双链联网检索结果,避免后续重复审查或误合并旧历史。

本次提交由BigStrongsSun完成
@BigStrongSun

Copy link
Copy Markdown
Owner

感谢 @zhushihao 的贡献。我已按当前实际发布分支完成源码级审查和干净移植:

  • 顶层 Claude profile 用户字段保留已由当前线 b96c3a4c 独立实现,因此没有重复吸收 e48510fb
  • inferenceModels 每模型 prefer1m 已移植为 27ba2724
  • 三处后台 PowerShell CREATE_NO_WINDOW 已移植为 9482e057
  • Windows 自启注册表思路已移植并修正为 15770e31:除引用含空格 exe 路径、同步 Run/StartupApproved 外,还补了 Windows 路径大小写不敏感比较、Task Manager 禁用状态判断、注册表错误上抛和半配置回滚。

三笔代码提交都保留 Shawn Pro 为 Author,并记录原始提交来源。验证结果:Claude profile 25/25、自启 2/2、Codex 主进程探测 1/1、代理诊断 10/10,cargo check --lib、rustfmt、diff check 通过。

这个 PR 不能直接 merge:head 基于长期未更新的 main@f13fea48,相对 base 混入 94 commits / 53 files,还包含 release、Codex 路由、workflow、版本和历史冲突解决;直接合并会把旧历史带回当前发布线。接受的贡献已经推送到 bigstrongsun/fix-portable-third-party-reasoning@332c6a4d,因此这里按“已手工集成”关闭,不合并原 PR。

再次感谢定位和实现这些 Windows/Claude Desktop 问题。

BigStrongSun added a commit that referenced this pull request Aug 8, 2026
补记干净提交推送位置、审查评论 URL,以及 PR 已关闭但未合并的远端回读状态。

本次提交由BigStrongsSun完成
BigStrongSun added a commit that referenced this pull request Aug 8, 2026
同步 package.json、Cargo.toml、Cargo.lock 与 tauri.conf.json 的版本为 3.19.1-14,并新增中文发布说明。该版本发布 PR #36 的干净移植成果:Claude Desktop 每模型 prefer1m 保留、Windows 后台 PowerShell 隐藏窗口,以及修正后的开机自启注册表状态。发布候选已通过 Rust library 2828/0/2、前端 818/818、cargo check、rustfmt、TypeScript typecheck、Prettier 与 diff check。

本次提交由BigStrongsSun完成
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants