YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: preserve Windows live transcript reading position (#7604)
Ezra Ellettea27c08b28d54
diff --git a/crates/screenpipe-overlay-win/src/layout.rs b/crates/screenpipe-overlay-win/src/layout.rsindex c37d31a83..f0312495f 100644--- a/crates/screenpipe-overlay-win/src/layout.rs+++ b/crates/screenpipe-overlay-win/src/layout.rs@@ -586,6 +586,7 @@ mod tests {anchor: Anchor::BottomCenter,meeting_active: true,transcript: vec![TranscriptItem {+ id: "1".into(),speaker: "louis".into(),text: "shipping the native overlay".into(),device_type: "input".into(),@@ -640,6 +641,7 @@ mod tests {s.meeting_active = true;s.transcript_pinned = true;s.transcript = vec![TranscriptItem {+ id: "1".into(),speaker: "louis".into(),text: "hello".into(),device_type: "input".into(),@@ -715,6 +717,7 @@ mod tests {meeting_active: true,transcript_pinned: true,transcript: vec![TranscriptItem {+ id: "1".into(),speaker: "louis".into(),text: "shipping the native overlay".into(),device_type: "input".into(),@@ -763,6 +766,7 @@ mod tests {s.meeting_active = true;s.transcript_pinned = true;s.transcript = vec![TranscriptItem {+ id: "1".into(),speaker: "louis".into(),text: "hello".into(),device_type: "input".into(),@@ -792,6 +796,7 @@ mod tests {let mut s = hovered();s.meeting_active = true;s.transcript = vec![TranscriptItem {+ id: "1".into(),speaker: "louis".into(),text: "hello".into(),device_type: "input".into(),@@ -820,6 +825,7 @@ mod tests {let mut s = hovered();s.meeting_active = true;s.transcript = vec![TranscriptItem {+ id: "1".into(),speaker: "louis".into(),text: "hello".into(),device_type: "input".into(),diff --git a/crates/screenpipe-overlay-win/src/preview.rs b/crates/screenpipe-overlay-win/src/preview.rsindex c74976dec..4e7dd17c2 100644--- a/crates/screenpipe-overlay-win/src/preview.rs+++ b/crates/screenpipe-overlay-win/src/preview.rs@@ -43,11 +43,13 @@ fn base() -> OverlayState {fn meeting_lines() -> Vec<TranscriptItem> {vec![TranscriptItem {+ id: "preview-1".into(),speaker: "louis".into(),text: "the native pill is drawing through direct2d now".into(),device_type: "input".into(),},TranscriptItem {+ id: "preview-2".into(),speaker: "matt".into(),text: "does it still pass clicks through to the desktop?".into(),device_type: "output".into(),@@ -55,6 +57,7 @@ fn meeting_lines() -> Vec<TranscriptItem> {// Unnamed: the card has to attribute this one from the device alone,// which is the common case in the first seconds of a meeting.TranscriptItem {+ id: "preview-3".into(),speaker: String::new(),text: "yes — layered windows hit-test per pixel".into(),device_type: "input".into(),@@ -319,6 +322,97 @@ fn live_shots(dir: &str) -> windows::core::Result<()> {Ok(())}+fn transcript_scroll_shots(dir: &str) -> windows::core::Result<()> {+ std::fs::create_dir_all(dir).expect("create shot dir");+ let overlay = Overlay::spawn(|action| println!("action: {action}"));+ let renderer = Renderer::new()?;+ let eq = Equalizer::default();+ overlay.show();+ let mut state = OverlayState {+ force_expanded: true,+ meeting_active: true,+ meeting_id: Some(1013),+ transcript_pinned: true,+ ..base()+ };+ state.transcript = (0..50)+ .map(|i| TranscriptItem {+ id: format!("fixture-{i}"),+ speaker: if i % 2 == 0 { "you" } else { "guest" }.into(),+ text: format!("synthetic transcript line {i}"),+ device_type: "output".into(),+ })+ .collect();++ let shoot = |name: &str,+ expected_offset: usize,+ expected: &[TranscriptItem]|+ -> windows::core::Result<()> {+ let evidence = overlay.preview_snapshot();+ assert_eq!(+ evidence.transcript_scroll_from_latest, expected_offset,+ "{name} offset"+ );+ assert_eq!(evidence.transcript, expected, "{name} transcript bytes");+ let path = format!("{dir}/{name}.png");+ let (w, h) = write_png(+ &renderer,+ &evidence,+ &eq,+ &Backdrop::Solid([0.11, 0.12, 0.14]),+ None,+ 14,+ &path,+ )?;+ println!("{path} {w}x{h}");+ Ok(())+ };++ overlay.update(state.clone());+ let initial = state.transcript.clone();+ shoot("01-following-latest", 0, &initial)?;+ overlay.preview_mouse_wheel(360);+ shoot("02-wheel-up-reading", 3, &initial)?;+ // A repeated Show while already visible must not discard the reading+ // snapshot. This is the command pattern used by redundant app lifecycle+ // notifications.+ overlay.show();+ shoot("03-repeated-show-still-reading", 3, &initial)?;++ // Model the bounded live feed rolling 0..49 to 1..50, then replace a+ // same-length partial. Neither update may alter the frozen display.+ state.transcript.remove(0);+ state.transcript.push(TranscriptItem {+ id: "fixture-50".into(),+ speaker: "you".into(),+ text: "synthetic transcript line 50".into(),+ device_type: "output".into(),+ });+ overlay.update(state.clone());+ state.transcript[45].text = "synthetic partial changed 46".into();+ overlay.update(state.clone());+ assert_ne!(+ state.transcript, initial,+ "rolling feed must differ from frozen fixture"+ );+ shoot("04-roll-and-partial-still-reading", 3, &initial)?;++ // Hide while still paused. Reopening is a genuine visibility transition+ // and must jump to the newest rolling snapshot.+ overlay.hide();+ overlay.show();+ shoot("05-hide-reopen-flushes-latest", 0, &state.transcript)?;++ // Returning to bottom must also flush immediately when the stream is now+ // quiet (there is deliberately no update between wheel and capture).+ overlay.preview_mouse_wheel(240);+ shoot("06-paused-again", 2, &state.transcript)?;+ overlay.preview_mouse_wheel(-1200);+ shoot("07-wheel-bottom-flushes-quiet-latest", 0, &state.transcript)?;+ overlay.hide();+ Ok(())+}+/// Anchor names accepted on the command line, matching the kebab-case the/// settings store and `overlay-anchor.ts` already use.fn parse_anchor(s: &str) -> Option<Anchor> {@@ -440,6 +534,11 @@ pub fn run() -> windows::core::Result<()> {.map(String::as_str).unwrap_or("target/overlay-live"),),+ Some("transcript-scroll-shots") => transcript_scroll_shots(+ args.get(2)+ .map(String::as_str)+ .unwrap_or("target/overlay-transcript-scroll"),+ ),Some("live") => {let anchor = args.get(2)@@ -452,7 +551,7 @@ pub fn run() -> windows::core::Result<()> {}_ => {eprintln!(- "usage: overlay-preview shots [dir]\n overlay-preview live-shots [dir]\n overlay-preview live [anchor] [--no-cycle] [--toast]\n\nanchors: top-center right-center bottom-center left-center"+ "usage: overlay-preview shots [dir]\n overlay-preview live-shots [dir]\n overlay-preview transcript-scroll-shots [dir]\n overlay-preview live [anchor] [--no-cycle] [--toast]\n\nanchors: top-center right-center bottom-center left-center");Ok(())}diff --git a/crates/screenpipe-overlay-win/src/render.rs b/crates/screenpipe-overlay-win/src/render.rsindex ed943ced5..85079df92 100644--- a/crates/screenpipe-overlay-win/src/render.rs+++ b/crates/screenpipe-overlay-win/src/render.rs@@ -23,9 +23,9 @@ use windows::Win32::Graphics::Direct2D::Common::{};use windows::Win32::Graphics::Direct2D::{D2D1CreateFactory, ID2D1Bitmap, ID2D1Factory, ID2D1RenderTarget, ID2D1SolidColorBrush,- D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,- D2D1_DRAW_TEXT_OPTIONS_NONE, D2D1_ELLIPSE, D2D1_FACTORY_TYPE_SINGLE_THREADED,- D2D1_ROUNDED_RECT,+ D2D1_ANTIALIAS_MODE_ALIASED, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE,+ D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, D2D1_DRAW_TEXT_OPTIONS_NONE, D2D1_ELLIPSE,+ D2D1_FACTORY_TYPE_SINGLE_THREADED, D2D1_ROUNDED_RECT,};use windows::Win32::Graphics::DirectWrite::{DWriteCreateFactory, IDWriteFactory, IDWriteTextFormat, DWRITE_FACTORY_TYPE_SHARED,@@ -841,9 +841,24 @@ impl Renderer {let capacity = ((r.bottom() - 6.0 * s - body_top) / line_h).floor().max(0.0) as usize;- let start = state.transcript.len().saturating_sub(capacity);+ let end = state+ .transcript+ .len()+ .saturating_sub(state.transcript_scroll_from_latest);+ let start = end.saturating_sub(capacity);let text_w = r.w - pad * 2.0;- for (i, item) in state.transcript[start..].iter().enumerate() {+ unsafe {+ rt.PushAxisAlignedClip(+ &d2d_rect(Rect::new(+ r.x + pad,+ body_top,+ text_w,+ r.bottom() - body_top - 6.0 * s,+ )),+ D2D1_ANTIALIAS_MODE_ALIASED,+ )+ };+ for (i, item) in state.transcript[start..end].iter().enumerate() {let y = body_top + i as f32 * line_h;self.mono_text(rt,@@ -869,6 +884,7 @@ impl Renderer {white(0.88),);}+ unsafe { rt.PopAxisAlignedClip() };let brush = self.brush(rt, white(0.42));unsafe { rt.DrawRectangle(&d2d_rect(r.inset(0.5, 0.5)), &brush, 1.0, None) };diff --git a/crates/screenpipe-overlay-win/src/state.rs b/crates/screenpipe-overlay-win/src/state.rsindex fbff791c6..1f154bace 100644--- a/crates/screenpipe-overlay-win/src/state.rs+++ b/crates/screenpipe-overlay-win/src/state.rs@@ -151,6 +151,10 @@ impl OverlaySize {#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]pub struct TranscriptItem {+ /// Stable feed identity. The window uses this to keep the same utterance+ /// under the reader when partial text changes or old history rolls away.+ #[serde(default)]+ pub id: String,pub speaker: String,pub text: String,/// `"input"` (our mic) or `"output"` (the room). Decides the attribution@@ -190,6 +194,9 @@ pub struct OverlayState {pub notification: Option<Notification>,pub transcript: Vec<TranscriptItem>,+ /// Lines between the rendered viewport and the newest transcript item.+ /// Owned by the native window; caller state replacement must not reset it.+ pub transcript_scroll_from_latest: usize,pub transcript_pinned: bool,/// The live meeting, if any. The note button routes by id, so without one/// there is nothing to open.@@ -339,6 +346,7 @@ mod tests {};assert!(!s.shows_transcript(), "no lines yet");s.transcript.push(TranscriptItem {+ id: "1".into(),speaker: "louis".into(),text: "hello".into(),device_type: "input".into(),diff --git a/crates/screenpipe-overlay-win/src/transcript.rs b/crates/screenpipe-overlay-win/src/transcript.rsindex d0773ede2..f82a36acf 100644--- a/crates/screenpipe-overlay-win/src/transcript.rs+++ b/crates/screenpipe-overlay-win/src/transcript.rs@@ -23,9 +23,9 @@ pub const WINDOW_SECONDS: f64 = 6.0;pub const COVERAGE: f32 = 0.6;pub const MIN_CHARACTERS: usize = 24;-/// How many lines the card keeps. The card shows four at most; a little history-/// beyond that absorbs a burst without the feed jumping.-pub const MAX_LINES: usize = 8;+/// How many lines the card keeps. This matches the other native overlays while+/// remaining small enough to bound the always-live meeting state.+pub const MAX_LINES: usize = 50;#[derive(Debug, Clone, PartialEq)]pub struct FeedItem {@@ -121,6 +121,7 @@ impl TranscriptFeed {self.items.iter().map(|i| TranscriptItem {+ id: i.id.clone(),speaker: i.speaker.clone(),text: i.text.clone(),device_type: i.device_type.clone(),@@ -129,6 +130,62 @@ impl TranscriptFeed {}}+/// Window-owned transcript viewport. While the reader is away from the live+/// edge, `display` is an immutable, bounded snapshot and `latest` continues to+/// receive the rolling feed.+#[derive(Debug, Default)]+pub struct TranscriptScroll {+ from_latest: usize,+ wheel_remainder: i32,+ latest: Vec<TranscriptItem>,+ display: Vec<TranscriptItem>,+}++impl TranscriptScroll {+ pub fn from_latest(&self) -> usize {+ self.from_latest+ }++ pub fn display(&self) -> &[TranscriptItem] {+ &self.display+ }++ pub fn reset(&mut self) {+ self.from_latest = 0;+ self.wheel_remainder = 0;+ self.display.clone_from(&self.latest);+ }++ pub fn sync(&mut self, new: &[TranscriptItem], preserve: bool) {+ self.latest.clear();+ self.latest.extend_from_slice(new);+ if !preserve || self.from_latest == 0 {+ self.reset();+ }+ }++ /// Accumulate high-resolution wheel input. Returns true when the displayed+ /// snapshot or row offset changed.+ pub fn wheel(&mut self, delta: i16, capacity: usize) -> bool {+ let before = self.from_latest;+ self.wheel_remainder += i32::from(delta);+ while self.wheel_remainder.abs() >= 120 {+ let step = self.wheel_remainder.signum();+ self.wheel_remainder -= step * 120;+ if step > 0 {+ let max = self.display.len().saturating_sub(capacity);+ self.from_latest = (self.from_latest + 1).min(max);+ } else {+ self.from_latest = self.from_latest.saturating_sub(1);+ }+ }+ if before != 0 && self.from_latest == 0 {+ self.display.clone_from(&self.latest);+ }+ before != self.from_latest+ }+}+#[cfg(test)]mod tests {use super::*;@@ -235,4 +292,84 @@ mod tests {let lines = feed.lines();assert!(lines[0].text.starts_with("the first"));}++ fn displayed(id: usize, text: &str) -> TranscriptItem {+ TranscriptItem {+ id: id.to_string(),+ speaker: "speaker".into(),+ text: text.into(),+ device_type: "output".into(),+ }+ }++ #[test]+ fn streaming_and_partial_updates_do_not_move_a_reader() {+ let mut scroll = TranscriptScroll::default();+ let old: Vec<_> = (0..6).map(|id| displayed(id, "original")).collect();+ scroll.sync(&old, false);+ scroll.wheel(120, 4);+ let mut appended = old.clone();+ appended.push(displayed(6, "new"));+ scroll.sync(&appended, true);+ assert_eq!(scroll.from_latest(), 1);+ assert_eq!(+ scroll.display(),+ old,+ "append leaves every displayed byte frozen"+ );++ let mut partial = appended.clone();+ partial[2].text = "same id and length, different words".into();+ scroll.sync(&partial, true);+ assert_eq!(scroll.display(), old, "partial replacement stays frozen");+ }++ #[test]+ fn rolling_history_eviction_does_not_change_the_snapshot() {+ let mut scroll = TranscriptScroll::default();+ let old: Vec<_> = (0..MAX_LINES).map(|id| displayed(id, "line")).collect();+ scroll.sync(&old, false);+ scroll.wheel(120, 4);+ scroll.wheel(120, 4);+ let new: Vec<_> = (1..=MAX_LINES).map(|id| displayed(id, "line")).collect();+ scroll.sync(&new, true);+ assert_eq!(scroll.display(), old);+ assert_eq!(scroll.display().len(), MAX_LINES);+ }++ #[test]+ fn reaching_latest_flushes_quiet_stream_and_reset_flushes_reopen() {+ let lines: Vec<_> = (0..8).map(|id| displayed(id, "line")).collect();+ let mut scroll = TranscriptScroll::default();+ scroll.sync(&lines, false);+ scroll.wheel(120, 4);+ let mut latest = lines.clone();+ latest.push(displayed(8, "quiet latest"));+ scroll.sync(&latest, true); // pin toggled while still visible+ assert_eq!(scroll.from_latest(), 1);+ assert_eq!(scroll.display(), lines);+ scroll.wheel(-120, 4);+ assert_eq!(scroll.from_latest(), 0, "wheel down reaches live edge");+ assert_eq!(+ scroll.display(),+ latest,+ "latest flushes without a stream event"+ );+ scroll.wheel(120, 4);+ scroll.reset(); // collapsed/hidden or new meeting+ assert_eq!(scroll.from_latest(), 0);+ assert_eq!(scroll.display(), latest);+ }++ #[test]+ fn high_resolution_wheel_accumulates_and_reversal_cancels() {+ let lines: Vec<_> = (0..8).map(|id| displayed(id, "line")).collect();+ let mut scroll = TranscriptScroll::default();+ scroll.sync(&lines, false);+ assert!(!scroll.wheel(60, 4));+ assert!(!scroll.wheel(-30, 4));+ assert!(!scroll.wheel(89, 4));+ assert!(scroll.wheel(1, 4));+ assert_eq!(scroll.from_latest(), 1);+ }}diff --git a/crates/screenpipe-overlay-win/src/window.rs b/crates/screenpipe-overlay-win/src/window.rsindex 91d633a9d..83889466d 100644--- a/crates/screenpipe-overlay-win/src/window.rs+++ b/crates/screenpipe-overlay-win/src/window.rs@@ -32,9 +32,9 @@ use windows::Win32::Graphics::Direct2D::{};use windows::Win32::Graphics::Gdi::{CreateCompatibleDC, CreateDIBSection, DeleteDC, DeleteObject, GetDC, GetMonitorInfoW,- MonitorFromPoint, MonitorFromWindow, ReleaseDC, SelectObject, AC_SRC_ALPHA, AC_SRC_OVER,- BITMAPINFO, BITMAPINFOHEADER, BI_RGB, BLENDFUNCTION, DIB_RGB_COLORS, HBITMAP, HDC, HGDIOBJ,- MONITORINFO, MONITOR_DEFAULTTONEAREST,+ MonitorFromPoint, MonitorFromWindow, ReleaseDC, ScreenToClient, SelectObject, AC_SRC_ALPHA,+ AC_SRC_OVER, BITMAPINFO, BITMAPINFOHEADER, BI_RGB, BLENDFUNCTION, DIB_RGB_COLORS, HBITMAP, HDC,+ HGDIOBJ, MONITORINFO, MONITOR_DEFAULTTONEAREST,};use windows::Win32::System::Com::{CoInitializeEx, COINIT_APARTMENTTHREADED};use windows::Win32::System::LibraryLoader::GetModuleHandleW;@@ -51,9 +51,9 @@ use windows::Win32::UI::WindowsAndMessaging::{IDC_ARROW, MF_SEPARATOR, MF_STRING, MSG, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE, SW_HIDE,SW_SHOWNOACTIVATE, TPM_RETURNCMD, TPM_RIGHTALIGN, TPM_TOPALIGN, ULW_ALPHA,WDA_EXCLUDEFROMCAPTURE, WDA_NONE, WINDOWPOS, WM_APP, WM_DESTROY, WM_DISPLAYCHANGE,- WM_DPICHANGED, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MOUSEMOVE, WM_RBUTTONDOWN, WM_RBUTTONUP,- WM_SETTINGCHANGE, WM_TIMER, WM_WINDOWPOSCHANGING, WNDCLASSEXW, WS_EX_LAYERED, WS_EX_NOACTIVATE,- WS_EX_TOOLWINDOW, WS_EX_TOPMOST, WS_EX_TRANSPARENT, WS_POPUP,+ WM_DPICHANGED, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_RBUTTONDOWN,+ WM_RBUTTONUP, WM_SETTINGCHANGE, WM_TIMER, WM_WINDOWPOSCHANGING, WNDCLASSEXW, WS_EX_LAYERED,+ WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_EX_TOPMOST, WS_EX_TRANSPARENT, WS_POPUP,};use crate::actions::{@@ -66,6 +66,7 @@ use crate::layout::{self, Layout, SHADOW_PAD};use crate::notification::{self, Notification, Refusal};use crate::render::{premultiplied_bgra, Renderer};use crate::state::{Anchor, Control, OverlayState};+use crate::transcript::TranscriptScroll;/// In `Win32::UI::Controls` in windows-rs, a feature this crate does not/// otherwise need — cheaper to name the constant than to pull it in.@@ -87,6 +88,23 @@ const ANIM_MS: u32 = 83; // ~12 Hz, same cadence as the macOS meter.const HOVER_POLL_MS: u32 = 90;/// Pointer travel before a press on the pill becomes a drag rather than a click.const DRAG_THRESHOLD: f32 = 4.0;+const TRANSCRIPT_CAPACITY: usize = 4;++fn show_resets_transcript(visible: bool) -> bool {+ !visible+}++fn flush_transcript_on_reexpand(+ was_visible: bool,+ state: &mut OverlayState,+ scroll: &mut TranscriptScroll,+) {+ if !was_visible && state.shows_transcript() {+ scroll.reset();+ state.transcript = scroll.display().to_vec();+ state.transcript_scroll_from_latest = 0;+ }+}/// Show the same two-choice brand context menu as the macOS overlay. Returning/// the selected app action keeps presentation inside the Win32 window while@@ -143,6 +161,7 @@ enum Cmd {Show,Hide,SetCaptureProtected(bool),+ PreviewSnapshot(Sender<OverlayState>),Quit,}@@ -227,6 +246,34 @@ impl Overlay {Some((r.left, r.top, r.right - r.left, r.bottom - r.top))}+ /// Drive the native wheel path from the synthetic preview fixture.+ #[doc(hidden)]+ pub fn preview_mouse_wheel(&self, delta: i16) {+ if let Some(h) = self.raw_hwnd() {+ let packed = (delta as u16 as usize) << 16;+ let mut rect = RECT::default();+ unsafe {+ let _ = GetWindowRect(h, &mut rect);+ }+ let x = rect.left + (rect.right - rect.left) / 2;+ // Aim well inside the transcript text body, not at its header or+ // the dock. Use a real screen coordinate, as WM_MOUSEWHEEL does.+ let y = rect.top + (rect.bottom - rect.top) * 2 / 3;+ let position = ((y as u16 as isize) << 16) | x as u16 as isize;+ unsafe {+ let _ = PostMessageW(h, WM_MOUSEWHEEL, WPARAM(packed), LPARAM(position));+ }+ }+ }++ /// Return window-owned state after every previously queued preview action.+ #[doc(hidden)]+ pub fn preview_snapshot(&self) -> OverlayState {+ let (tx, rx) = channel();+ self.send(Cmd::PreviewSnapshot(tx));+ rx.recv().expect("overlay preview snapshot")+ }+fn raw_hwnd(&self) -> Option<HWND> {let h = *self.hwnd.lock().ok()?;(h != 0).then_some(HWND(h as *mut _))@@ -280,6 +327,7 @@ struct Ctx {pushed_anchor: Option<Anchor>,/// Same, for the transcript card's pin.pushed_pinned: Option<bool>,+ transcript_scroll: TranscriptScroll,dragging: bool,drag_offset: (i32, i32),animating: bool,@@ -358,6 +406,7 @@ fn run_message_loop(toast_hovered: false,pushed_anchor: None,pushed_pinned: None,+ transcript_scroll: TranscriptScroll::default(),dragging: false,drag_offset: (0, 0),animating: false,@@ -1098,6 +1147,14 @@ fn drain_commands(hwnd: HWND) -> (bool, bool) {// The caller does not own the notification either — it arrives// through show_notification and leaves on its own schedule.s.notification = ctx.state.notification.clone();+ let was_transcript_visible = ctx.state.shows_transcript();+ let transcript_visible = s.shows_transcript();+ let preserve = transcript_visible+ && was_transcript_visible+ && s.meeting_id == ctx.state.meeting_id;+ ctx.transcript_scroll.sync(&s.transcript, preserve);+ s.transcript = ctx.transcript_scroll.display().to_vec();+ s.transcript_scroll_from_latest = ctx.transcript_scroll.from_latest();if s != ctx.state {ctx.state = s;dirty = true;@@ -1115,6 +1172,11 @@ fn drain_commands(hwnd: HWND) -> (bool, bool) {}}Cmd::Show => {+ if show_resets_transcript(ctx.visible.load(Ordering::SeqCst)) {+ ctx.transcript_scroll.reset();+ ctx.state.transcript = ctx.transcript_scroll.display().to_vec();+ ctx.state.transcript_scroll_from_latest = 0;+ }unsafe {let _ = ShowWindow(hwnd, SW_SHOWNOACTIVATE);}@@ -1132,6 +1194,9 @@ fn drain_commands(hwnd: HWND) -> (bool, bool) {ctx.state.hovered_control = None;ctx.state.pressed_control = None;ctx.state.notification = None;+ ctx.transcript_scroll.reset();+ ctx.state.transcript = ctx.transcript_scroll.display().to_vec();+ ctx.state.transcript_scroll_from_latest = 0;rearm_dismiss = true;}Cmd::SetCaptureProtected(protected) => {@@ -1148,6 +1213,9 @@ fn drain_commands(hwnd: HWND) -> (bool, bool) {}}}+ Cmd::PreviewSnapshot(reply) => {+ let _ = reply.send(ctx.state.clone());+ }Cmd::Quit => quit = true,}}@@ -1287,8 +1355,14 @@ extern "system" fn wndproc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM)let on_toast = ctx.layout.is_notification_at(x, y);let hovering = if on_toast { ctx.state.hovering } else { inside };if ctx.state.hovering != hovering || ctx.state.hovered_control != hovered {+ let was_transcript_visible = ctx.state.shows_transcript();ctx.state.hovering = hovering;ctx.state.hovered_control = hovered;+ flush_transcript_on_reexpand(+ was_transcript_visible,+ &mut ctx.state,+ &mut ctx.transcript_scroll,+ );apply_state(hwnd);}// …and it holds the toast open too: a notification that expires@@ -1307,6 +1381,29 @@ extern "system" fn wndproc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM)LRESULT(0)}+ WM_MOUSEWHEEL => {+ if let Some(ctx) = ctx_of(hwnd) {+ let mut point = POINT {+ x: lparam.0 as i16 as i32,+ y: (lparam.0 >> 16) as i16 as i32,+ };+ let _ = ScreenToClient(hwnd, &mut point);+ let over_body = ctx.layout.transcript.is_some_and(|r| {+ r.contains(point.x as f32, point.y as f32)+ && point.y as f32 >= r.y + 27.0 * ctx.layout.scale+ });+ if ctx.state.shows_transcript() && over_body {+ let delta = ((wparam.0 >> 16) & 0xffff) as u16 as i16;+ ctx.transcript_scroll.wheel(delta, TRANSCRIPT_CAPACITY);+ ctx.state.transcript = ctx.transcript_scroll.display().to_vec();+ ctx.state.transcript_scroll_from_latest =+ ctx.transcript_scroll.from_latest();+ repaint(hwnd);+ }+ }+ LRESULT(0)+ }+// Not believed on its own: reaching for the card or the toast// crosses a transparent gap, and that arrives here exactly like a// real exit. The corridor timer decides which one it was.@@ -1477,6 +1574,54 @@ extern "system" fn wndproc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM)mod tests {use super::*;+ #[test]+ fn only_a_hidden_to_visible_show_resets_the_transcript() {+ assert!(show_resets_transcript(false));+ assert!(!show_resets_transcript(true));+ }++ #[test]+ fn hover_reexpand_flushes_latest_streamed_while_collapsed() {+ use crate::state::TranscriptItem;++ let line = |id: usize| TranscriptItem {+ id: id.to_string(),+ speaker: "synthetic".into(),+ text: format!("line {id}"),+ device_type: "output".into(),+ };+ let initial: Vec<_> = (0..6).map(line).collect();+ let mut scroll = TranscriptScroll::default();+ scroll.sync(&initial, false);+ scroll.wheel(120, TRANSCRIPT_CAPACITY);++ let mut latest = initial[1..].to_vec();+ latest.push(line(6));+ scroll.sync(&latest, true);+ let mut state = OverlayState {+ meeting_active: true,+ transcript: initial.clone(),+ transcript_scroll_from_latest: 1,+ ..Default::default()+ };+ assert!(+ !state.shows_transcript(),+ "collapsed before pointer returns"+ );++ state.hovering = true;+ flush_transcript_on_reexpand(false, &mut state, &mut scroll);+ assert_eq!(state.transcript_scroll_from_latest, 0);+ assert_eq!(+ state.transcript, latest,+ "hover publishes latest exact bytes"+ );+ assert_ne!(+ state.transcript, initial,+ "stale frozen snapshot was replaced"+ );+ }+/// Replays the drag that would not stick: the app's own copy of the state/// is stale the moment the pointer is released, and it re-pushes that copy/// continuously.diff --git a/docs/pr-assets/transcript-scroll-windows/01-following-latest.png b/docs/pr-assets/transcript-scroll-windows/01-following-latest.pngnew file mode 100644index 000000000..d749b6d1aBinary files /dev/null and b/docs/pr-assets/transcript-scroll-windows/01-following-latest.png differdiff --git a/docs/pr-assets/transcript-scroll-windows/02-wheel-up-reading.png b/docs/pr-assets/transcript-scroll-windows/02-wheel-up-reading.pngnew file mode 100644index 000000000..385617b3cBinary files /dev/null and b/docs/pr-assets/transcript-scroll-windows/02-wheel-up-reading.png differdiff --git a/docs/pr-assets/transcript-scroll-windows/03-repeated-show-still-reading.png b/docs/pr-assets/transcript-scroll-windows/03-repeated-show-still-reading.pngnew file mode 100644index 000000000..385617b3cBinary files /dev/null and b/docs/pr-assets/transcript-scroll-windows/03-repeated-show-still-reading.png differdiff --git a/docs/pr-assets/transcript-scroll-windows/04-roll-and-partial-still-reading.png b/docs/pr-assets/transcript-scroll-windows/04-roll-and-partial-still-reading.pngnew file mode 100644index 000000000..385617b3cBinary files /dev/null and b/docs/pr-assets/transcript-scroll-windows/04-roll-and-partial-still-reading.png differdiff --git a/docs/pr-assets/transcript-scroll-windows/05-hide-reopen-flushes-latest.png b/docs/pr-assets/transcript-scroll-windows/05-hide-reopen-flushes-latest.pngnew file mode 100644index 000000000..14b1dc0f8Binary files /dev/null and b/docs/pr-assets/transcript-scroll-windows/05-hide-reopen-flushes-latest.png differdiff --git a/docs/pr-assets/transcript-scroll-windows/06-paused-again.png b/docs/pr-assets/transcript-scroll-windows/06-paused-again.pngnew file mode 100644index 000000000..026c1c0caBinary files /dev/null and b/docs/pr-assets/transcript-scroll-windows/06-paused-again.png differdiff --git a/docs/pr-assets/transcript-scroll-windows/07-wheel-bottom-flushes-quiet-latest.png b/docs/pr-assets/transcript-scroll-windows/07-wheel-bottom-flushes-quiet-latest.pngnew file mode 100644index 000000000..14b1dc0f8Binary files /dev/null and b/docs/pr-assets/transcript-scroll-windows/07-wheel-bottom-flushes-quiet-latest.png differdiff --git a/docs/pr-assets/transcript-scroll-windows/README.md b/docs/pr-assets/transcript-scroll-windows/README.mdnew file mode 100644index 000000000..0f7b3d150--- /dev/null+++ b/docs/pr-assets/transcript-scroll-windows/README.md@@ -0,0 +1,13 @@+# Windows transcript scroll evidence++These privacy-safe images come from the synthetic native overlay fixture. The+fixture drives the real Win32 layered window and production command, wheel, and+update paths. Queue-ordered snapshots of the native controller state assert the+exact scroll offset and transcript bytes at every step. The committed PNGs are+separate offscreen `Renderer` captures of those returned states against a solid+backdrop, so no desktop, customer, or credential content is captured.++The sequence shows live follow, a frozen reading snapshot, repeated Show while+paused, rolling-feed eviction plus a same-length partial update, hide/reopen,+and an immediate return to the quiet live edge. This is not full live-app+acceptance and no narrated demo video is claimed.