╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ─────────────╮ │src/ui/Repo/Header.zig│ ╰──────────────────────╯ ╭────────────────────────────────────────────────────╮ │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 }); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ───────────╮ │src/ui/Repo/Refs.zig│ ╰────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │183 // window-navigation rows bracket the names: "← previous" off the │ │184 // first window, "next →" when more remain. each is a full reload. │ │185 if (after > 0) try addRow(allocator, &rows, "← previous", try windowLink(session.page_arena, identity, kind, after -| page_size));│ │186 - for (names) |name| try addRow(allocator, &rows, name, null); │ │186 + // each ref name links to the files tab at that ref's root. │ │187 + for (names) |name| try addRow(allocator, &rows, name, try refLink(session.page_arena, identity, kind, name)); │ │188 if (next_after) |na| try addRow(allocator, &rows, "next →", try windowLink(session.page_arena, identity, kind, na)); │ │189 │ │190 if (rows.children.count() > 0) rows.getFocus().child_id = rows.children.keys()[0]; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │364 const route = ui.RoutablePage.repoRefsRoute(identity, kind, after) orelse return error.RouteTooLong; │ │365 const url = try route.urlAlloc(page_arena); │ │366 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); │ │367 +} │ │368 + │ │369 +// the "a:" link to the files tab at ref `name` (a branch or tag) within │ │370 +// `identity` ("owner/name"), at its root directory. the name is percent-encoded │ │371 +// since it can contain a '/'. │ │372 +fn refLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, kind: ui.RoutablePage.RefKind, name: []const u8) ![]const u8 {│ │373 + const aa = page_arena.allocator(); │ │374 + const ref_or_oid: ui.RoutablePage.RefOrOid = switch (kind) { │ │375 + .branch => .branch, │ │376 + .tag => .tag, │ │377 + }; │ │378 + const value = try ui.ResolvedRefOrOid.urlEncode(aa, name); │ │379 + const route = ui.RoutablePage.repoFilesRoute(identity, ref_or_oid, value, "") orelse return error.RouteTooLong; │ │380 + const url = try route.urlAlloc(page_arena); │ │381 + return std.fmt.allocPrint(aa, "a:{s}", .{url}); │ │382 } │ │383 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯