Skip to content

feat(sse): persist bounded resume cursors#913

Closed
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/sse-cursor-storage-clean
Closed

feat(sse): persist bounded resume cursors#913
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/sse-cursor-storage-clean

Conversation

@luoye520ww

Copy link
Copy Markdown
Collaborator

Problem

Renderer SSE acknowledgement state is currently in-memory. A renderer/runtime restart loses the last confirmed sequence and can replay an unnecessarily large thread window.

Root cause

There is no bounded, atomic persistence layer for per-scope resume cursors.

Scope

This PR adds only the shared cursor contract and a main-process persistence service. It is independent from IPC and renderer recovery wiring.

Changes

  • Add strict, versioned SseResumeCursor and file envelope schemas.
  • Persist at most 256 scopes with atomic writes and serialized mutations.
  • Reject same-generation cursor regressions.
  • Allow a new runtime generation to reset its sequence.
  • Keep malformed files untouched and fail open to authoritative replay.
  • Ignore storage entries whose key does not match their cursor scope.

Non-goals

  • No preload/IPC bridge changes.
  • No renderer subscription changes.
  • No automatic cursor restore yet; that is a follow-up integration PR.

Safety

  • Cursor data contains only bounded IDs, sequence numbers, generation metadata, and timestamps.
  • Writes use the existing atomic file helper.
  • Corrupt data is never overwritten automatically.
  • Entries are capped to prevent unbounded user-data growth.

Typecheck

npm.cmd run typecheck and npm.cmd --prefix kun run typecheck passed on the clean develop-based branch.

Tests

npm.cmd exec vitest run src/main/services/sse-resume-cursor-store.test.ts ? 1 file, 5 tests passed.

Also passed: git diff --check.

Review performed

  • Functional correctness
  • Concurrency and lifecycle
  • Data integrity and atomic writes
  • Corrupt-file and generation-boundary handling
  • Cross-platform path handling
  • PR scope and diff cleanliness

Issue

Part of #885

@luoye520ww

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated IPC/SSE reliability PR #945, which passed Typecheck, Linux, macOS, and Windows packaged checks. Closing this duplicate to keep the review surface focused.

@luoye520ww luoye520ww closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant