Skip to content

fix(cli): coalesce overlapping history refreshes - #563

Open
Dante-dan wants to merge 2 commits into
LodyAI:mainfrom
Dante-dan:fix/553-coalesce-history-refresh
Open

fix(cli): coalesce overlapping history refreshes#563
Dante-dan wants to merge 2 commits into
LodyAI:mainfrom
Dante-dan:fix/553-coalesce-history-refresh

Conversation

@Dante-dan

Copy link
Copy Markdown

Related issue

Closes #553

Problem / pressure

Opening an imported conversation can trigger overlapping refresh effects from separate renderer lifecycles. The CLI currently protects the local project with a fail-fast process lease, so the second equivalent request surfaces history sync is already running even though the first request is already doing the required work.

Summary

Replace the fail-fast lease with a process-local per-project coordinator. Equivalent catalog, import, or conflict-resolution requests share the in-flight result; distinct operations or targets wait for the project's current operation. Request cleanup runs after success or failure, so later refreshes execute normally and genuine provider or persistence failures still reach callers.

The import request identity normalizes duplicate and reordered ACP session IDs while retaining the original first caller's execution inputs. Replay comparison, catalog persistence, and conflict-resolution rules are unchanged.

Visual explanation

flowchart TD
  A[History request] --> B{Equivalent request active?}
  B -- yes --> C[Return its result or error]
  B -- no --> D[Wait for local-project tail]
  D --> E[Run existing sync/import/resolve implementation]
  E --> F[Publish result or error]
  F --> G[Remove request and idle coordinator]
Loading

Before / after

Before After
Any overlapping project history operation throws a synthetic already-running error. Equivalent requests reuse one result; different requests execute in order.
The lease is removed in finally, but callers cannot join work already in progress. Success and failure both clean the request map, allowing a fresh retry or refresh.

Test plan

  • corepack pnpm --filter lody exec vitest run tests/local-project-history-sync-service.test.ts — 33 tests passed.
  • corepack pnpm --filter lody run typecheck — passed.
  • corepack pnpm format — passed; an unrelated pre-existing formatting difference was excluded from this PR.
  • corepack pnpm run docs check — passed with existing Agent instruction size and translation warnings.
  • corepack pnpm check — passed, including repository typechecks, lint, test suites, i18n, and boundary guards.

Context handoff

Instructions for reviewing agents

  • Review focus: Inspect the coordinator lifecycle and request keys in local-project-history-sync-service.ts, especially cleanup ordering after rejection.
  • Decisions to challenge: Confirm that reordered import session IDs are semantically equivalent and that distinct operations should serialize per provider/project.
  • Plausible failures / evidence gaps: Coordination is intentionally process-local; renderer remount timing and real provider/filesystem I/O were not reproduced in an installed desktop build.

Authoring context

  • User goal / directives: Fix issue [Bug] 打开已导入会话时自动刷新请求重叠,报 history sync is already running #553 so automatic refreshes triggered while opening imported Codex conversations do not fail when they overlap.
  • Constraints / non-goals: Keep existing import, replay comparison, conflict, persistence, and cross-process behavior unchanged; do not broaden into PR fix(cli): support custom ACP history synchronization #335's custom ACP launch work.
  • Risk-bearing decisions: The coordinator shares both successful results and genuine failures for an exact request identity, while different identities wait on a failure-tolerant tail.
  • Destructive or irreversible behavior: The change adds no deletion, migration, or overwrite path; existing inner operations remain responsible for their writes, and cleanup only removes in-memory coordination entries.
  • Deliberately not done or tested: No renderer component change or time-based/network test was added because the defect is at the shared CLI boundary and deferred promises expose its ordering directly.
  • Unknowns / confidence: Confidence is high from deterministic service coverage and the full repository check; coordination between separate CLI processes remains outside this change.

Replace the project-wide fail-fast lease with request coalescing and ordered execution so renderer remounts do not surface a synthetic sync error.

Model: gpt-5.6-sol
@Dante-dan
Dante-dan marked this pull request as ready for review September 10, 2026 02:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-10T02:07:44.158615Z d72e701 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 打开已导入会话时自动刷新请求重叠,报 history sync is already running

1 participant