Skip to content

fix(zbugs-gpui): mark an issue viewed after the server confirms its changes - #186

Merged
tmm merged 1 commit into
mainfrom
zbugs-gpui-viewed-after-confirm
Nov 13, 2026
Merged

tmm merged 1 commit into
mainfrom
zbugs-gpui-viewed-after-confirm

Conversation

@tmm

@tmm tmm commented Nov 13, 2026

Copy link
Copy Markdown
Member

The "zbugs GPUI app (macOS)" job failed once on #185 (run) at the viewState check: e2e online: passed, then the row read …|f|f|0|internal, so Postgres had the issue's viewed before its modified. A rerun passed.

Cause. zbugs' issue_set_last_modified trigger stamps modified with the start of the server's transaction for a change (CURRENT_TIMESTAMP), which comes after the client showed the change. The one-second view timer took its viewed time from the client's state (max(now, modified)). When it fired before the server had applied the close, the server's stamp came later. The app re-marked the issue a second after the server confirmed it, but the run had already exited after settled. A timer still pending from an earlier change makes the window wider: it can fire just after the close.

Fix. After its second, the timer waits for when_pending_settled and only then takes max(now, modified) from the confirmed issue. Offline, when_pending_settled returns at once, so marking works as before.

Checked on a Mac (macOS 27, same steps and DB check as CI's job, each run a fresh backend, online then offline):

build delay before the server's issue.update transaction result viewed − modified
main 1000 / 1200 / 1500 ms 0/5, 0/5, 0/3 (…|f|f|0|internal, as on #185) −90 to −640 ms
this PR 1000 / 1200 / 1500 ms 5/5, 5/5, 3/3 +9 to +13 ms
this PR none / 300 / 800 ms 30/30, 5/5, 5/5 +200 to +730 ms

The delay was a temporary local patch to apps/zbugs/api/index.ts, not part of this PR. It forces the timing the flaky CI run hit. cargo fmt --check, clippy with and without e2e, and cargo test pass.

…hanges

The zbugs GPUI end-to-end job failed once on #185 at the viewState check:
`e2e online: passed`, then Postgres had the issue's viewed time before its
modified time.

zbugs' issue trigger stamps `modified` with the time the server's
transaction for a change starts, after the client showed the change. The
one-second view timer took its viewed time from the client's state, so when
it fired before the server had applied the close, the server's stamp came
later. The app marked the issue viewed again a second after the server
confirmed it, but the run had already exited.

The timer now waits until the server has confirmed the pending mutations
before it takes the viewed time, as `max(now, modified)` of the confirmed
issue.

Amp-Thread-ID: https://ampcode.com/threads/T-5a01d9bf-e8fb-479a-8866-c293f3e230d5
Co-authored-by: tmm <tmm@tmm.dev>
@tmm
tmm merged commit 488bf65 into main Nov 13, 2026
16 checks passed
@tmm
tmm deleted the zbugs-gpui-viewed-after-confirm branch November 13, 2026 02:50
tmm added a commit that referenced this pull request Nov 13, 2026
…hanges (#187)

As in zbugs-gpui (#186): zbugs' issue trigger stamps `modified` with the
start of the server's transaction for a change, after the app showed it.
The one-second view timer took `now` from the app's state, so when it fired
before the server had applied the change, the server's stamp came later and
the issue stayed unread on the server until the app marked it again, a
second after the confirmation. An app that quit in between, as e2e.sh's run
does at a fixed time, left it unread.

The timer now waits until the server has confirmed the mutations sent so
far (`SyncThread::when_settled`), then marks the issue viewed at
`max(now, modified)` of the confirmed issue.

Amp-Thread-ID: https://ampcode.com/threads/T-5a01d9bf-e8fb-479a-8866-c293f3e230d5

Co-authored-by: Amp <amp@ampcode.com>
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