╭ changed ────────╮ │src/ui/widget.zig│ ╰─────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────╮ │1018 pub fn init( │ │1019 allocator: std.mem.Allocator, │ │1020 session: *ui.Session, │ │1021 - location: ui.RoutablePage.RepoLocation,│ │1021 + handle: ui.RepoHandle, │ │1022 label: []const u8, │ │1023 name: []const u8, │ │1024 text: ?[]const u8, │ ╰─────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────╮ │1043 } │ │1044 │ │1045 if (session.data.host_kind == .server) { │ │1046 - if (try CopyableText.initClone(allocator, session, location)) |value| {│ │1046 + if (try CopyableText.initClone(allocator, session, handle)) |value| { │ │1047 var clone_url = value; │ │1048 errdefer clone_url.deinit(allocator); │ │1049 const min_width = clone_url.minWidth(); │ ╰─────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1782 choices: []Choice, │ │1783 selected: usize = 0, │ │1784 │ │1785 - pub fn init(allocator: std.mem.Allocator, session: *ui.Session, choices: []const Choice) !CopyableText { │ │1785 + pub fn init(allocator: std.mem.Allocator, session: *ui.Session, choices: []const Choice, initial: usize) !CopyableText {│ │1786 if (choices.len == 0) return error.MissingCopyableText; │ │1787 │ │1788 const owned_choices = try allocator.dupe(Choice, choices); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────╮ │1801 var text_input = try wgt.TextInput.init(allocator, .{│ │1802 .border_style = .single, │ │1803 .round_corners = true, │ │1804 - .label = choices[0].label, │ │1805 - .bottom_label = choices[0].bottom_label, │ │1804 + .label = choices[initial].label, │ │1805 + .bottom_label = choices[initial].bottom_label, │ │1806 .read_only = true, │ │1807 .render_content = session.is_terminal, │ │1808 .visible_width = null, │ ╰───────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1809 }); │ │1810 errdefer text_input.deinit(allocator); │ │1811 text_input.getFocus().mode = .all; │ │1812 - try text_input.setContent(allocator, choices[0].text); │ │1812 + try text_input.setContent(allocator, choices[initial].text); │ │1813 box.getFocus().child_id = text_input.getFocus().id; │ │1814 try box.children.put(allocator, text_input.getFocus().id, .{ .widget = .{ .text_input = text_input }, .rect = null, .min_size = null, .flex = .shrink });│ │1815 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1816 - return .{ .box = box, .session = session, .choices = owned_choices }; │ │1816 + return .{ .box = box, .session = session, .choices = owned_choices, .selected = initial }; │ │1817 } │ │1818 │ │1819 - pub fn initClone(allocator: std.mem.Allocator, session: *ui.Session, location: ui.RoutablePage.RepoLocation) !?CopyableText {│ │1819 + pub fn initClone(allocator: std.mem.Allocator, session: *ui.Session, handle: ui.RepoHandle) !?CopyableText { │ │1820 const aa = session.page_arena.allocator(); │ │1821 var choices: [2]Choice = undefined; │ │1822 var count: usize = 0; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1823 - switch (location) { │ │1823 + var ssh_index: ?usize = null; │ │1824 + switch (handle.location) { │ │1825 .repo => |identity| { │ │1826 if (session.data.git_http_port) |port| { │ │1827 const url = try std.fmt.allocPrint(aa, "http://localhost:{d}/repo/{s}", .{ port, identity });│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1834 count += 1; │ │1835 } │ │1836 if (session.data.git_ssh_port) |port| { │ │1837 + ssh_index = count; │ │1838 const url = try std.fmt.allocPrint(aa, "ssh://localhost:{d}/repo/{s}", .{ port, identity });│ │1839 choices[count] = .{ │ │1840 .selector = "ssh", │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │1856 }, │ │1857 } │ │1858 if (count == 0) return null; │ │1857 - return @as(?CopyableText, try init(allocator, session, choices[0..count])); │ │1859 + // a viewer who can push starts on the ssh url │ │1860 + const initial = if (handle.canWrite()) ssh_index orelse 0 else 0; │ │1861 + return @as(?CopyableText, try init(allocator, session, choices[0..count], initial));│ │1862 } │ │1863 │ │1864 pub fn minWidth(self: *const CopyableText) usize { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯