╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ──────╮ │src/ui/User.zig│ ╰───────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │250 try box.children.put(allocator, stack.getFocus().id, .{ .widget = .{ .stack = stack }, .rect = null, .min_size = null });│ │251 } │ │252 │ │257 - var self = View{ .box = box, .data = data, .session = session }; │ │253 + var self = View{ .box = box }; │ │254 self.getFocus().child_id = box.children.keys()[header_index]; │ │255 return self; │ │256 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │264 const header = &self.box.children.values()[header_index].widget.user_header; │ │265 const stack = &self.box.children.values()[stack_index].widget.stack; │ │266 │ │271 - // each header tab maps 1:1 to a stack child by position. mirror the │ │272 - // selection into current_page so the host can push the matching url; │ │273 - // all user tabs share the .user parent, so this stays on the page │ │274 - // rather than navigating. │ │275 - if (header.getSelectedIndex()) |index| { │ │267 + // each header tab maps 1:1 to a stack child by position │ │268 + if (header.getSelectedIndex()) |index| │ │269 stack.getFocus().child_id = stack.children.keys()[index]; │ │277 - const name = self.data.route_name; │ │278 - switch (index) { │ │279 - 0 => self.session.data.current_page = .{ .user_repos = .{ .name = name, .start = self.data.repos_start } },│ │280 - 1 => self.session.data.current_page = .{ .user_forks = .{ .name = name, .start = self.data.forks_start } },│ │281 - else => switch (std.meta.activeTag(stack.children.values()[index])) { │ │282 - .home_settings => self.session.data.current_page = .{ .user_settings = name }, │ │283 - .home_auth => self.session.data.current_page = .{ .user_auth = name }, │ │284 - // the quit tab is tty-only and not a route, so leave current_page │ │285 - // alone (nothing to mirror into the url). │ │286 - .quit => {}, │ │287 - else => {}, │ │288 - }, │ │289 - } │ │290 - } │ │270 try self.box.build(allocator, constraint, root_focus); │ │271 } │ │272 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ─────────────╮ │src/ui/User/Header.zig│ ╰──────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │27 │ │28 pub const View = struct { │ │29 scroll: wgt.Scroll(ui.Widget), │ │30 - data: *const Self, │ │30 tab_ids: std.AutoArrayHashMapUnmanaged(usize, void), │ │31 │ │32 pub fn init(allocator: std.mem.Allocator, data: *const Self, session: *ui.Session) !View {│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │70 // still followed with js off. allocated in the page arena so the focus │ │71 // kinds that borrow them live as long as this page's widget tree. │ │72 const aa = session.page_arena.allocator(); │ │74 - const repos_link = try std.fmt.allocPrint(aa, "ai:/user/{s}", .{data.name}); │ │75 - const forks_link = try std.fmt.allocPrint(aa, "ai:/user/{s}/forks", .{data.name}); │ │76 - const settings_link = try std.fmt.allocPrint(aa, "ai:/user/{s}/settings", .{data.name}); │ │77 - const auth_link = try std.fmt.allocPrint(aa, "ai:/user/{s}/auth", .{data.name}); │ │73 + const current_page = session.data.current_page; │ │74 + const current_tag = std.meta.activeTag(current_page); │ │75 + const current_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try current_page.toUrl(session.page_arena)}); │ │76 + const repos_link = if (current_tag == .user_repos) current_link else try std.fmt.allocPrint(aa, "ai:/user/{s}", .{data.name}); │ │77 + const forks_link = if (current_tag == .user_forks) current_link else try std.fmt.allocPrint(aa, "ai:/user/{s}/forks", .{data.name}); │ │78 + const settings_link = if (current_tag == .user_settings) current_link else try std.fmt.allocPrint(aa, "ai:/user/{s}/settings", .{data.name});│ │79 + const auth_link = if (current_tag == .user_auth) current_link else try std.fmt.allocPrint(aa, "ai:/user/{s}/auth", .{data.name}); │ │80 │ │81 // the tab matching the current page is focused initially; matching by │ │82 // link (rather than position) keeps this robust to tab changes. │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────╮ │81 - const current_link: []const u8 = switch (session.data.current_page) {│ │83 + const selected_link: []const u8 = switch (current_page) { │ │84 .user_settings => settings_link, │ │85 .user_auth => auth_link, │ │86 .user_forks => forks_link, │ ╰─────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 95 text_box.getFocus().focusable = true; │ │ 96 text_box.getFocus().kind = .{ .custom = repos_link }; │ │ 97 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │ 96 - if (std.mem.eql(u8, repos_link, current_link)) selected_tab = text_box.getFocus().id; │ │ 98 + if (std.mem.eql(u8, repos_link, selected_link)) selected_tab = text_box.getFocus().id;│ │ 99 try box.children.put(allocator, text_box.getFocus().id, .{ │ │100 .widget = .{ .text_box = text_box }, │ │101 .rect = null, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮ │110 text_box.getFocus().focusable = true; │ │111 text_box.getFocus().kind = .{ .custom = forks_link }; │ │112 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │111 - if (std.mem.eql(u8, forks_link, current_link)) selected_tab = text_box.getFocus().id; │ │113 + if (std.mem.eql(u8, forks_link, selected_link)) selected_tab = text_box.getFocus().id;│ │114 try box.children.put(allocator, text_box.getFocus().id, .{ │ │115 .widget = .{ .text_box = text_box }, │ │116 .rect = null, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │137 text_box.getFocus().focusable = true; │ │138 text_box.getFocus().kind = .{ .custom = settings_link }; │ │139 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │138 - if (std.mem.eql(u8, settings_link, current_link)) selected_tab = text_box.getFocus().id; │ │140 + if (std.mem.eql(u8, settings_link, selected_link)) selected_tab = text_box.getFocus().id;│ │141 try box.children.put(allocator, text_box.getFocus().id, .{ │ │142 .widget = .{ .text_box = text_box }, │ │143 .rect = null, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │152 errdefer auth_tab.deinit(allocator); │ │153 auth_tab.text_box.getFocus().kind = .{ .custom = auth_link }; │ │154 try tab_ids.put(allocator, auth_tab.getFocus().id, {}); │ │153 - if (std.mem.eql(u8, auth_link, current_link)) selected_tab = auth_tab.getFocus().id; │ │155 + if (std.mem.eql(u8, auth_link, selected_link)) selected_tab = auth_tab.getFocus().id;│ │156 try box.children.put(allocator, auth_tab.getFocus().id, .{ │ │157 .widget = .{ .auth_tab = auth_tab }, │ │158 .rect = null, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │177 │ │178 var self = View{ │ │179 .scroll = try wgt.Scroll(ui.Widget).init(allocator, .{ .box = box }, .{ .direction = .horiz, .show_bar = false, .web_native = !session.is_terminal }),│ │178 - .data = data, │ │180 .tab_ids = tab_ids, │ │181 }; │ │182 self.getFocus().child_id = selected_tab orelse self.tab_ids.keys()[0]; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯