Skip to content

fix(claude): rebase hand-edit guard after desktop apply - #217

Closed
luvs01 wants to merge 5 commits into
devfrom
codex/propose-fix-for-claudecode-baseline-issue
Closed

luvs01 wants to merge 5 commits into
devfrom
codex/propose-fix-for-claudecode-baseline-issue

Conversation

@luvs01

@luvs01 luvs01 commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A field-scoped persistence path for Claude Desktop wrote claudeCode.desktopProfile to disk but did not refresh the in-memory Claude baseline, which could cause later whole-config saves to silently overwrite operator hand-edited security/routing fields under claudeCode.

Description

  • Add adoptPersistedClaudeCode(config, persistedClaudeCode) in src/config.ts to mirror the exact committed claudeCode subtree into the long-lived in-memory snapshot and rebase the hand-edit baseline.
  • Change persistDesktopProfileField in src/server/management/agent-settings-routes.ts to capture the committed claudeCode returned by mutatePersistedConfig() and call adoptPersistedClaudeCode() only after the durable write succeeds.
  • Add a regression test in tests/native-claude-desktop-toggle.test.ts that exercises apply → hand-edit on-disk claudeCode → unrelated saveConfigPreservingClaudeCode() and asserts the hand edit is preserved.

Testing

  • node_modules/@oven/bun-linux-x64-baseline/bin/bun test tests/native-claude-desktop-toggle.test.ts was run and the focused test file passed.
  • bun run typecheck was run and completed successfully.
  • bun run privacy:scan was run and completed successfully.
  • Running bun test tests/native-claude-desktop-toggle.test.ts with the environment-provided Bun initially failed due to an environment mismatch (node:zlib export zstdDecompressSync missing), which is an execution-platform issue and not a code regression; the repository-provided baseline Bun binary passed the focused tests, and the broader test run encountered unrelated existing timeouts/auth failures in other integration tests when executing the whole suite.

Codex Task


Devin Review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: luvs01/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 67483627-c2ee-4d29-8525-40f8dafb9d39


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8850f822d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config.ts Outdated
@github-actions github-actions Bot changed the title fix(claude): rebase hand-edit guard after desktop apply [WRONG BRANCH] fix(claude): rebase hand-edit guard after desktop apply Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

✅ READY

  • all PR quality gates passed.

Hygiene

Deterministic PR hygiene checks passed.

@github-actions
github-actions Bot marked this pull request as draft August 9, 2026 06:50
@luvs01 luvs01 closed this Aug 19, 2026
@luvs01 luvs01 reopened this Aug 19, 2026
@luvs01 luvs01 changed the title [WRONG BRANCH] fix(claude): rebase hand-edit guard after desktop apply fix(claude): rebase hand-edit guard after desktop apply Sep 3, 2026
@luvs01
luvs01 changed the base branch from main to dev September 3, 2026 06:25
@github-actions
github-actions Bot marked this pull request as ready for review September 3, 2026 06:34
devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: Epinephrine <luvs01@hanmail.net>
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration Bot and others added 2 commits September 21, 2026 01:20
…eCode into live-reconcile

The dev merge kept both the facade re-exports and ~660 lines of the
pre-split config.ts bodies, producing 30 duplicate exports and a Bun
SyntaxError (Cannot export a duplicate function name: 'websocketsEnabled')
that broke every bun run entrypoint, including linux-systemd service
install.

The branch-only adoptPersistedClaudeCode now lives in
src/config/live-reconcile.ts next to the baseline guards and also refreshes
liveConfigBaseline, matching adoptPersistedProviderIntoLiveConfig; the
facade re-exports it. src/config.ts stays at its 460-line cap.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
adoptPersistedClaudeCode replaced the live claudeCode subtree wholesale, so a
concurrent settings PUT that had assigned its subtree and yielded before saving
lost its mutation while still reporting success. Reconcile baseline, live, and
committed subtrees instead: pending live leaves win same-leaf conflicts and
disjoint committed changes merge in, matching the guarded-save policy.

persistDesktopModeField wrote claudeCode.desktopMode to disk and patched only
the live object, so first-party apply (which ends at the mode write) left the
armed hand-edit baseline stale; a later unrelated save then read both sides as
changed and kept the stale live subtree over the operator's hand edit. Return
the committed subtree from the mutation and run it through
adoptPersistedClaudeCode like the profile-field writer does.

Regression tests: a scoped write keeps a pending live Claude edit, and
first-party apply -> hand edit -> unrelated save preserves the hand edit.

Co-Authored-By: Epinephrine <luvs01@hanmail.net>
@devin-ai-integration

Copy link
Copy Markdown

Resolved: persistDesktopModeField now returns the committed claudeCode subtree from mutatePersistedConfig and runs it through adoptPersistedClaudeCode after a committed or unchanged outcome, so the armed hand-edit baseline moves with the mode write (e76f464). Added a regression test: first-party apply → hand edit → unrelated saveConfigPreservingClaudeCode preserves the hand edit (tests/claude-integration/claude-desktop-first-party.test.ts).

@devin-ai-integration

Copy link
Copy Markdown

Resolved: adoptPersistedClaudeCode no longer replaces the live subtree wholesale — it three-way reconciles the armed baseline, the live subtree, and the committed subtree (e76f464). Pending live leaves win same-leaf conflicts and disjoint committed changes merge in, matching the guarded-save conflict policy, so a Claude settings request that yielded between assignment and save keeps its pending mutation. Regression test in tests/config/config-user-edits.test.ts.

@devin-ai-integration

Copy link
Copy Markdown

Resolved (same issue as the Devin Review thread): adoptPersistedClaudeCode now three-way reconciles the old baseline, live subtree, and committed subtree (e76f464) — pending live leaves win same-leaf conflicts, so the concurrent PUT /api/claude-code mutation survives the adoption and reaches its save.

@luvs01

luvs01 commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

Closing: superseded by combined PR #612, which carries this PR's hand-edit guard rebase after desktop apply (�doptPersistedClaudeCode) together with the auto-refresh preservation and async probe on current dev. Combined tests: 91 pass (4 baseline-identical timeouts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant