From 9d66562add574036647f30f888c653ee62c2ce21 Mon Sep 17 00:00:00 2001 From: Wing <44917547+wingleeio@users.noreply.github.com> Date: Sat, 14 Nov 2026 17:59:08 -0700 Subject: [PATCH] Transcript: a reply being written is glided to, not stepped a line at a time At the end while a reply streams, the view now glides to the end as the reply grows (`ui.list`'s new `glide`, zeronsh/zgx#2212) instead of jumping a line or a block at a time. Opening a chat, a send and the way back to the latest still land at once; only a reply being written glides. - zgx pinned at 0cd5afbec (zeronsh/zgx zeron/glide-follow, on zgx main 5a4be29b5): to move to zgx main once #2212 lands. - ui/tests/transcript_glide.test.luau: many small moves forward per streamed step, no way back to the latest meanwhile, landing on the end. Fails without `glide`. - The full UI suite passes (1406). Co-Authored-By: Claude Opus 5.5 --- apps/zgx/Cargo.lock | 48 ++++++------ apps/zgx/Cargo.toml | 28 +++---- apps/zgx/ui/ds/transcript.luau | 4 + apps/zgx/ui/tests/transcript_glide.test.luau | 77 ++++++++++++++++++++ 4 files changed, 119 insertions(+), 38 deletions(-) create mode 100644 apps/zgx/ui/tests/transcript_glide.test.luau diff --git a/apps/zgx/Cargo.lock b/apps/zgx/Cargo.lock index 437ed1ee8..e1372de26 100644 --- a/apps/zgx/Cargo.lock +++ b/apps/zgx/Cargo.lock @@ -30,7 +30,7 @@ dependencies = [ [[package]] name = "accesskit_atspi_common" version = "0.19.1" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "accesskit", "accesskit_consumer", @@ -43,7 +43,7 @@ dependencies = [ [[package]] name = "accesskit_consumer" version = "0.38.0" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "accesskit", "hashbrown 0.16.1", @@ -66,7 +66,7 @@ dependencies = [ [[package]] name = "accesskit_macos" version = "0.26.3" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "accesskit", "accesskit_consumer", @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "accesskit_unix" version = "0.22.1" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "accesskit", "accesskit_atspi_common", @@ -96,7 +96,7 @@ dependencies = [ [[package]] name = "accesskit_windows" version = "0.34.0" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "accesskit", "accesskit_consumer", @@ -6450,7 +6450,7 @@ dependencies = [ [[package]] name = "wgpu-hal" version = "29.0.4" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "android_system_properties", "arrayvec", @@ -6888,7 +6888,7 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winit" version = "0.30.13" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "ahash", "android-activity", @@ -7456,7 +7456,7 @@ dependencies = [ [[package]] name = "zgx" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "fixed_decimal", "foldhash 0.2.0", @@ -7485,7 +7485,7 @@ dependencies = [ [[package]] name = "zgx-3d" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "bytemuck", "zgx", @@ -7495,7 +7495,7 @@ dependencies = [ [[package]] name = "zgx-alacritty-terminal" version = "0.26.8" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "base64 0.22.1", "bitflags 2.13.2", @@ -7520,7 +7520,7 @@ dependencies = [ [[package]] name = "zgx-components" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "zgx", ] @@ -7528,7 +7528,7 @@ dependencies = [ [[package]] name = "zgx-cosmic-text" version = "0.19.14" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "bitflags 2.13.2", "fontdb", @@ -7552,7 +7552,7 @@ dependencies = [ [[package]] name = "zgx-desktop" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "accesskit", "accesskit_consumer", @@ -7603,12 +7603,12 @@ dependencies = [ [[package]] name = "zgx-ghostty-sys" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" [[package]] name = "zgx-gpu" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "ash", "block2 0.6.2", @@ -7648,7 +7648,7 @@ dependencies = [ [[package]] name = "zgx-harfrust" version = "0.5.4" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "bitflags 2.13.2", "bytemuck", @@ -7660,7 +7660,7 @@ dependencies = [ [[package]] name = "zgx-mlua" version = "0.12.9" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "bstr", "either", @@ -7675,7 +7675,7 @@ dependencies = [ [[package]] name = "zgx-run" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "serde_json", "ureq 3.5.0", @@ -7687,7 +7687,7 @@ dependencies = [ [[package]] name = "zgx-script" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "icu_locale_core", "icu_plurals", @@ -7712,7 +7712,7 @@ dependencies = [ [[package]] name = "zgx-swash" version = "0.2.11" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "skrifa", "yazi", @@ -7722,7 +7722,7 @@ dependencies = [ [[package]] name = "zgx-taffy" version = "0.9.2" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "arrayvec", "grid", @@ -7733,7 +7733,7 @@ dependencies = [ [[package]] name = "zgx-terminal" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "base64 0.22.1", "flate2", @@ -7749,7 +7749,7 @@ dependencies = [ [[package]] name = "zgx-vte" version = "0.15.4" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "arrayvec", "bitflags 2.13.2", @@ -7761,7 +7761,7 @@ dependencies = [ [[package]] name = "zgx-zune-jpeg" version = "0.5.15" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=0cd5afbec694c8f5f0d0f5882dacc4ed172589a2#0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" dependencies = [ "zune-core", ] diff --git a/apps/zgx/Cargo.toml b/apps/zgx/Cargo.toml index 9a30cbf91..0ed9473ab 100644 --- a/apps/zgx/Cargo.toml +++ b/apps/zgx/Cargo.toml @@ -32,7 +32,7 @@ layout_probe = [] [dependencies] lz4_flex = { version = "0.11", default-features = false, features = ["safe-encode", "safe-decode"] } -zgx = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } +zgx = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" } # `mimalloc`: the program's allocator, in place of the system's. It hands # freed memory back to the system (the system's keeps the most it ever # held), and zgx measures 1-10% less CPU for script, text and layout work. @@ -43,7 +43,7 @@ zgx = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191 # none of it, and without it pages are placeholders ("Web view · "). # zgx-run turns it on by default, but this app takes zgx-run without its # defaults (below). Nothing on macOS or Windows. -zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", features = ["mimalloc", "terminal", "webkitgtk"] } +zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2", features = ["mimalloc", "terminal", "webkitgtk"] } # `inspect`: devtools for `zgx inspect` (and its MCP server), asked for # with `--inspect`. `i18n`: `ui.t`'s plurals and numbers by each locale's # own rules (ICU4X's data, about 90 KB), for ui/locales' translations. @@ -51,18 +51,18 @@ zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb # wgpu this app already links), for plugins that show 3D: the CAD plugin # hands it its own triangles (`geometry = { positions, indices, … }`). It # asks no grant; a scene draws a frame only when something in it changes. -zgx-script = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", features = ["inspect", "i18n", "scene3d"] } +zgx-script = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2", features = ["inspect", "i18n", "scene3d"] } # A picture's pixels for the clipboard (src/images.rs): zgx's own decoder, # the formats `ui.image` shows (no features of its own: the ones zgx-desktop # turns on). -zgx-gpu = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", default-features = false } +zgx-gpu = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2", default-features = false } # Each plugin's own database (`zeron.db`, src/plugins/db.rs): SQLite, # built in; `limits` to keep one from attaching any other file. rusqlite = { version = "0.32", features = ["bundled", "limits", "hooks"] } # `fetch`: zgx's own transport for `ui.fetch` and remote images (HTTP and # HTTPS, rustls), given to every window (src/main.rs): the app's scripts, # and plugins granted "network". Nothing else of the runner. -zgx-run = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", default-features = false, features = ["fetch"] } +zgx-run = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2", default-features = false, features = ["fetch"] } # `webp`: `ui.image` decodes through this crate, by what its features # allow, so turning WebP on here is all it takes (the member cards' art). # `ico`: sites' favicons (the browser tab's: src/favicons.rs), most of @@ -162,7 +162,7 @@ foreign-types = "0.5" # elements, box drawing and Powerline glyphs to the cell; zgx's own renderer # draws them from the font at its text line height, gapped. Builds Ghostty # with Zig 0.16 (cached in ~/Library/Caches/zgx-ghostty). -zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", features = ["ghostty"] } +zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2", features = ["ghostty"] } # Windows' Transparency effects (src/transparency.rs), read and watched in # the registry, until zgx reports them (zgx-asks/windows-transparency); a @@ -173,7 +173,7 @@ zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb # 11 (and with Edge on Windows 10); without it, pages are placeholders. [target.'cfg(windows)'.dependencies] windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Graphics_Gdi", "Win32_Media_Audio", "Win32_Storage_FileSystem", "Win32_System_IO", "Win32_System_Console", "Win32_System_Registry", "Win32_System_Threading", "Win32_System_Time", "Win32_UI_WindowsAndMessaging"] } -zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", features = ["webview2"] } +zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2", features = ["webview2"] } # zgx's D-Bus (menus, portals) linked in rather than loaded: `zeron` is also # what a headless Linux server and every Cloud machine runs (`zeron @@ -185,13 +185,13 @@ libdbus-sys = { version = "0.2.7", features = ["vendored"] } # zgx's own patches (its root Cargo.toml): a git dependency does not bring # them, so every consumer repeats them. [patch.crates-io] -wgpu-hal = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -winit = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -accesskit_macos = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -accesskit_consumer = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -accesskit_atspi_common = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -accesskit_unix = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -accesskit_windows = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } +wgpu-hal = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" } +winit = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" } +accesskit_macos = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" } +accesskit_consumer = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" } +accesskit_atspi_common = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" } +accesskit_unix = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" } +accesskit_windows = { git = "https://github.com/zeronsh/zgx", rev = "0cd5afbec694c8f5f0d0f5882dacc4ed172589a2" } # zgx is slow unoptimized (its own setting): optimize dependencies, keep # this crate quick to build. diff --git a/apps/zgx/ui/ds/transcript.luau b/apps/zgx/ui/ds/transcript.luau index 8606ca686..6838289c5 100644 --- a/apps/zgx/ui/ds/transcript.luau +++ b/apps/zgx/ui/ds/transcript.luau @@ -2086,6 +2086,10 @@ local function Transcript(props: Props): Node focused_at = ui.now() end, follow = true, + -- While a reply is written, the end is glided to as it grows + -- (a line at a time otherwise steps the view); opening a chat, + -- a send and the way back to the latest still land at once. + glide = writing, at_end = at_end, height = ESTIMATE, overscan = 3, diff --git a/apps/zgx/ui/tests/transcript_glide.test.luau b/apps/zgx/ui/tests/transcript_glide.test.luau new file mode 100644 index 000000000..54c4b9723 --- /dev/null +++ b/apps/zgx/ui/tests/transcript_glide.test.luau @@ -0,0 +1,77 @@ +-- At the end while a reply is written, the view glides to the end as the +-- reply grows rather than stepping a line (or a block) at a time, as Zeron +-- 0.2's transcript did; it says it's at the end all the while (no way back +-- to the latest shows), and lands there. (Nov 14: "scrolling doesn't feel +-- smooth, it feels line by line while streaming".) +-- On chat_fixture's `long_chat` (ui/long_chat_fixture.luau). + +local function settle(app: any) + app:wait("#never-shown", { timeout_ms = 250 }) + app:frames(10) +end + +local function offset(app: any): number + return app:state("chat.transcript.offset") +end + +test("at the end, a reply being written is glided to as it grows", function() + local app = mount("chat_fixture.luau") + app:resize(960, 700) + app:frames(20) + app:command("long_chat_sent") + app:command("go_s7") + app:frames(30) + settle(app) + app:type("role:textbox", "three and one sounds like the most optional option") + app:key("Enter") + app:frames(40) + settle(app) + -- Written past the view (the runway under the prompt filled). + for _ = 1, 40 do + app:command("long_chat_streams") + app:frames(2) + end + settle(app) + -- More of the reply, at a window's pace: the view moves over several + -- frames each time. (Frames a refresh apart in real time: + -- the glide steps on the clock, as a window's frames do, not on the + -- test's frame count.) + local before = offset(app) + local seen: { number } = {} + for _ = 1, 12 do + app:command("long_chat_streams") + for _ = 1, 6 do + app:wait("#never-shown", { timeout_ms = 16 }) + app:frames(1) + local now = offset(app) + if now ~= (seen[#seen] or before) then + table.insert(seen, now) + end + end + end + -- Many small moves forward; back only where the reply's end itself came + -- up (a block settling shorter: the view at the end goes with it, as it + -- did before it glided). + local forward, back = 0, 0 + for i = 2, #seen do + if seen[i] > seen[i - 1] then + forward += 1 + else + back += 1 + end + end + expect(forward >= 24).to_be(true) + expect(back <= 2).to_be(true) + -- At the end all the while: no way back to the latest. + expect(app:has('role:button "Jump to latest"')).to_be(false) + -- (A second and a half, as a window's frames come.) + for _ = 1, 90 do + app:wait("#never-shown", { timeout_ms = 16 }) + app:frames(1) + end + -- Landed on the end. + local at = offset(app) + app:scroll("#transcript", 1e6) + app:frames(4) + expect(offset(app) - at < 1).to_be(true) +end)