Skip to content

fix(sync): defer reset_runtime_state until codex CLI recovery path is viable#60

Open
chdendi wants to merge 1 commit intotaptap:mainfrom
chdendi:fix/codex-plugins-reset-order
Open

fix(sync): defer reset_runtime_state until codex CLI recovery path is viable#60
chdendi wants to merge 1 commit intotaptap:mainfrom
chdendi:fix/codex-plugins-reset-order

Conversation

@chdendi
Copy link
Copy Markdown
Contributor

@chdendi chdendi commented May 7, 2026

Summary

  • ensure_remote_marketplace previously called reset_runtime_state() (which rm -rfs clone_path and cache_root) before verifying the recovery path was viable. In offline runs, on legacy Codex CLI versions, or when codex isn't on PATH at all, this destroyed the user's working clone/cache without being able to re-register the marketplace.
  • Reordered the function so the destructive reset only fires after both has_codex and resolve_marketplace_cli("add") succeed. The early-return paths now explicitly note that the existing clone/cache is preserved when state was abnormal but recovery is not currently possible.
  • Bumped plugins/sync to 0.1.31 (claude + codex plugin.json + marketplace entry) and marketplace.json metadata.version to 0.1.41 per .claude/rules/versioning.md.

Failure scenarios this fixes

State must be one of local_or_mismatched | broken_remote | unknown_clone to enter the affected branch. Previously, in that branch:

  1. Offline: add network call fails → clone/cache already gone, user has nothing until the next online session.
  2. Legacy Codex CLI: resolve_marketplace_cli("add") returns [] → function returns early, but clone/cache already deleted.
  3. codex not installed: function returns at the has_codex check, but clone/cache already deleted.

After this change, all three paths leave the existing clone/cache intact and surface a warning explaining the situation.

Test plan

  • bash tests/validate.sh passes locally (all checks PASS).
  • Manual: run on a host with codex offline; confirm existing clone is preserved and warning is printed.
  • Manual: run on a host without codex installed; confirm same behavior.

… viable

ensure_remote_marketplace previously deleted the existing clone_path and
cache_root before checking that codex CLI is available and supports
'marketplace add'. In offline runs, on legacy CLI versions, or when codex
is missing entirely, this destroyed a recoverable working state without
being able to re-register the marketplace.

Reorder so the destructive reset only fires after has_codex and
resolve_marketplace_cli('add') both succeed. The early-return paths now
explicitly note that the existing clone/cache is preserved when the
state was abnormal but recovery is not currently possible.

Bump sync plugin to 0.1.31 and marketplace metadata to 0.1.41.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chdendi chdendi requested a review from em0t as a code owner May 7, 2026 10:46
@github-actions github-actions Bot added scope:plugins Changes one or more plugins. scope:sync Touches the sync plugin. kind:fix Fixes a bug or regression. size:s Small PR. and removed scope:plugins Changes one or more plugins. labels May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:fix Fixes a bug or regression. scope:sync Touches the sync plugin. size:s Small PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant