╭ changed ─────────────╮ │src/ui/Repo/Header.zig│ ╰──────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────╮ │ 9 const Focus = xitui.focus.Focus; │ │10 │ │11 pub const AuthTab = @import("./../AuthTab.zig");│ │12 + │ │13 +const RefOrOid = ui.RoutablePage.RefOrOid; │ │14 │ │15 name: []const u8, │ │16 owner_name: []const u8, │ ╰────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │17 title: ui.Title, │ │18 auth_tab: AuthTab, │ │19 +// the ref/oid this page is viewing, so the files and commits tabs both link to│ │20 +// it (switching tabs keeps the same ref). the value is url-encoded. │ │21 +ref_or_oid: RefOrOid, │ │22 +ref_or_oid_value: []const u8, │ │23 │ │24 const Self = @This(); │ │25 │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │20 -pub fn init(arena: *std.heap.ArenaAllocator, name: []const u8, owner_name: []const u8) !Self { │ │26 +pub fn init(arena: *std.heap.ArenaAllocator, name: []const u8, owner_name: []const u8, ref_or_oid: RefOrOid, ref_or_oid_value: []const u8) !Self {│ │27 return .{ │ │28 .name = name, │ │29 .owner_name = owner_name, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────╮ │30 .title = try ui.Title.init(arena, name),│ │31 .auth_tab = AuthTab.init(), │ │32 + .ref_or_oid = ref_or_oid, │ │33 + .ref_or_oid_value = ref_or_oid_value, │ │34 }; │ │35 } │ │36 │ ╰────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 96 // the global settings or auth pages. the files tab routes through the │ │ 97 // shared helper so the /repo/.../files url format lives in one place. │ │ 98 const identity = try std.fmt.allocPrint(aa, "{s}/{s}", .{ data.owner_name, data.name }); │ │ 91 - const files_route = ui.RoutablePage.repoFilesRoute(identity, null, "", "") orelse return error.RouteTooLong; │ │ 99 + // both tabs link to the ref/oid this page is viewing, so switching tabs │ │100 + // keeps the same ref (the files tab opens at its root directory). │ │101 + const files_route = ui.RoutablePage.repoFilesRoute(identity, data.ref_or_oid, data.ref_or_oid_value, "") orelse return error.RouteTooLong; │ │102 const files_link = try std.fmt.allocPrint(aa, "a:{s}", .{try files_route.urlAlloc(session.page_arena)}); │ │ 93 - const commits_route = ui.RoutablePage.repoCommitsRoute(identity, null, "", 0) orelse return error.RouteTooLong; │ │103 + const commits_route = ui.RoutablePage.repoCommitsRoute(identity, data.ref_or_oid, data.ref_or_oid_value, 0) orelse return error.RouteTooLong;│ │104 const commits_link = try std.fmt.allocPrint(aa, "a:{s}", .{try commits_route.urlAlloc(session.page_arena)}); │ │105 const refs_link = try std.fmt.allocPrint(aa, "a:/repo/{s}/{s}/refs", .{ data.owner_name, data.name }); │ │106 const settings_link = try std.fmt.allocPrint(aa, "a:/repo/{s}/{s}/settings", .{ data.owner_name, data.name }); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯