Skip to content

fix(server): restore feedback from closed immediate polls - #262

Closed
Julian-Dasilva wants to merge 2 commits into
kunchenguid:mainfrom
Julian-Dasilva:fm/lavish-upstream-229-fix2
Closed

fix(server): restore feedback from closed immediate polls#262
Julian-Dasilva wants to merge 2 commits into
kunchenguid:mainfrom
Julian-Dasilva:fm/lavish-upstream-229-fix2

Conversation

@Julian-Dasilva

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #261. Restore feedback consumed by a client that disconnects during the immediate poll take, so the next poll can receive it and presence does not remain stuck on working.

What changed

  • src/server.js: check request closure before immediate delivery; requeue closed feedback through queuePrompts and log if the restored batch is incomplete.
  • src/session-store.js: add an internal restore mode that preserves normalized prompts, layout-warning prompts, attachments, artifact failures, existing chat, and an already-ended session without creating duplicate chat records.
  • test/server.test.js: add a production-composition regression that pauses takeFeedback, destroys the request, and verifies waiting presence plus exact next-poll recovery.

Verification

  • npm test → 931 passed, 5 skipped, 0 failed.
  • npm run lint → passed.
  • npm run typecheck → passed.
  • Prettier on changed files → passed.
  • npm run check completed build and lint, then reported unrelated formatting failures in untracked .planning/telemetry/hook-metrics.json and existing test/fixtures/layout-audit/real-editorial.html.

Not covered / follow-ups

  • Optional real-browser suites were not run.
  • Greptile re-review was requested on PR 261.

Test plan

  • node --test --test-name-pattern "a disconnect during immediate feedback take requeues" test/server.test.js
  • npm test
  • npm run lint
  • npm run typecheck

Julian Alecssandre Dasilva and others added 2 commits August 19, 2026 21:59
Keep feedback actions durable while the agent is working, close poll cleanup races, and clear delivered state for final feedback on ended sessions.

Fixes kunchenguid#229
@Julian-Dasilva

Copy link
Copy Markdown
Contributor Author

Fix folded into #261; closing this overlapping follow-up PR.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Confidence Score: 3/5

The PR should not merge until armed-poll disconnects preserve consumed feedback and restoration can no longer overwrite newer queued metadata.

The immediate disconnect path is improved, but an equivalent disconnect during an armed poll still loses feedback and strands working presence, while a concurrent submission can have its newer snapshot and artifact failures replaced during restoration.

Files Needing Attention: src/server.js, src/session-store.js

Reviews (1): Last reviewed commit: "fix(server): restore feedback from close..." | Re-trigger Greptile

Comment thread src/server.js
Comment on lines 488 to +489
const result = await store.takeFeedback(key);
if (result.status === "feedback") markFeedbackDelivered(key, activePolls, deliveredFeedback, events);
finishFeedbackDelivery(key, result);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Armed poll loses feedback

When an attached long-poll client disconnects while store.takeFeedback(key) is in flight, respond() still marks the consumed batch delivered and writes it to the destroyed socket without restoring it, causing feedback loss and leaving presence stuck on working.

Comment thread src/session-store.js
Comment on lines +226 to 232
if (restoring) {
session.artifact_failures = Array.isArray(payload.artifact_failures)
? JSON.parse(JSON.stringify(payload.artifact_failures))
: [];
}
session.pending_prompts = session.prompts.length;
session.dom_snapshot = String(payload.domSnapshot || payload.dom_snapshot || "");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Restore overwrites newer metadata

If a new prompt submission completes after the disconnected poll's take but before restoration reacquires the store lock, restore mode appends the old prompts but replaces the newly queued artifact failures and DOM snapshot with older values, causing the next poll to receive stale or incomplete feedback metadata.

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