╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ thread.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
2903 // a multiline input keeps enter and any up/down that has a row to move to 2904 fn multilineKeepsKey(text_input: *wgt.TextInput, allocator: std.mem.Allocator, key: Key) !bool { 2905 return switch (key) { 2906 .enter => true, 2907 .arrow_up => !try text_input.cursorOnFirstRow(allocator), 2908 .arrow_down => !try text_input.cursorOnLastRow(allocator), 2909 else => false, 2910 }; 2911 } 2912 2913 // the neighboring form control, skipping spacers and blank rows 2914 fn formStep(form: *wgt.Box(Widget), cur: usize, down: bool) ?usize { 2915 var i = cur; 2916 while (true) { 2917 if (down) { 2918 i += 1; 2919 if (i >= form.children.count()) return null; 2920 } else { 2921 if (i == 0) return null; 2922 i -= 1; 2923 } 2924 const child = &form.children.values()[i]; 2925 if (child.hidden) continue; 2926 switch (child.widget) { 2927 .spacer, .text => continue, 2928 else => return i, 2929 } 2930 } 2931 } 2932 2933 // focus the resolve-form child at `i` (a version row focuses its selected 2934 // child) and keep it visible on the terminal 2935 fn focusResolveChild(self: *This, form: *wgt.Box(Widget), i: usize, root_focus: *Focus) void { 2936 const child = &form.children.values()[i]; 2937 switch (child.widget) { 2938 .box => |*row| root_focus.setFocus(row.getFocus().child_id orelse form.children.keys()[i]), 2939 else => root_focus.setFocus(form.children.keys()[i]), 2940 } 2941 if (self.session.is_terminal) { 2942 if (self.resolveScroll()) |sc| { 2943 if (child.rect) |rect| sc.scrollToRect(rect); 2944 } 2945 } 2946 } 2947 2948 // re-emit the conflicted thread's event with the resolved content; any 2949 // event on the thread settles its conflict entry. this is the terminal 2950 // path; the web posts the form to the resolve route. 2951 fn submitResolution(self: *This, allocator: std.mem.Allocator) !void { 2952 if (comptime wasm) return; 2953 const io = self.session.io orelse return; 2954 const src = self.data.repo_source orelse return; 2955 const entry = self.data.selectedThread() orelse return; 2956 const author = ((try self.session.authorize(self.data.identity, .write, kind)) orelse return).author; 2957 const form = self.formBox() orelse return; 2958 2959 // gather the inputs by name; the d<n> hunk inputs appear in chunk order 2960 var title: ?[]u8 = null; 2961 var labels: ?[]u8 = null; 2962 var hunks: std.ArrayList([]const u8) = .empty; 2963 defer { 2964 if (title) |t| allocator.free(t); 2965 if (labels) |t| allocator.free(t); 2966 for (hunks.items) |h| allocator.free(h); 2967 hunks.deinit(allocator); 2968 } 2969 for (form.children.values()) |*child| switch (child.widget) { 2970 .text_input => |*ti| { 2971 const text = try ti.text(allocator); 2972 errdefer allocator.free(text); 2973 if (std.mem.eql(u8, ti.options.name, "title")) { 2974 title = text; 2975 } else if (std.mem.eql(u8, ti.options.name, "labels")) { 2976 labels = text; 2977 } else { 2978 try hunks.append(allocator, text); 2979 } 2980 }, 2981 else => {}, 2982 }; 2983 2984 const id_bytes = try evt.parseEventId(entry.id); 2985 2986 switch (src.repo_kind) { 2987 inline else => |repo_kind| { 2988 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2989 defer any_repo.deinit(io, allocator); 2990 switch (any_repo) { 2991 inline else => |*repo| { 2992 var resolution: Event.Resolve = .{ 2993 .title = title, 2994 .labels = labels, 2995 .hunks = hunks.items, 2996 }; 2997 if (comptime @hasField(Event.Resolve, "theirs")) resolution.theirs = self.data.theirs_picks; 2998 const change = Event.Update{ .resolve = resolution }; 2999 Event.update(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, change, author) catch |err| switch (err) { 3000 // leave the form up for correction 3001 error.InvalidFields => return, 3002 else => |e| return e, 3003 }; 3004 }, 3005 } 3006 }, 3007 } 3008 3009 const route = listRoute(self.data.identity, entryStatus(entry.*), entry.id) orelse return; 3010 try self.session.navigate(route); 3011 } 3012 3013 // commit a new or edited comment and navigate to its permalink. this is the 3014 // terminal path; the web posts the form to its comment route. 3015 fn submitComment(self: *This, allocator: std.mem.Allocator) !void { 3016 if (comptime wasm) return; 3017 const io = self.session.io orelse return; 3018 const src = self.data.repo_source orelse return; 3019 const actor = (try self.session.authorize(self.data.identity, .read, kind)) orelse return; 3020 const author = actor.author; 3021 const form = self.formBox() orelse return; 3022 const body_input = try formField(form, "body"); 3023 const body = try body_input.text(allocator); 3024 defer allocator.free(body); 3025 if (!evt.Comment.fieldsValid(body)) return; 3026 3027 var thread_id: [evt.event_id_size * 2]u8 = undefined; 3028 @memcpy(&thread_id, self.data.selected_id); 3029 const parent_id = if (self.data.comment_id.len == 0) thread_id else blk: { 3030 var parent: [evt.event_id_size * 2]u8 = undefined; 3031 @memcpy(&parent, self.data.comment_id); 3032 break :blk parent; 3033 }; 3034 var event_id_hex: [evt.event_id_size * 2]u8 = undefined; 3035 const editing = self.data.view == .edit_comment; 3036 if (editing) { 3037 const comment_id = evt.parseEventId(self.data.comment_id) catch return; 3038 if (!try src.canModify(io, allocator, actor, .comment, &comment_id)) return; 3039 } 3040 switch (src.repo_kind) { 3041 inline else => |repo_kind| { 3042 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 3043 defer any_repo.deinit(io, allocator); 3044 switch (any_repo) { 3045 inline else => |*repo| if (editing) { 3046 const comment_id = evt.parseEventId(self.data.comment_id) catch return; 3047 try evt.Comment.update(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, kind, &thread_id, &comment_id, body, author); 3048 event_id_hex = std.fmt.bytesToHex(comment_id, .lower); 3049 } else { 3050 event_id_hex = try evt.Comment.create(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, kind, &thread_id, &parent_id, body, author); 3051 }, 3052 } 3053 }, 3054 } 3055 3056 body_input.clear(allocator); 3057 const route = ui.RoutablePage.repoThreadCommentRoute(kind, self.data.identity, &thread_id, &event_id_hex, 0) orelse return; 3058 try self.session.navigate(route); 3059 } 3060 3061 // terminal form submissions; the web posts to the forms' routes instead 3062 fn submitForm(self: *This, allocator: std.mem.Allocator) !void { 3063 switch (self.data.view) { 3064 .new_comment, .edit_comment => try self.submitComment(allocator), 3065 .edit => try self.submitEditedThread(allocator), 3066 else => try self.submitNewThread(allocator), 3067 } 3068 } 3069 3070 // commit the new thread to the repo's events branch and navigate to it. 3071 // this is the terminal path; the web posts the form to the thread route, 3072 // so the wasm side never runs (or compiles) the repo access below. 3073 fn submitNewThread(self: *This, allocator: std.mem.Allocator) !void { 3074 if (comptime wasm) return; 3075 const io = self.session.io orelse return; 3076 const src = self.data.repo_source orelse return; 3077 const actor = (try self.session.authorize(self.data.identity, .read, kind)) orelse return; 3078 3079 const form = self.threadForm() orelse return; 3080 const title_input = try formField(form, "title"); 3081 const labels_input = try formField(form, "labels"); 3082 const description_input = try formField(form, "description"); 3083 3084 const title = try title_input.text(allocator); 3085 defer allocator.free(title); 3086 const labels = try labels_input.text(allocator); 3087 defer allocator.free(labels); 3088 const description = try description_input.text(allocator); 3089 defer allocator.free(description); 3090 const target_branch = if (comptime supports_drafts) try (try formField(form, "target_branch")).text(allocator) else ""; 3091 defer if (comptime supports_drafts) allocator.free(target_branch); 3092 3093 if (!Event.fieldsValid(title, labels)) { 3094 if (!evt.titleValid(title)) try self.rememberThreadFeedback(.required_title, title, labels, description, target_branch); 3095 return; 3096 } 3097 3098 if (comptime supports_drafts) { 3099 const source = formWidget(form, .patch_source) orelse return error.MissingFormField; 3100 const source_branch = switch (source.selectedKind()) { 3101 .fork => null, 3102 .branch => try source.field().text(allocator), 3103 }; 3104 defer if (source_branch) |branch| allocator.free(branch); 3105 const event_id_hex = Data.create(self.data, self.session, allocator, actor, title, labels, description, target_branch, source_branch) catch |err| { 3106 const failure = FeedbackFailure.fromError(err) orelse return err; 3107 try self.rememberThreadFeedback(failure, title, labels, description, target_branch); 3108 return; 3109 }; 3110 title_input.clear(allocator); 3111 labels_input.clear(allocator); 3112 description_input.clear(allocator); 3113 (try formField(form, "target_branch")).clear(allocator); 3114 const route = ui.RoutablePage.repoThreadCommentsRoute(kind, self.data.identity, &event_id_hex, 0) orelse return; 3115 try self.session.navigate(route); 3116 return; 3117 } 3118 3119 var id_bytes: [evt.event_id_size]u8 = undefined; 3120 io.random(&id_bytes); 3121 const event_id_hex = std.fmt.bytesToHex(id_bytes, .lower); 3122 3123 const event = evt.EventWithId{ 3124 .id = event_id_hex, 3125 .timestamp = @intCast(std.Io.Timestamp.now(io, .real).toSeconds()), 3126 .author = actor.author, 3127 .event = @unionInit(evt.Event, @tagName(kind), Event{ 3128 .title = title, 3129 .description = description, 3130 .labels = labels, 3131 }), 3132 }; 3133 3134 switch (src.repo_kind) { 3135 inline else => |repo_kind| { 3136 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 3137 defer any_repo.deinit(io, allocator); 3138 switch (any_repo) { 3139 inline else => |*repo| try evt.consume(self.session.eventHost(), .repo, repo_kind, repo.self_repo_opts, io, allocator, repo, evt.events_ref, &.{event}), 3140 } 3141 }, 3142 } 3143 3144 // wipe the form so a return visit starts fresh 3145 title_input.clear(allocator); 3146 labels_input.clear(allocator); 3147 description_input.clear(allocator); 3148 3149 const route = listRoute(self.data.identity, @fromBackingInt(@intCast(0)), &event_id_hex) orelse return; 3150 try self.session.navigate(route); 3151 } 3152 3153 // re-emit the selected thread's event with the form's content (status 3154 // preserved), then reload the thread's page. this is the terminal path; 3155 // the web posts the form to the edit route. 3156 fn submitEditedThread(self: *This, allocator: std.mem.Allocator) !void { 3157 if (comptime wasm) return; 3158 const io = self.session.io orelse return; 3159 const entry = self.data.selectedThread() orelse return; 3160 const actor = (try self.session.authorize(self.data.identity, .read, kind)) orelse return; 3161 const author = actor.author; 3162 3163 const form = self.threadForm() orelse return; 3164 const title_input = try formField(form, "title"); 3165 const labels_input = try formField(form, "labels"); 3166 const description_input = try formField(form, "description"); 3167 3168 const title = try title_input.text(allocator); 3169 defer allocator.free(title); 3170 const labels = try labels_input.text(allocator); 3171 defer allocator.free(labels); 3172 const description = try description_input.text(allocator); 3173 defer allocator.free(description); 3174 const target_branch = if (comptime supports_drafts) try (try formField(form, "target_branch")).text(allocator) else ""; 3175 defer if (comptime supports_drafts) allocator.free(target_branch); 3176 3177 if (!Event.fieldsValid(title, labels)) { 3178 if (!evt.titleValid(title)) try self.rememberThreadFeedback(.required_title, title, labels, description, target_branch); 3179 return; 3180 } 3181 const src = self.data.repo_source orelse return; 3182 3183 if (comptime supports_drafts) { 3184 if (entryDraft(entry.*)) { 3185 self.data.editDraft(self.session, allocator, author, entry.id, title, labels, description, target_branch) catch |err| { 3186 const failure = FeedbackFailure.fromError(err) orelse return err; 3187 try self.rememberThreadFeedback(failure, title, labels, description, target_branch); 3188 return; 3189 }; 3190 const route = listRoute(self.data.identity, entryStatus(entry.*), entry.id) orelse return; 3191 try self.session.navigate(route); 3192 return; 3193 } 3194 } 3195 3196 const id_bytes = try evt.parseEventId(entry.id); 3197 if (!try src.canModify(io, allocator, actor, kind, &id_bytes)) return; 3198 3199 switch (src.repo_kind) { 3200 inline else => |repo_kind| { 3201 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 3202 defer any_repo.deinit(io, allocator); 3203 switch (any_repo) { 3204 inline else => |*repo| if (supports_drafts) { 3205 Event.update(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .fields = .{ 3206 .title = title, 3207 .labels = labels, 3208 .description = description, 3209 .target_branch = target_branch, 3210 } }, author) catch |err| { 3211 const failure = FeedbackFailure.fromError(err) orelse return err; 3212 try self.rememberThreadFeedback(failure, title, labels, description, target_branch); 3213 return; 3214 }; 3215 } else if (has_status) 3216 try Event.update(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .fields = .{ 3217 .title = title, 3218 .labels = labels, 3219 .description = description, 3220 } }, author) 3221 else 3222 try Event.update(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, title, labels, description, author), 3223 } 3224 }, 3225 } 3226 3227 const route = listRoute(self.data.identity, entryStatus(entry.*), entry.id) orelse return; 3228 try self.session.navigate(route); 3229 } 3230 3231 fn rememberThreadFeedback(self: *This, failure: FeedbackFailure, title: []const u8, labels: []const u8, description: []const u8, target_branch: []const u8) !void { 3232 const aa = self.session.arena.allocator(); 3233 const source = if (supports_drafts) blk: { 3234 const form = self.threadForm() orelse break :blk null; 3235 break :blk formWidget(form, .patch_source); 3236 } else null; 3237 self.session.data.form_feedback = @unionInit(ui.Session.FormFeedback, @tagName(feedback_tag), .{ 3238 .failure = failure, 3239 .fields = if (comptime supports_drafts) .{ 3240 .title = try aa.dupe(u8, title), 3241 .labels = try aa.dupe(u8, labels), 3242 .description = try aa.dupe(u8, description), 3243 .target_branch = try aa.dupe(u8, target_branch), 3244 .source_branch = if (source) |value| try value.field().text(aa) else "", 3245 .source_kind = if (source) |value| value.selectedKind() else .fork, 3246 } else .{ 3247 .title = try aa.dupe(u8, title), 3248 .labels = try aa.dupe(u8, labels), 3249 .description = try aa.dupe(u8, description), 3250 }, 3251 }); 3252 } 3253 3254 fn submitConfirmation(self: *This, allocator: std.mem.Allocator, button_index: usize) !void { 3255 switch (confirmation(self.data.view) orelse return) { 3256 .publish => if (comptime supports_drafts) { 3257 if (comptime wasm) return; 3258 const entry = self.data.selectedThread() orelse return; 3259 if (!entryDraft(entry.*)) return; 3260 const author = ((try self.session.authorize(self.data.identity, .read, kind)) orelse return).author; 3261 try self.data.publishDraft(self.session, allocator, author, entry.id); 3262 const route = listRoute(self.data.identity, @fromBackingInt(@intCast(0)), entry.id) orelse return; 3263 try self.session.navigate(route); 3264 } else unreachable, 3265 .merge => if (comptime supports_merge) { 3266 if (comptime wasm) return; 3267 const entry = self.data.selectedThread() orelse return; 3268 const revision: evt.Patch.MergeRevision = if (button_index > 1) .squash else .source; 3269 if (!Data.canMerge(entry.*, self.session) or entry.mergeability.get(revision) != .clean) return; 3270 const author = ((try self.session.authorize(self.data.identity, .write, kind)) orelse return).author; 3271 self.data.mergePatch(self.session, allocator, author, entry.id, revision) catch |err| switch (err) { 3272 error.MergeConflict, error.MergeCheckUnavailable, error.PatchOutOfDate, error.PatchDataUnavailable => { 3273 const route = listRoute(self.data.identity, entryStatus(entry.*), entry.id) orelse return; 3274 try self.session.navigate(route); 3275 return; 3276 }, 3277 else => return err, 3278 }; 3279 const merged = std.meta.stringToEnum(Status, "merged") orelse return; 3280 const route = listRoute(self.data.identity, merged, entry.id) orelse return; 3281 try self.session.navigate(route); 3282 } else unreachable, 3283 .remove => try self.submitRemove(allocator), 3284 } 3285 } 3286 3287 fn submitRemove(self: *This, allocator: std.mem.Allocator) !void { 3288 const comment = self.data.comment_id.len != 0; 3289 const event_id = if (comment) self.data.comment_id else self.data.selected_id; 3290 const id = evt.parseEventId(event_id) catch return; 3291 try self.removeEvent(allocator, if (comment) .comment else kind, id); 3292 } 3293 3294 fn removeEvent(self: *This, allocator: std.mem.Allocator, event_kind: evt.EventKind, id: [evt.event_id_size]u8) !void { 3295 if (comptime wasm) return; 3296 const actor = (try self.session.authorize(self.data.identity, .read, kind)) orelse return; 3297 const author = actor.author; 3298 3299 if (comptime supports_drafts) { 3300 const selected = self.data.selectedThread() orelse return; 3301 if (event_kind == kind and entryDraft(selected.*)) { 3302 try Data.removeDraft(self.session, allocator, author, &id); 3303 const route = draftsRoute(self.data.identity) orelse return; 3304 try self.session.navigate(route); 3305 return; 3306 } 3307 } 3308 3309 const io = self.session.io orelse return; 3310 const src = self.data.repo_source orelse return; 3311 if (!try src.canModify(io, allocator, actor, event_kind, &id)) return; 3312 const thread_id = evt.parseEventId(self.data.selected_id) catch return; 3313 3314 switch (src.repo_kind) { 3315 inline else => |repo_kind| { 3316 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 3317 defer any_repo.deinit(io, allocator); 3318 switch (any_repo) { 3319 inline else => |*repo| try evt.removeInThread(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, kind, &thread_id, event_kind, &id, author), 3320 } 3321 }, 3322 } 3323 3324 const id_hex = std.fmt.bytesToHex(id, .lower); 3325 const route = ui.RoutablePage.repoEventsRoute(self.data.identity, .removed, event_kind, &id_hex, null) orelse return; 3326 try self.session.navigate(route); 3327 } 3328 3329 // enter the detail pane, landing on the way back to the list when it shows 3330 fn focusDetail(self: *This, index: usize, root_focus: *Focus) void { 3331 if (widget.listBackId(self.detailFrame(index)) != null) return widget.focusListBack(self.detailFrame(index), root_focus); 3332 _ = self.detail(index).focusFirst(root_focus); 3333 } 3334 3335 // return to the list. 3336 fn focusList(self: *This, index: usize, root_focus: *Focus) void { 3337 root_focus.setFocus(self.listScroll(index).getFocus().id); 3338 } 3339 3340 // cross to the header tabs above the stack. 3341 fn focusHeader(self: *This, root_focus: *Focus) void { 3342 root_focus.setFocus(self.box.children.keys()[header_index]); 3343 } 3344 3345 pub fn clearGrid(self: *This) void { 3346 self.box.clearGrid(); 3347 } 3348 3349 pub fn getGrid(self: This) ?Grid { 3350 return self.box.getGrid(); 3351 } 3352 3353 pub fn getFocus(self: *This) *Focus { 3354 return self.box.getFocus(); 3355 } 3356 3357 // for the parent's "scroll up at the top jumps to the header" check: at the 3358 // top only while the header tabs hold focus, so up from the split 3359 // crosses into the tabs first. 3360 pub fn atTop(self: *This) bool { 3361 return self.headerActive(); 3362 } 3363 }; 3364 } 3365