╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ thread.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2520 }, 2521 .enter => if (on_submit) try self.submitResolution(allocator), 2522 .mouse => |mouse| if (on_submit) { 2523 if (inp.leftClickOn(root_focus, child.widget.submit_button.buttonId(), mouse)) try self.submitResolution(allocator); 2524 }, 2525 else => try child.widget.input(allocator, key, root_focus), 2526 } 2527 } 2528 2529 // a multiline input keeps enter and any up/down that has a row to move to 2530 fn multilineKeepsKey(text_input: *wgt.TextInput, allocator: std.mem.Allocator, key: Key) !bool { 2531 return switch (key) { 2532 .enter => true, 2533 .arrow_up => !try text_input.cursorOnFirstRow(allocator), 2534 .arrow_down => !try text_input.cursorOnLastRow(allocator), 2535 else => false, 2536 }; 2537 } 2538 2539 // the neighboring form control, skipping spacers and blank rows 2540 fn formStep(form: *wgt.Box(Widget), cur: usize, down: bool) ?usize { 2541 var i = cur; 2542 while (true) { 2543 if (down) { 2544 i += 1; 2545 if (i >= form.children.count()) return null; 2546 } else { 2547 if (i == 0) return null; 2548 i -= 1; 2549 } 2550 const child = &form.children.values()[i]; 2551 if (child.hidden) continue; 2552 switch (child.widget) { 2553 .spacer, .text => continue, 2554 else => return i, 2555 } 2556 } 2557 } 2558 2559 // focus the resolve-form child at `i` (a version row focuses its selected 2560 // child) and keep it visible on the terminal 2561 fn focusResolveChild(self: *This, form: *wgt.Box(Widget), i: usize, root_focus: *Focus) void { 2562 const child = &form.children.values()[i]; 2563 switch (child.widget) { 2564 .box => |*row| root_focus.setFocus(row.getFocus().child_id orelse form.children.keys()[i]), 2565 else => root_focus.setFocus(form.children.keys()[i]), 2566 } 2567 if (self.session.is_terminal) { 2568 if (self.resolveScroll()) |sc| { 2569 if (child.rect) |rect| sc.scrollToRect(rect); 2570 } 2571 } 2572 } 2573 2574 // re-emit the conflicted thread's event with the resolved content; any 2575 // event on the thread settles its conflict entry. this is the terminal 2576 // path; the web posts the form to the resolve route. 2577 fn submitResolution(self: *This, allocator: std.mem.Allocator) !void { 2578 if (comptime wasm) return; 2579 const io = self.session.io orelse return; 2580 const src = self.data.repo_source orelse return; 2581 const entry = self.data.selectedThread() orelse return; 2582 const author = ((try self.session.authorize(self.data.identity, .write)) orelse return).author; 2583 const form = self.formBox() orelse return; 2584 2585 // gather the inputs by name; the d<n> hunk inputs appear in chunk order 2586 var title: ?[]u8 = null; 2587 var labels: ?[]u8 = null; 2588 var hunks: std.ArrayList([]const u8) = .empty; 2589 defer { 2590 if (title) |t| allocator.free(t); 2591 if (labels) |t| allocator.free(t); 2592 for (hunks.items) |h| allocator.free(h); 2593 hunks.deinit(allocator); 2594 } 2595 for (form.children.values()) |*child| switch (child.widget) { 2596 .text_input => |*ti| { 2597 const text = try ti.text(allocator); 2598 errdefer allocator.free(text); 2599 if (std.mem.eql(u8, ti.options.name, "title")) { 2600 title = text; 2601 } else if (std.mem.eql(u8, ti.options.name, "labels")) { 2602 labels = text; 2603 } else { 2604 try hunks.append(allocator, text); 2605 } 2606 }, 2607 else => {}, 2608 }; 2609 2610 const id_bytes = try evt.parseEventId(entry.id); 2611 2612 switch (src.repo_kind) { 2613 inline else => |repo_kind| { 2614 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2615 defer any_repo.deinit(io, allocator); 2616 switch (any_repo) { 2617 inline else => |*repo| { 2618 var resolution: Event.Resolve = .{ 2619 .title = title, 2620 .labels = labels, 2621 .hunks = hunks.items, 2622 }; 2623 if (comptime @hasField(Event.Resolve, "theirs")) resolution.theirs = self.data.theirs_picks; 2624 const change = Event.Update{ .resolve = resolution }; 2625 Event.update(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, change, author) catch |err| switch (err) { 2626 // leave the form up for correction 2627 error.InvalidFields => return, 2628 else => |e| return e, 2629 }; 2630 }, 2631 } 2632 }, 2633 } 2634 2635 const route = listRoute(self.data.identity, entryStatus(entry.*), "", entry.id) orelse return; 2636 try self.session.navigate(route); 2637 } 2638 2639 // commit a new or edited comment and navigate to its permalink. this is the 2640 // terminal path; the web posts the form to its comment route. 2641 fn submitComment(self: *This, allocator: std.mem.Allocator) !void { 2642 if (comptime wasm) return; 2643 const io = self.session.io orelse return; 2644 const src = self.data.repo_source orelse return; 2645 const actor = (try self.session.authorize(self.data.identity, .read)) orelse return; 2646 const author = actor.author; 2647 const form = self.formBox() orelse return; 2648 const body_input = try formField(form, "body"); 2649 const body = try body_input.text(allocator); 2650 defer allocator.free(body); 2651 if (!evt.Comment.fieldsValid(body)) return; 2652 2653 var thread_id: [evt.event_id_size * 2]u8 = undefined; 2654 @memcpy(&thread_id, self.data.selected_id); 2655 const parent_id = if (self.data.comment_id.len == 0) thread_id else blk: { 2656 var parent: [evt.event_id_size * 2]u8 = undefined; 2657 @memcpy(&parent, self.data.comment_id); 2658 break :blk parent; 2659 }; 2660 var event_id_hex: [evt.event_id_size * 2]u8 = undefined; 2661 const editing = self.data.view == .edit_comment; 2662 if (editing) { 2663 const comment_id = evt.parseEventId(self.data.comment_id) catch return; 2664 if (!try src.canModify(io, allocator, actor, .comment, &comment_id)) return; 2665 } 2666 switch (src.repo_kind) { 2667 inline else => |repo_kind| { 2668 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2669 defer any_repo.deinit(io, allocator); 2670 switch (any_repo) { 2671 inline else => |*repo| if (editing) { 2672 const comment_id = evt.parseEventId(self.data.comment_id) catch return; 2673 try evt.Comment.update(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id, &comment_id, body, author); 2674 event_id_hex = std.fmt.bytesToHex(comment_id, .lower); 2675 } else { 2676 event_id_hex = try evt.Comment.create(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id, &parent_id, body, author); 2677 }, 2678 } 2679 }, 2680 } 2681 2682 body_input.clear(allocator); 2683 const route = ui.RoutablePage.repoThreadCommentRoute(kind, self.data.identity, &thread_id, &event_id_hex, 0) orelse return; 2684 try self.session.navigate(route); 2685 } 2686 2687 // terminal form submissions; the web posts to the forms' routes instead 2688 fn submitForm(self: *This, allocator: std.mem.Allocator) !void { 2689 switch (self.data.view) { 2690 .new_comment, .edit_comment => try self.submitComment(allocator), 2691 .edit => try self.submitEditedThread(allocator), 2692 else => try self.submitNewThread(allocator), 2693 } 2694 } 2695 2696 // commit the new thread to the repo's events branch and navigate to it. 2697 // this is the terminal path; the web posts the form to the thread route, 2698 // so the wasm side never runs (or compiles) the repo access below. 2699 fn submitNewThread(self: *This, allocator: std.mem.Allocator) !void { 2700 if (comptime wasm) return; 2701 const io = self.session.io orelse return; 2702 const src = self.data.repo_source orelse return; 2703 const actor = (try self.session.authorize(self.data.identity, .read)) orelse return; 2704 2705 const form = self.threadForm() orelse return; 2706 const title_input = try formField(form, "title"); 2707 const labels_input = try formField(form, "labels"); 2708 const description_input = try formField(form, "description"); 2709 2710 const title = try title_input.text(allocator); 2711 defer allocator.free(title); 2712 const labels = try labels_input.text(allocator); 2713 defer allocator.free(labels); 2714 const description = try description_input.text(allocator); 2715 defer allocator.free(description); 2716 const target_branch = if (comptime supports_drafts) try (try formField(form, "target_branch")).text(allocator) else ""; 2717 defer if (comptime supports_drafts) allocator.free(target_branch); 2718 2719 if (!Event.fieldsValid(title, labels)) { 2720 if (!evt.titleValid(title)) try self.rememberThreadFeedback(.required_title, title, labels, description, target_branch); 2721 return; 2722 } 2723 2724 if (comptime supports_drafts) { 2725 const source = formWidget(form, .patch_source) orelse return error.MissingFormField; 2726 const source_branch = switch (source.selectedKind()) { 2727 .fork => null, 2728 .branch => try source.field().text(allocator), 2729 }; 2730 defer if (source_branch) |branch| allocator.free(branch); 2731 const event_id_hex = Data.create(self.data, self.session, allocator, actor, title, labels, description, target_branch, source_branch) catch |err| { 2732 const failure = FeedbackFailure.fromError(err) orelse return err; 2733 try self.rememberThreadFeedback(failure, title, labels, description, target_branch); 2734 return; 2735 }; 2736 title_input.clear(allocator); 2737 labels_input.clear(allocator); 2738 description_input.clear(allocator); 2739 (try formField(form, "target_branch")).clear(allocator); 2740 const route = ui.RoutablePage.repoThreadCommentsRoute(kind, self.data.identity, &event_id_hex, 0) orelse return; 2741 try self.session.navigate(route); 2742 return; 2743 } 2744 2745 var id_bytes: [evt.event_id_size]u8 = undefined; 2746 io.random(&id_bytes); 2747 const event_id_hex = std.fmt.bytesToHex(id_bytes, .lower); 2748 2749 const event = evt.EventWithId{ 2750 .id = event_id_hex, 2751 .timestamp = @intCast(std.Io.Timestamp.now(io, .real).toSeconds()), 2752 .author = actor.author, 2753 .event = @unionInit(evt.Event, @tagName(kind), Event{ 2754 .title = title, 2755 .description = description, 2756 .labels = labels, 2757 }), 2758 }; 2759 2760 switch (src.repo_kind) { 2761 inline else => |repo_kind| { 2762 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2763 defer any_repo.deinit(io, allocator); 2764 switch (any_repo) { 2765 inline else => |*repo| try evt.consume(self.session.eventHost(), .repo, repo_kind, repo.self_repo_opts, io, allocator, repo, evt.events_ref, &.{event}), 2766 } 2767 }, 2768 } 2769 2770 // wipe the form so a return visit starts fresh 2771 title_input.clear(allocator); 2772 labels_input.clear(allocator); 2773 description_input.clear(allocator); 2774 2775 const route = listRoute(self.data.identity, @fromBackingInt(@intCast(0)), "", &event_id_hex) orelse return; 2776 try self.session.navigate(route); 2777 } 2778 2779 // re-emit the selected thread's event with the form's content (status 2780 // preserved), then reload the thread's page. this is the terminal path; 2781 // the web posts the form to the edit route. 2782 fn submitEditedThread(self: *This, allocator: std.mem.Allocator) !void { 2783 if (comptime wasm) return; 2784 const io = self.session.io orelse return; 2785 const entry = self.data.selectedThread() orelse return; 2786 const actor = (try self.session.authorize(self.data.identity, .read)) orelse return; 2787 const author = actor.author; 2788 2789 const form = self.threadForm() orelse return; 2790 const title_input = try formField(form, "title"); 2791 const labels_input = try formField(form, "labels"); 2792 const description_input = try formField(form, "description"); 2793 2794 const title = try title_input.text(allocator); 2795 defer allocator.free(title); 2796 const labels = try labels_input.text(allocator); 2797 defer allocator.free(labels); 2798 const description = try description_input.text(allocator); 2799 defer allocator.free(description); 2800 const target_branch = if (comptime supports_drafts) try (try formField(form, "target_branch")).text(allocator) else ""; 2801 defer if (comptime supports_drafts) allocator.free(target_branch); 2802 2803 if (!Event.fieldsValid(title, labels)) { 2804 if (!evt.titleValid(title)) try self.rememberThreadFeedback(.required_title, title, labels, description, target_branch); 2805 return; 2806 } 2807 const src = self.data.repo_source orelse return; 2808 2809 if (comptime supports_drafts) { 2810 if (entryDraft(entry.*)) { 2811 self.data.editDraft(self.session, allocator, author, entry.id, title, labels, description, target_branch) catch |err| { 2812 const failure = FeedbackFailure.fromError(err) orelse return err; 2813 try self.rememberThreadFeedback(failure, title, labels, description, target_branch); 2814 return; 2815 }; 2816 const route = listRoute(self.data.identity, entryStatus(entry.*), "", entry.id) orelse return; 2817 try self.session.navigate(route); 2818 return; 2819 } 2820 } 2821 2822 const id_bytes = try evt.parseEventId(entry.id); 2823 if (!try src.canModify(io, allocator, actor, kind, &id_bytes)) return; 2824 2825 switch (src.repo_kind) { 2826 inline else => |repo_kind| { 2827 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2828 defer any_repo.deinit(io, allocator); 2829 switch (any_repo) { 2830 inline else => |*repo| if (supports_drafts) { 2831 Event.update(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .fields = .{ 2832 .title = title, 2833 .labels = labels, 2834 .description = description, 2835 .target_branch = target_branch, 2836 } }, author) catch |err| { 2837 const failure = FeedbackFailure.fromError(err) orelse return err; 2838 try self.rememberThreadFeedback(failure, title, labels, description, target_branch); 2839 return; 2840 }; 2841 } else if (has_status) 2842 try Event.update(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .fields = .{ 2843 .title = title, 2844 .labels = labels, 2845 .description = description, 2846 } }, author) 2847 else 2848 try Event.update(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, title, labels, description, author), 2849 } 2850 }, 2851 } 2852 2853 const route = listRoute(self.data.identity, entryStatus(entry.*), "", entry.id) orelse return; 2854 try self.session.navigate(route); 2855 } 2856 2857 fn rememberThreadFeedback(self: *This, failure: FeedbackFailure, title: []const u8, labels: []const u8, description: []const u8, target_branch: []const u8) !void { 2858 const aa = self.session.arena.allocator(); 2859 const source = if (supports_drafts) blk: { 2860 const form = self.threadForm() orelse break :blk null; 2861 break :blk formWidget(form, .patch_source); 2862 } else null; 2863 self.session.data.form_feedback = @unionInit(ui.Session.FormFeedback, @tagName(feedback_tag), .{ 2864 .failure = failure, 2865 .fields = if (comptime supports_drafts) .{ 2866 .title = try aa.dupe(u8, title), 2867 .labels = try aa.dupe(u8, labels), 2868 .description = try aa.dupe(u8, description), 2869 .target_branch = try aa.dupe(u8, target_branch), 2870 .source_branch = if (source) |value| try value.field().text(aa) else "", 2871 .source_kind = if (source) |value| value.selectedKind() else .fork, 2872 } else .{ 2873 .title = try aa.dupe(u8, title), 2874 .labels = try aa.dupe(u8, labels), 2875 .description = try aa.dupe(u8, description), 2876 }, 2877 }); 2878 } 2879 2880 fn submitConfirmation(self: *This, allocator: std.mem.Allocator, button_index: usize) !void { 2881 switch (confirmation(self.data.view) orelse return) { 2882 .publish => if (comptime supports_drafts) { 2883 if (comptime wasm) return; 2884 const entry = self.data.selectedThread() orelse return; 2885 if (!entryDraft(entry.*)) return; 2886 const author = ((try self.session.authorize(self.data.identity, .read)) orelse return).author; 2887 try self.data.publishDraft(self.session, allocator, author, entry.id); 2888 const route = listRoute(self.data.identity, @fromBackingInt(@intCast(0)), "", entry.id) orelse return; 2889 try self.session.navigate(route); 2890 } else unreachable, 2891 .merge => if (comptime supports_merge) { 2892 if (comptime wasm) return; 2893 const entry = self.data.selectedThread() orelse return; 2894 const revision: evt.Patch.MergeRevision = if (button_index > 1) .squash else .source; 2895 if (!Data.canMerge(entry.*, self.session) or entry.mergeability.get(revision) != .clean) return; 2896 const author = ((try self.session.authorize(self.data.identity, .write)) orelse return).author; 2897 self.data.mergePatch(self.session, allocator, author, entry.id, revision) catch |err| switch (err) { 2898 error.MergeConflict, error.MergeCheckUnavailable, error.PatchOutOfDate, error.PatchDataUnavailable => { 2899 const route = listRoute(self.data.identity, entryStatus(entry.*), "", entry.id) orelse return; 2900 try self.session.navigate(route); 2901 return; 2902 }, 2903 else => return err, 2904 }; 2905 const merged = std.meta.stringToEnum(Status, "merged") orelse return; 2906 const route = listRoute(self.data.identity, merged, "", entry.id) orelse return; 2907 try self.session.navigate(route); 2908 } else unreachable, 2909 .remove => try self.submitRemove(allocator), 2910 } 2911 } 2912 2913 fn submitRemove(self: *This, allocator: std.mem.Allocator) !void { 2914 const comment = self.data.comment_id.len != 0; 2915 const event_id = if (comment) self.data.comment_id else self.data.selected_id; 2916 const id = evt.parseEventId(event_id) catch return; 2917 try self.removeEvent(allocator, if (comment) .comment else kind, id); 2918 } 2919 2920 fn removeEvent(self: *This, allocator: std.mem.Allocator, event_kind: evt.EventKind, id: [evt.event_id_size]u8) !void { 2921 if (comptime wasm) return; 2922 const actor = (try self.session.authorize(self.data.identity, .read)) orelse return; 2923 const author = actor.author; 2924 2925 if (comptime supports_drafts) { 2926 const selected = self.data.selectedThread() orelse return; 2927 if (event_kind == kind and entryDraft(selected.*)) { 2928 try Data.removeDraft(self.session, allocator, author, &id); 2929 const route = draftsRoute(self.data.identity) orelse return; 2930 try self.session.navigate(route); 2931 return; 2932 } 2933 } 2934 2935 const io = self.session.io orelse return; 2936 const src = self.data.repo_source orelse return; 2937 if (!try src.canModify(io, allocator, actor, event_kind, &id)) return; 2938 2939 switch (src.repo_kind) { 2940 inline else => |repo_kind| { 2941 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2942 defer any_repo.deinit(io, allocator); 2943 switch (any_repo) { 2944 inline else => |*repo| try evt.remove(self.session.eventHost(), .repo, repo_kind, repo.self_repo_opts, io, allocator, repo, &id, event_kind, author), 2945 } 2946 }, 2947 } 2948 2949 const id_hex = std.fmt.bytesToHex(id, .lower); 2950 const route = ui.RoutablePage.repoEventsRoute(self.data.identity, .removed, event_kind, &id_hex, null) orelse return; 2951 try self.session.navigate(route); 2952 } 2953 2954 // return to the list. 2955 fn focusList(self: *This, index: usize, root_focus: *Focus) void { 2956 root_focus.setFocus(self.listScroll(index).getFocus().id); 2957 } 2958 2959 // cross to the header tabs above the stack. 2960 fn focusHeader(self: *This, root_focus: *Focus) void { 2961 root_focus.setFocus(self.box.children.keys()[header_index]); 2962 } 2963 2964 pub fn clearGrid(self: *This) void { 2965 self.box.clearGrid(); 2966 } 2967 2968 pub fn getGrid(self: This) ?Grid { 2969 return self.box.getGrid(); 2970 } 2971 2972 pub fn getFocus(self: *This) *Focus { 2973 return self.box.getFocus(); 2974 } 2975 2976 // for the parent's "scroll up at the top jumps to the header" check: at the 2977 // top only while the header tabs hold focus, so up from the split 2978 // crosses into the tabs first. 2979 pub fn atTop(self: *This) bool { 2980 return self.headerActive(); 2981 } 2982 }; 2983 } 2984