Skip to content

feat(sse): persist bounded resume cursors#912

Closed
luoye520ww wants to merge 4 commits into
KunAgent:developfrom
luoye520ww:codex/sse-cursor-storage
Closed

feat(sse): persist bounded resume cursors#912
luoye520ww wants to merge 4 commits into
KunAgent:developfrom
luoye520ww:codex/sse-cursor-storage

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 intentionally 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 scope.

Non-goals

  • No preload/IPC bridge changes.
  • No renderer subscription changes.
  • No automatic cursor restore yet; that is the 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
npm.cmd --prefix kun run typecheck

Both passed.

Tests

npm.cmd exec vitest run src/main/services/sse-resume-cursor-store.test.ts

Result: 1 file, 5 tests passed.

Also passed:

npm.cmd run lint
npm.cmd run build
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

Dependency

Depends on #911 (and its sequence/gap contracts in #902/#910).

Issue

Part of #885

@luoye520ww

Copy link
Copy Markdown
Collaborator Author

Closing this stacked version in favor of a clean develop-based PR; the cursor store does not depend on the earlier SSE implementation commits.

@luoye520ww luoye520ww closed this Jul 13, 2026
@luoye520ww
luoye520ww deleted the codex/sse-cursor-storage branch July 13, 2026 23:59
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