Skip to content

feat(pm-console): the app works with no connection, and sends what was done once when it is back - #13287

Merged
dezren39 merged 6 commits into
mainfrom
claude/pm-offline
Nov 23, 2026
Merged

dezren39 merged 6 commits into
mainfrom
claude/pm-offline

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

What

Step 4 of the plan in doc/2026-11-23T06-50-00Z_architecture_pm_platform_cloudflare_core/: the app works with no connection, in a browser and in the Android app (which is this site in Chrome).

Before this the app could not open offline, showed nothing, and lost whatever was done.

How it works

  • It opens. The service worker keeps the app's own files, fetched at install.
  • It shows what the device last saw. The worker asks the network first and keeps each good answer under the address it was asked for: the three documents and every screen's own read. A copy is shown only when the network gives no answer (or is too slow to wait for) and is marked as one; an answer that says no (a refusal, a way to the sign-in page, an error) is never replaced by a copy. No screen had to change, and a screen added later works offline from its first visit. The header says offline and how old; a line under it says there is no connection and what is kept.
  • What the owner does is kept and sent once. Every action gets a name on the device (a UUID) and is written to the browser's database before it is sent (public/outbox.js, one file for the page and the worker). With no connection it waits and is sent when there is one: by the page, or by the worker if the app is closed (Background Sync).
  • Once, however often it arrives. The edge writes down each name it did with its answer (a week, three hundred names); a machine keeps its own record (src/named.ts: one record for actions sent straight to it, relayed to it, and held for it). A name offered again is answered from the record, marked again.
  • What may have changed is not sent unasked. A prompt, reply, rank, note, bug or answer goes whenever it can. A merge, a deploy, a cancel, an unblock and a service action are kept, sent by themselves only within ten minutes, and after that wait under "kept back" for the owner to look again. A merge now names the commit the owner was shown, and GitHub merges only that. What sets the connection up or carries a secret (notifications, phones, sign-in, the Cloudflare switch) is never kept.
  • Signed out is told from offline by asking past the worker without following the way to the sign-in page.

More → On this device: what is waiting, kept back, could not be done, is with the platform for a machine, and was sent; each can be dropped, sent, or tried again. "Keep a copy of every screen now" reads every screen once, for before a flight. "Forget what it last saw" drops the copies; signing out does the same.

Also fixed on the way

  • A first load that failed said "Loading…" for ever instead of why (the error card was drawn and at once drawn over).
  • A toast's Undo button was written in the page's ink on the toast's green: unreadable in both themes. A test measures it now.

Checked

  • 342 tests under bun (was 278); the keeper's 25 unchanged.
  • 80 planted faults, all caught: 23 in the once-only rule on the edge and the laptop, 57 on the device (the outbox's rules, the worker, the app's wording).
  • A real Chrome, phone-sized, against the demo laptop and the demo edge, light and dark (27 checks each): taken offline the app opens, shows each screen it had seen and says it has no copy of one it had not, keeps a prompt, a rank and a merge across a reload, lets one be taken back, refuses to keep the Cloudflare switch, and when the connection is back sends each once; a repeat of each name is answered without being done again; a three-hour-old merge is kept back until confirmed; and it forgets when asked.
  • With the app closed: the worker, woken the way the browser wakes it (ServiceWorker.dispatchSyncEvent), sends what was kept, and the reopened app shows it sent.
  • axe-core over all 20 screens, the dialogs, the toasts, and the new screen in each of its states, light and dark: no violations.
  • The bundle in the real Worker runtime with the switch on: all checks passed. A test now fails if the three lists of the app's files (the laptop's, the edge's, the edge's build) disagree with what the page and the worker load.

Not checked

  • A real phone with no signal, and the Android app itself (nothing in it changed).
  • Background Sync outside Chrome (Safari and Firefox do not have it: there the page sends when it is next opened).

After review

Six findings, all real, and more of the same kinds found while fixing them. All in e4ab229e64.

Once under a name

  • A name is taken first, with nothing waited for in between, and what is known of it is read after, on the laptop and at the edge. Two arrivals under one name at the same moment used to both look, both find nothing, and both do it.
  • A held action being done on the laptop is marked as being done, so a device sending it again meanwhile is told to wait, not that the laptop restarted (which offered a retry under a new name).
  • The laptop's link had two methods called take; the second silently replaced the first, and the tests passed for the wrong reason. Renamed. The console's TypeScript is not type-checked anywhere: a check finds this at once, plus 53 smaller complaints, none a fault. Adding it to CI is the next PR.
  • The laptop's record of names is read once however many ask together, and written one write at a time, so a slow write cannot land over a later one.

In the order it was done

  • Something done now is written down and sent through the same oldest-first pass as what is waiting, never ahead of it. (A rank changed twice used to be able to end as the first.)
  • Two about the same thing keep their order to the end: while the earlier has not been taken (nothing could take it, or it is being done), the later one waits, on the device and in what the edge holds for a machine. What is about something else is not held up.
  • Each entry is read again just before it is sent, so "Do not send" during a send is honoured.

The worker

  • Asks to be woken again while anything still waits to be sent; on the browser's last call says what is left.
  • Keeps copies on a best effort: a full device, or a browser that gives the site no cache at all, still gets the network's answer, and the worker still installs.

Checked again: 40 planted faults in the new code, all caught (two more changed nothing: each is behind a second guard). In a real Chrome against both demos: the offline flow light and dark, the worker woken with the app closed, and a new check that an older waiting rank and a new one leave the device in order and are done in order (with the old direct send planted, that check fails). axe-core over 20 screens, dialogs and toasts: no violations. The Worker in its real runtime passes its own checks.

After the second review (9e252b2ccf), two more, both real:

  • A name keeps to the side that first took it. Which side does a kind can change (the edge is turned away for an hour, then takes it back); an action given to the laptop, its answer lost, and sent again after the change was done again by the edge. The edge now writes down a name it hands to a machine as given and looks a name up before choosing a side.
  • "Sent" means recorded. An answer to a question settled in the meantime comes back as a success that says "not recorded"; from what the device kept it was marked sent. It is now "could not be done", with why.

After the third review (c5c1a1db74), two more, both in the page:

  • An action is written down before it waits its turn to be sent. It used to wait in memory while another tab or the worker held the lock, and a page closed meanwhile lost it. One try at sending now has a one-minute limit.
  • A question is shown again when its kept answer is taken back. The list of questions answered here is worked out from the outbox, so it also survives a reload.

342 tests; 52 planted faults in the review fixes, all caught. Each of these two has a check in a real Chrome that fails against the code before its fix.

After the fourth review (bd1d03fb2a), three more:

  • What is being typed is kept through a send that finishes in the background: no forced redraw from under a field with the cursor in it, and the bug, note and message forms keep a draft across any redraw.
  • An answer whose body stops arriving part-way is no answer and is offered again; it was being read as "sign in again".
  • A failed answer reads the list of questions again whole, so its question cannot stay hidden.

Each has a check in a real Chrome that fails against the code before its fix.

Left out, and filed: #13398, an older action held for a machine against a newer one about the same thing that the edge does itself.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF


<a href="https://dashboardbackend.blacksmith.sh/track/run-proof?expires=1798030510&installation_model_id=443529&pr_number=13287&ref=codesmith_pr_footer&repository=developing-today%2Fcode&return_to=https%3A%2F%2Fgithub.com%2Fdeveloping-today%2Fcode%2Fpull%2F13287&variant=see_it_in_action&signature=85629cf6e4ddfc077f087e9374a91807b4a706b260743ff3eafd6aacbbd64b64"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-see-it-in-action-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-see-it-in-action-v2-light.svg"><img alt="See it in action" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-see-it-in-action-v2-dark-3x.png" width="132" height="28">
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Generated by Claude Code

…s done once when it is back

The app could not open without a connection, showed nothing, and lost
whatever was done. Now:

- It opens: the service worker keeps the app's own files.
- It shows what the device last saw: the worker keeps the last good
  answer to everything the app reads, under the address it was asked
  for. The network is asked first; a copy is shown only when it gives
  no answer or is too slow, and is marked as one. An answer that says
  no is never replaced by a copy. The header says offline and how old.
- What the owner does is kept and sent once. Every action gets a name
  on the device (a UUID) and is written to the browser's database
  before it is sent (public/outbox.js). With no connection it waits and
  is sent when there is one: by the page, or by the service worker if
  the app is closed (Background Sync).
- The platform does an action once under its name however often it
  arrives. The edge writes down each name it did with its answer; a
  machine keeps its own record (src/named.ts, one for actions sent
  straight to it, relayed to it, and held for it).
- What may have changed is not sent unasked: a merge, a deploy, a
  cancel, an unblock and a service action are sent by themselves only
  within ten minutes, and after that wait for the owner to look again.
  A merge names the commit the owner was shown, and GitHub merges only
  that. What sets the connection up or carries a secret is never kept.
- A sign-in that ran out is told from no connection.

More, On this device lists what is waiting, kept back, failed, with the
platform, and sent; and can fetch a copy of every screen before a
flight.

Also: a first load that failed said "Loading" for ever instead of why;
a toast's Undo was written in the page's ink, not the toast's.

321 tests under bun (was 278). 80 planted faults, all caught. In a real
Chrome against the demo laptop and the demo edge, light and dark: taken
offline it opens, shows, keeps, and sends each once; and with the app
closed the worker sends when woken.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 333b5764-c6af-4c4f-9406-de0e41532731
Commits

Reviewing files that changed from the base of the PR and between 4468cbb and bd1d03f.

Files selected for processing: 25

  • doc/2026-11-23T06-50-00Z_architecture_pm_platform_cloudflare_core/2026-11-23T06-50-00Z_architecture_pm_platform_cloudflare_core.md
  • pm-stack/console/README.md
  • pm-stack/console/edge/README.md
  • pm-stack/console/edge/build.mjs
  • pm-stack/console/edge/src/edge.ts
  • pm-stack/console/public/app.css
  • pm-stack/console/public/app.js
  • pm-stack/console/public/index.html
  • pm-stack/console/public/outbox.js
  • pm-stack/console/public/sw.js
  • pm-stack/console/scripts/demo-state.ts
  • pm-stack/console/scripts/edge-demo.ts
  • pm-stack/console/scripts/edge-smoke.ts
  • pm-stack/console/src/actions.ts
  • pm-stack/console/src/edge-proto.ts
  • pm-stack/console/src/named.ts
  • pm-stack/console/src/ops.ts
  • pm-stack/console/src/server.ts
  • pm-stack/console/src/sync.ts
  • pm-stack/console/test/app.test.ts
  • pm-stack/console/test/console.test.ts
  • pm-stack/console/test/edge.test.ts
  • pm-stack/console/test/outbox.test.ts
  • pm-stack/console/test/sw.test.ts
  • pm-stack/console/test/work.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T16:34:01.745897Z bd1d03f New commits
ℹ️ 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.

While an action was written down and not yet answered, a send of what
is waiting (the page's own, every twenty seconds, or the service
worker's) could take it for something left waiting and send it too.
The platform would still have done it once, under its name; the owner
would have been told twice. An action is now sent under the same lock.

Also: "Forget what it last saw" left its button disabled in a browser
with no worker.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4eba2ebb83

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pm-stack/console/src/server.ts Outdated
Comment on lines +418 to +419
const before = (await link?.seen?.(name)) ?? null;
if (before?.state === "running") return json({ error: "This is still being done.", running: true }, 409);

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 Badge Atomically claim action names before awaiting the audit write

When two requests with the same UUID arrive concurrently, both can observe seen(name) === null. Each then enters act(), which awaits the asynchronous audit write before reaching begin(name). Since Named.begin() does not reject an already claimed name, both requests proceed to perform(), duplicating external side effects such as comments or task moves. This affects direct host requests and independently forwarded edge relays. Make checking and claiming the name atomic before yielding to the audit operation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in e4ab229. The name is now taken first, with nothing waited for in between, and what is known of it is read after (Named.take, Named.known); the second arrival gets 409 running. The edge's once() does the same. Tests: two arrivals at the same moment on the laptop (with a slow audit write) and at the edge (with a slow storage read) are one doing.


Generated by Claude Code

Comment thread pm-stack/console/src/sync.ts Outdated
fate = { ok: false, error: "this is not an action that may be done late" };
} else {
await this.record(held.id, "started");
await this.named.record(held.id, "started");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Mark held actions as running in the shared name record

If a device retries an action while the host is executing its held copy, this call records "started" without adding the ID to Named.running. The newly shared record therefore makes Named.seen() report "lost", and the HTTP handler returns a terminal 502 claiming the host restarted even though the action is still executing. The device then marks the action failed and offers a retry under a new name, potentially repeating a successful operation. Use the running-state lifecycle (begin/end) for held execution too.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in e4ab229. Doing a held action takes the name before anything is read and gives it back after, like any other. Fixing it turned up that EdgeLink had two methods named take and the later one silently replaced the first; renamed. Test: a retry that reaches the laptop while the held copy is being done gets 409 running, and the outcome once it is over.


Generated by Claude Code

Comment thread pm-stack/console/public/sw.js Outdated
Comment on lines +209 to +210
// Still no connection: say so, and the browser will call again.
if (out.offline) throw new Error("still offline");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep background sync pending after retryable platform responses

With the app closed, a 503 response or 409 { running: true } leaves the action in waiting, but Outbox.flush() returns offline: false. Consequently send() resolves successfully here, consuming the Background Sync registration without arranging another attempt. For example, a timely action rejected because the laptop is temporarily unreachable will not be retried or marked stale until the app is opened again. Reject or re-register when retryable work remains, while treating sign-in and stale entries separately.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in e4ab229. flush now says how many entries still wait to be sent, and the worker rejects the sync while that is not zero (not when what waits needs a sign-in, and not for stale entries). On the browser's last call it also says what is left.


Generated by Claude Code

Comment thread pm-stack/console/public/sw.js Outdated
Comment on lines +104 to +106
if (res.status === 200) {
const copy = kind === "read" ? await stamped(res.clone(), { "x-pm-kept-at": String(Date.now()) }) : res.clone();
await cache.put(key, copy);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Return successful network responses even if caching fails

When Cache Storage rejects a write, such as when the device exhausts its storage quota, this awaited cache.put() rejects fromNetwork despite the fetch having succeeded. The response-selection logic then serves an old offline copy or rejects the request entirely if no copy exists, preventing healthy online reads of new screens. Make caching best-effort and return the successful network response independently of whether persistence succeeds.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in e4ab229. Keeping a copy is on a best effort: the network's answer is returned whether or not the write to the cache worked. Also handled: a browser that gives the site no cache at all (the worker installs and answers as if it kept nothing).


Generated by Claude Code

Comment on lines +199 to +201
let answer;
try {
answer = await send(entry);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor cancellations of queued entries during a flush

If a flush is waiting for action A's response and the owner selects “Do not send” for a later queued action B, the page removes B from IndexedDB, but this loop still sends B from the snapshot loaded at the start of the flush. It then writes B back with its outcome. This affects actions that had not even started sending when canceled, including merges and deploys. Coordinate cancellation with the sender and check that each queued entry still exists before starting its request.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in e4ab229. Each entry is read again from the store just before it is sent; one removed or dealt with meanwhile is skipped.


Generated by Claude Code

keeps = false;
}
}
const answer = await Outbox.httpSend(entry);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Send new actions through the ordered outbox

When older actions are waiting, this direct send lets a newly submitted action overtake them instead of following the flush's oldest-first ordering. For example, while a flush waits on an earlier request, the owner can successfully change an issue's rank to priority/high; the flush subsequently sends an older queued rank change for that same issue and overwrites the newer choice. Ops.setRank() applies the supplied rank and removes competing ranks, so the final state reflects the older action. Route queueable submissions through the same ordered sender rather than sending them independently.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in e4ab229. A new action is written down and sent through the same oldest-first pass as what is waiting (sendInOrder). Also added: two about the same thing keep their order while the earlier one has not been taken (503, or 409 running), on the device and in what the edge holds for a machine. One case is left and filed as #13398.


Generated by Claude Code

…orker that asks again

Review of the offline work found six faults; looking at them found
more of the same kinds.

Once under a name:
- A name is taken first, with no waiting in between, and what is known
  of it is read after (Named.take, known), on the laptop and at the
  edge. Two arrivals under one name at the same moment used to both
  look, both find nothing, and both do it.
- A held action being done on the laptop is marked as being done, so a
  device sending it again meanwhile is told to wait, not that the
  laptop restarted.
- The laptop's link had two methods called take; the second silently
  replaced the first. Renamed (the console is not type-checked yet).
- The record of names is read once however many ask together, and
  written one write at a time.

In the order it was done:
- Something done now is written down and sent through the same
  oldest-first pass as what is waiting (sendInOrder), not ahead of it.
- Two about the same thing keep their order: while the earlier one has
  not been taken, the later one waits, on the device and in what the
  edge holds for a machine (subject, subjectOf).
- Each entry is read again just before it is sent, so "do not send"
  during a send is honoured.

The worker:
- Asks to be woken again while anything still waits to be sent, and on
  the browser's last call says what is left.
- Keeps copies on a best effort: a full device, or a browser with no
  cache at all, still gets the network's answer, and the worker still
  installs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4ab229e64

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1542 to +1543
return await this.once(id, kind, () =>
this.directAct(kind, args as Record<string, unknown>, by, who.via, id),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve name ownership when switching execution sides

If an action succeeds but its response is lost, retrying its UUID after the execution route changes can repeat the external effect. For example, an issue.comment delegated to the host during the edge’s refusal cooldown is recorded only in the host’s Named ledger. Once that cooldown expires, a retry enters once() here, finds no edge a:<id> record, and posts the comment again. The reverse occurs when an edge-completed action is retried while its kind is delegated. Resolve existing names independently of the current route, or persist which side originally claimed each name.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 9e252b2. The edge now writes down a name it hands to a machine as given, and looks a name up before choosing a side: a name given to a machine goes to a machine again even after the edge takes the kind back, and a name the edge did is answered from its record even while the kind is handed over. Test: both directions, for a holdable kind and for a merge whose answer was lost.


Generated by Claude Code

Comment thread pm-stack/console/public/outbox.js Outdated
Comment on lines +168 to +171
if (status === 200 && body.ok === true) {
return body.held === true
? { state: "held", note: "Kept for the laptop, which will do it when it is back.", result: null }
: { state: "done", note: "", result: body.result ?? null };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Surface refused question answers during outbox replay

When a queued question answer is replayed after the question has already been answered, Work.submit() returns { applied: 0, refused: [...] } inside a successful HTTP response rather than throwing. This branch marks that entry done, so background replay reports it as sent and the device history never exposes why the answer was not recorded. The immediate sendAnswer() path checks result.refused, and heldRunner() explicitly treats these outcomes as failures, but neither check runs for device-outbox replay. Preserve and surface refused or partially applied outcomes instead of counting them as successful completions.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 9e252b2. classify treats a success whose result carries refused as failed, with the same words the laptop uses for one it does late ("Not recorded: …" or "N recorded, M not recorded: …"), so a replayed answer shows under "could not be done".


Generated by Claude Code

…nt" means recorded

Two findings from review of the last change, both real.

- Which side does a kind can change: the edge is turned away for an
  hour, then takes the kind back. An action given to the laptop, its
  answer lost, and sent again after the change was done again by the
  edge, which had no record of the name; and the other way about. The
  edge now writes down a name it hands to a machine as given, and
  looks a name up before choosing a side.
- An answer to a question settled in the meantime comes back as a
  success that says "not recorded". Sent from what the device kept, it
  was marked sent. It is now "could not be done", with why, as the
  laptop already says of one it does late.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e252b2ccf

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pm-stack/console/public/app.js Outdated
Comment on lines +339 to +340
const work = () => submitNow(entry);
return navigator.locks?.request ? navigator.locks.request("pm-outbox", work) : work();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Persist queueable actions before waiting for the send lock

When another page or the service worker is already sending a slow request, this waits for its pm-outbox lock before submitNow() reaches outbox.put(). Both flushOutbox() and the worker hold that lock throughout their HTTP requests, and Outbox.httpSend() has no timeout. Consequently, a newly submitted prompt, note, or answer remains only in memory while waiting; closing or reloading the page during that wait loses it even though IndexedDB is available. Persist queueable entries before waiting for the sender lock, and serialize only their sending.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in c5c1a1d. A queueable action is written to the outbox first, and only its sending waits for the lock; what is never kept (the "now" kinds) is sent without the lock. httpSend also has a one-minute limit now, so a request that hangs cannot hold the lock for every sender. Checked in a real Chrome: with the lock held by another sender, the action is already in IndexedDB, and after the page is reloaded it is sent once.


Generated by Claude Code

"div",
{ class: "row end" },
group.can.includes("drop")
? h("button", { class: "small ghost", onclick: () => after(() => outbox.remove(e.id)) }, group.state === "waiting" ? "Do not send" : "Discard")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore canceled answers to the open-question list

After answering a question offline, selecting “Do not send” removes the queued answer but leaves its key in answeredHere. sendAnswer() has already removed the question from the local document, and withoutAnswered() continues filtering it from subsequent server responses because the unanswered question is still open there. Consequently, canceling the answer leaves the question hidden for the remainder of the page session, even after reconnecting, so it cannot be answered again without reloading. Clear the optimistic answered state and restore or reload the question when its queued answer is canceled.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in c5c1a1d. The set of answered questions is now worked out from the outbox (answers waiting or held), not kept beside it: taking an answer back, or one that fails, brings the question back (the questions document is read again whole), and one still waiting stays out of the list after a reload. Checked in a real Chrome, and the check fails against the previous code.


Generated by Claude Code

…a question again when its answer is taken back

Two findings from review, both real, both in the page.

- An action was written down only once it held the turn to send. With
  another tab or the worker in the middle of a slow send, closing the
  page lost it. It is written down first, and only the sending waits.
  One try at sending is given a minute, so a request that hangs cannot
  hold every sender up.
- The page kept its own list of questions answered here, and "do not
  send" did not clear it: the question stayed hidden. The list is now
  worked out from what is kept, so a question is out of the list while
  its answer waits (across a reload too) and back when the answer is
  taken back or does not count.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5c1a1db74

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pm-stack/console/public/app.js Outdated
Comment on lines +727 to +729
sendingAnswers.delete(key);
}
if (out.state === "failed" || out.state === "refused") toast(out.note, true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore filtered questions when sending an answer fails

If a questions refresh returns a new document while an answer is being sent, withoutAnswered() removes that question using sendingAnswers. If the submission then fails, deleting this key does not restore the question: the failure branch only shows a toast and reloads core, while subsequent questions requests can return 304 and preserve the filtered document. The still-unanswered question consequently remains hidden until the server document changes or the page reloads. Restore it or invalidate and reload the questions document after clearing the sending key on failure.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in bd1d03f. When an answer fails, the questions document is read again whole (its tag is dropped first, so a 304 cannot keep the filtered copy). Checked in a real Chrome with the list read while the answer was on its way; the check fails against the previous code.


Generated by Claude Code

Comment on lines +386 to +389
} catch (error) {
// Given up on part-way through the answer: no answer at all.
if (gaveUp(error)) return { network: true };
body = null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retry transport failures while reading action responses

When the connection drops after response headers arrive but before the body finishes, res.json() can reject with a transport TypeError, rather than AbortError or TimeoutError. This catch converts that failure into body: null, which classify() interprets as requiring sign-in. With the app closed, the service worker then resolves the sync event because out.signin suppresses retries, leaving the action's outcome unresolved until the app is reopened despite the session still being valid. Treat response-body transport failures as retryable network failures instead of sign-in responses.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in bd1d03f. Only a body that arrives and is not JSON (SyntaxError) is read as something other than the platform; any other failure while reading the body is no answer ({ network: true }), so it is offered again and the worker asks to be woken again.


Generated by Claude Code

Comment thread pm-stack/console/public/app.js Outdated
const said = flushSaid(out.changed);
if (said) {
toast(said, out.changed.some((e) => e.state === "failed"));
refresh(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve active drafts when background replay finishes

If an older queued action finishes sending while the owner is composing a bug report, intake note, or agent message, this background call to refresh(true) bypasses refresh()'s focused-input guard and redraws the current screen. viewBugs(), viewIntake(), and viewAgents() recreate their textareas without retaining their contents, so reconnecting and replaying unrelated queued work can silently erase an unsent draft. Use a non-forced refresh for background completion or preserve the active form's state before redrawing; the service-worker completion handler has the same forced-refresh behavior.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in bd1d03f, two ways. A send that finishes in the background (the page's own flush, the worker's message, the worker taking the page over) no longer forces a redraw: it draws the screen again only when no dialog is open and no field has the cursor. And the bug, note and message forms now keep what is typed across any redraw, as the prompt box already did, so a draft that was set aside survives too. Checked in a real Chrome, cursor in the field and out of it; the check fails against the previous code.


Generated by Claude Code

…a cut-off answer is retried

Three findings from review, all real.

- When something kept earlier was sent, the screen was drawn again
  whatever the owner was doing, and a bug report, a note or a message
  half typed was gone. A background send now draws the screen again
  only when nobody is in the middle of something, and those three
  forms keep what is typed across any redraw.
- An answer whose body stops arriving part-way was read as "sign in
  again", which also stopped the worker from asking to be woken again.
  It is no answer, and is offered again.
- A failed answer could leave its question hidden if the list was read
  while the answer was on its way. On failure the list is read again
  whole.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
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.

2 participants