Fix mobile PWA reflow and avoid redundant session refresh#3976
Fix mobile PWA reflow and avoid redundant session refresh#3976ksj5131513-ops wants to merge 1 commit into
Conversation
|
| Filename | Overview |
|---|---|
| static/sessions.js | Refactors idle-reconcile path to probe server metadata before forcing a reload; introduces _probeActiveSessionServerFreshness but its catch block conflates API errors with loadSession errors, which can cause a double reload. |
| static/boot.js | Adds _forceMobileViewportReflow helper, wires it to visualViewport resize/scroll (debounced) and window.resize (synchronous when no visualViewport); debouncing asymmetry on old browsers is a pre-existing thread concern. |
| static/style.css | Adds GPU-promoted reflow class, overflow-x guard, and safe-area-aware padding for mobile PWA; all changes are scoped to @media(max-width:640px). |
Sequence Diagram
sequenceDiagram
participant Stream as Streaming "done" event
participant FinalizeStream as _finalizeStreamingSession
participant IdleReload as _scheduleActiveSessionIdleReload
participant Probe as _probeActiveSessionServerFreshness
participant API as /api/session (metadata)
participant LoadSession as loadSession
Stream->>FinalizeStream: "sets _streamJustFinished=true"
FinalizeStream->>IdleReload: setTimeout(0)
IdleReload->>Probe: allowNative:true, ignoreStreamJustFinished:true
Probe->>API: fetch message_count / last_message_at
alt API error (network/timeout)
API-->>Probe: throws
Probe-->>IdleReload: 'failed'
IdleReload->>LoadSession: force reload (fallback)
note over LoadSession: if loadSession also throws,<br/>it was already counted as 'failed'<br/>double-call risk
else remote newer than local
API-->>Probe: newer data
Probe->>LoadSession: force reload inside probe
Probe-->>IdleReload: 'reloaded'
else local is current
API-->>Probe: same counts
Probe-->>IdleReload: 'unchanged'
note over IdleReload: no reload - flash avoided
end
Reviews (3): Last reviewed commit: "Rebase mobile PWA refresh fix onto curre..." | Re-trigger Greptile
|
Thanks for this — the mobile PWA end-of-turn flash is a real annoyance and the 1. Rebase needed — it overlaps code that just shipped. 2. Settle-cooldown invariant + mobile evidence. This touches the post-stream cooldown ( Once it's rebased with the #4195 interaction resolved and has mobile before/after evidence, I'll run the full gate. Appreciate the contribution @ksj5131513-ops. |
4a2378e to
c32b80e
Compare
Summary
Why
On mobile PWA installs, the active conversation could visibly flash at end-of-turn when idle reconciliation immediately force-reloaded the same session. In the same environment, viewport/compositor changes could also leave the layout slightly clipped on the left until a manual scroll or repaint corrected it.
Changes
efreshActiveSessionIfExternallyUpdated('idle-reconcile') before falling back to a same-session force reload
Notes