Skip to content
This repository was archived by the owner on Nov 15, 2026. It is now read-only.

fix(desktop): start the other reader at the unread view after a mode change - #78

Merged
bketelsen merged 4 commits into
mainfrom
irulan/server-switch-start-route
Nov 12, 2026
Merged

bketelsen merged 4 commits into
mainfrom
irulan/server-switch-start-route

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the failure of item 7 ("Disconnects and mode changes") of the clean-install gate (plan 0002, Phase 10) on v0.6.0-rc.5.

A Server sheet switch reloaded the window (web/src/desktop/server.ts: win.location.reload()), and the reload kept the URL fragment. web/src/desktop/start.tsx read the fragment as the start route, so with #/item/4 open, the other reader opened its own item 4 and marked it read. Item ids belong to one reader: the item was unrelated data, in the local reader or in lodge's shared data. v0.6.0-rc.4 has the same code; its gate run had no item open at a switch.

The change:

  • tauriServer().reload loads the window's start address with no fragment (startAddress, location.replace).
  • The start route takes the fragment only on a new load. A reload, or Back or Forward into an earlier document, starts at the unread view (startHash, from the navigation timing entry). This also covers the ErrorBoundary's reload and the unknown-mode check's reload.
  • location.replace keeps the window's earlier history entries, and after Back into an earlier document its entries are this document's too. Each start writes its own mark in the state of the entries it writes (newStart, startState), and Back or Forward to an entry without the mark goes to the unread view (ownsEntry in onPop).
  • A document that Back or Forward restores from the back-forward cache runs no start, so it starts again through the server control (pageshow with persisted).
  • No saved last-route state exists (no localStorage or sessionStorage in web/src).

.memory/corrections.jsonl gets 1 line for the cross-review's blocking finding (the history entries), with its guard in web/src/desktop.test.tsx.

Docs: plan 0002 records the v0.6.0-rc.5 gate and this fix; Phase 10's Done when waits for a full gate on v0.6.0-rc.6. docs/design/overview.md, docs/specs/api.md (server_save) and AGENTS.md Status follow.

Risk tier

Risk tier: 2 — behaviour change in the desktop window's start route. No path in .github/risk-paths.json matches (web/src/desktop/* is at the default level L3).

Verification

  • make check green (host)
  • make web-check green (nsl): 24 files, 182 tests
  • make app-check and make app-build green (nsl)
  • make app-e2e-lodge green (nsl), against lodge main 0e4a5bd and frostnotes main: 7 of 7. Test b now opens a local item before the switch to lodge, and checks the window's fragment and lodge's unread total.
  • make app-e2e green (nsl) in 2 of 3 runs. The failed run: e2e/hostile.e2e.ts "runs nothing and reaches nothing through readd's sanitizer", WebDriver no such window at checkFrame's first find, the handle loss the suite documents after a history write. This change does not change how many history calls the shell makes.
  • Revert tests (scratch worktree for the unit tests):
    • web/src/desktop.test.tsx "starts the other reader at the unread view and marks nothing read", with reload back to win.location.reload(): fails with expected [ { ids: [ 31 ], read: true } ] to deeply equal [], the gate's symptom. web/src/server-sheet.test.tsx fails too.
    • The reload and back_forward cases, with the start route back to win.location.hash: both fail with the same items.setRead call.
    • The back-forward cache case, with the pageshow handler emptied: fails.
    • "takes Back to an entry of an earlier document to the unread view and marks nothing read", with the ownsEntry check bypassed: fails with expected { kind: 'item', id: 31 } to deeply equal { kind: 'view', view: 'unread' }. With the shell writing null state, "moves between routes and back" and "follows Back to an entry that this start wrote" fail.
    • make app-e2e-lodge with both fixes reverted: test b fails with expected [ '', '#/' ] to include '#/item/1'.

…change

A Server sheet switch reloaded the window, and the reload kept the
fragment. The window started at that route, so the other reader opened
its own item with the same id and marked it read: item ids belong to one
reader (plan 0002, Phase 10, item 7, on v0.6.0-rc.5).

- A mode change loads the window's start address with no fragment.
- A reload, or Back or Forward into an earlier document, starts at the
  unread view.
- A document restored from the back-forward cache starts again.

The unit tests switch readers with an item open, and the lodge e2e suite
switches to lodge with a local item open and checks lodge's unread
count. The plan records the rc.5 gate.
@github-actions github-actions Bot added the level:L3 Skim label Nov 12, 2026
…g its route

location.replace keeps the window's earlier history entries. After Back
into an earlier document, the entries that document wrote are this
document's too, and their routes can belong to the other reader. Each
start now writes its own mark in the state of its entries, and Back or
Forward to an entry without it goes to the unread view.
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 12, 2026
@bketelsen
bketelsen merged commit fb0ba06 into main Nov 12, 2026
12 checks passed
@bketelsen
bketelsen deleted the irulan/server-switch-start-route branch November 12, 2026 17:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

level:L3 Skim ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants