Skip to content

fix(mobile,host): report a refused pin; read each task's due date in its own zone - #1338

Merged
huichen merged 4 commits into
mainfrom
pr/huichen
Oct 24, 2026
Merged

huichen merged 4 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

What and why

Two independent fixes that landed on dev-huichen:

  • A refused pin is now reported, not swallowed. Pinning a session from the phone resolved silently whenever the client, session id or thread id was missing, so the reader saw a tap that did nothing. threadId alone can go missing: a session notice carries threadId: "", and the session id cannot address the desktop's row. On the host side the pin also never announced itself, so the session snapshot was not re-read and re-sent.
  • Task due dates are read in each task's own zone. The scheduler compared due dates against one hard-coded offset, which is wrong for a task scheduled in a different zone and for DST boundaries.

Commits

  • fix(mobile,host): report a refused pin instead of swallowing it — setSessionPinned now throws Session unavailable instead of returning early (matching deleteSession and setWorkspacePinned, whose callers already catch); pin_thread calls mark_catalog_dirty() exactly as workspaces::pin_workspace does, so the publisher learns about the structural change from the store's own signal. Tests cover both the throw paths and the one-shot dirty flag.
  • fix(host): read each task's due date in its own zone, not one hard-coded offset — the task service resolves each task's due instant in its own time zone instead of applying a fixed offset to all of them.

Verification

Run locally at the frozen tip (5af7159b9) with the repo-pinned toolchain (rustc 1.97.0, clippy 0.1.97) and Node 22 (the CI line):

  • cargo fmt --all -- --check → clean
  • cargo clippy -p future-host --all-targets -- -D warnings → clean
  • cargo test -p future-host --lib -- store::threads → 35 passed
  • cargo test -p future-host --lib -- tasks → 66 passed, 2 ignored
  • npx tsc --noEmit (mobile) → clean
  • npx eslint src/remote/useSessionCatalog.ts src/remote/__tests__/useSessionCatalog.test.ts src/screens/__tests__/SessionsScreen.test.ts → clean
  • npx jest --runInBand src/remote/__tests__/useSessionCatalog.test.ts src/screens/__tests__/SessionsScreen.test.ts → 2 suites / 167 tests passed

Notes

  • Behaviour change: useSessionCatalog().setSessionPinned now rejects instead of resolving when it cannot address the row. Callers must handle the rejection (the existing call sites already catch and show the failure).

The phone's `setSessionPinned` returned early when the row it was given could
not be addressed — no connection, or no `threadId` (a shape a session notice
carries as `threadId: ""`). Resolving told the caller the desktop had taken the
pin, the action sheet closed, the row did not move and nothing said why. Its two
siblings in the same file, `deleteSession` and `setWorkspacePinned`, already
refuse with `Session unavailable` / `Workspace unavailable`, and the screen's
`runCommand` has always had a `catch` that shows `common.error` — this one path
simply never reached it.

The guard now throws, so the reader learns the tap did nothing. The later
`clientRef`/`catalogEpoch` re-check stays a silent return: that one means the
command succeeded and a newer local snapshot owns the list.

`store::pin_thread` also marks the catalogue dirty, as `pin_workspace` does.
`pinned` rides on the structural side of the session snapshot, so a client cannot
patch it from a value; the mark is what tells the publisher the store changed
rather than leaving it to a signature it recomputes on its own schedule.

Each new assertion was run against the unfixed code first: the two hook tests
fail on "promise resolved instead of rejected", the screen test on the missing
`common.error`, and the store test on the absent dirty mark.
…ded offset

`a_tasks_schedule_uses_its_own_zone` read both tasks' next due date through
Asia/Shanghai and hard-coded '09:00 Berlin is 15:00 Shanghai'. That also encodes
the offset in force that week: Europe/Berlin is UTC+2 until the last Sunday of
October and UTC+1 after it, so a correct schedule reads 15:00 in summer and
16:00 in winter. The next 09:00 Berlin fell after the 2026-10-25 switch, so from
that morning the test failed on every machine — including CI, whose last Rust
run predated the switch (and whose most recent run skipped the Rust jobs
entirely, so nothing had noticed).

Each due date is now read in the zone it was written in, which is the invariant
the test is about, and the two instants are asserted to differ. Both keep the
'not the host's zone' bite: a schedule computed in the host's zone lands Berlin
on Shanghai's instant, which reads 02:00 in Berlin rather than 09:00 — verified
by temporarily asserting exactly that, which failed.

Task module: 65 passed. fmt and clippy clean under the pinned 1.97 toolchain
(PATH-prefixed; bare cargo here is Homebrew 1.96).
@huichen
huichen enabled auto-merge (squash) October 24, 2026 07:19
@huichen
huichen merged commit 144ad03 into main Oct 24, 2026
21 checks passed
@huichen
huichen deleted the pr/huichen branch October 24, 2026 07:33
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