╭ changed ────────╮ │src/main_wasm.zig│ ╰─────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────╮ │32 var page_arena: ?std.heap.ArenaAllocator = null; │ │33 var snapshot: ?ui.Snapshot = null; │ │34 var session: ui.Session = .{}; │ │35 +// last current_page we told JS about. used to avoid pushing the URL on│ │36 +// every tick — we only call history.pushState when the tab actually │ │37 +// changes. │ │38 +var last_pushed_page: ?ui.RoutablePage = null; │ │39 │ │40 fn start(json: []const u8, min_height: u32, max_width: u32) !void { │ │41 if (page_arena) |*a| a.deinit(); │ ╰───────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │69 .min_size = .{ .width = null, .height = min_height }, │ │70 .max_size = .{ .width = max_width, .height = null }, │ │71 }, root_ptr.getFocus()); │ │72 + │ │73 + // mirror the page Header settled on into the browser URL. _pushState │ │74 + // is idempotent on the JS side (it bails when pathname already matches)│ │75 + // so the first tick after _start is a no-op even though we always send │ │76 + // something through. │ │77 + const current_page = session.data.current_page; │ │78 + if (last_pushed_page == null or last_pushed_page.? != current_page) { │ │79 + last_pushed_page = current_page; │ │80 + const url = current_page.url(); │ │81 + _pushState(url.ptr, @intCast(url.len)); │ │82 + } │ │83 + │ │84 try updateHtml(); │ │85 } │ │86 │ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │121 extern fn _consoleLog(arg: [*]const u8, len: u32) void; │ │122 extern fn _setHtml(arg: [*]const u8, len: u32) void; │ │123 extern fn _setOverlay(arg: [*]const u8, len: u32) void; │ │124 +extern fn _pushState(arg: [*]const u8, len: u32) void; │ │125 │ │126 /// js calls this first to get a wasm pointer it can write the page json into.│ │127 export fn _alloc(len: u32) ?[*]u8 { │ ╰───────────────────────────────────────────────────────────────────────────────────╯