Web UI: pull down on the header bar to refresh on mobile#289
Merged
Conversation
The app shell is locked to `html, body { overflow: hidden }` so the
browser's native swipe-down-to-refresh never engages. On a narrow phone
viewport the URL-bar reload button is also hidden, which leaves no
obvious way to refresh the page — and hijacking page-wide swipes would
fight the session-view scroll.
Scope the gesture to the `<header>` only: a vertical drag that starts
on the title bar grows a sticky banner from the top of the viewport;
releasing past a 70 px threshold reloads. Anything starting outside the
header (chat scroll, session list, terminal) keeps its existing
behavior.
The handler differentiates from a tap by waiting until the drag has
moved more than 8 px down before it engages, so hamburger / title /
connection-indicator taps still fire normally. `touch-action: pan-y`
on the header lets the browser dispatch touchmove cleanly, and we
`preventDefault` only once tracking starts.
`location.reload()` is the wrong UX for a pull-to-refresh gesture on mobile: it nukes the xterm scrollback, transcript scroll position, widgets, and any in-flight PTY input — and flashes the page white for half a second on a slow phone. Replace it with `softRefresh()`: close the active WebSocket and let the existing close handler -> scheduleReconnect -> connect path re-run end to end. That re-subscribes globally, re-fetches the session list, and hydrates the active session via the reconnect path (`refreshCurrentSessionAfterReconnect`), which already preserves the xterm buffer for terminal sessions. The reconnect-delay backoff is short-circuited to 50 ms so the gesture feels instant.
You asked for the gesture to do a real refresh. The intervening soft-refresh detour was based on misreading 'can you hot reload' as a request to change the gesture behavior; you actually meant 'use agentd's webui_hot_reload tool to iterate'. Drop the helper function (its name was also clashing with the project's existing 'hot reload' terminology for the dev asset poller) and inline the original location.reload() back at the call site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The app shell is locked to
html, body { overflow: hidden; overscroll-behavior: none }, so the browser's native swipe-down-to-refresh never engages. On a narrow phone viewport (e.g. iOS / Android in portrait) the URL-bar reload button is also hidden, leaving no obvious way to refresh the page.Hijacking page-wide swipes isn't an option — it would fight the session-view scroll-up gesture, which is the primary thing you'd want a downward swipe to do inside the chat / terminal pane.
Fix
Scope the gesture to just
<header>:location.reload(); releasing earlier snaps the banner back.touch-action: pan-yon<header>keeps the browser dispatchingtouchmoveevents;preventDefaultis only called once tracking starts.All in
crates/daemon/assets/index.html: a.pull-indicatorCSS overlay and aninitPullToRefresh()function called from boot.Test
UI gesture itself isn't covered by automated tests (no headless mobile-touch harness in this repo). Manual verification on a narrow viewport:
🤖 Generated with Claude Code