mere-kernel 0.0.1

Portable identity, authority, and mutation kernel for the Mere browser. Renamed from graphshell-core.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
// Copyright 2026 Mark AB (markik)
// SPDX-License-Identifier: MIT OR Apache-2.0

//! Portable action catalogue.
//!
//! The shell's command surfaces (command palette, context palette,
//! radial palette) share a single enumerated vocabulary of actions
//! (`ActionId`) grouped into logical families (`ActionCategory`). The
//! pre-M4-slice-1 home for these types was `render::action_registry`
//! in the graphshell crate, which also carried host-coupled helpers
//! (input-binding lookup, action-registry-driven `ActionContext`
//! filtering). This module splits off the portable leaves so that
//! downstream portable state — `CommandPaletteSession`'s Tier 1
//! selection, the omnibar's action-match types, future iced-host
//! action-dispatch — can reference the vocabulary without pulling in
//! the host-side registry machinery.
//!
//! The render-side [`render::action_registry`] module re-exports the
//! symbols here for zero-churn at call sites; host-coupled helpers
//! (`ActionId::shortcut_hints`, the `ActionContext` / `ActionEntry`
//! filtering surface, the `list_actions_for_context` resolver) stay
//! alongside the re-exports.

use serde::{Deserialize, Serialize};

/// Preferred input mode, used as a layout hint by control surfaces.
///
/// `InputMode` is not a gate; surfaces may use it to choose their
/// default presentation.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default, Serialize, Deserialize)]
pub enum InputMode {
    #[default]
    MouseKeyboard,
}

/// Logical grouping of actions, used for separators and ordering in
/// the command palette and as sector grouping in the radial palette.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Serialize, Deserialize)]
pub enum ActionCategory {
    Node,
    Edge,
    Graph,
    Persistence,
}

/// Persistent-storage key for the recency ring used by palette ranking.
pub const CATEGORY_RECENCY_PERSIST_KEY: &str = "command_palette_category_recency";

/// Persistent-storage key for user-pinned category ordering.
pub const CATEGORY_PIN_ORDER_PERSIST_KEY: &str = "command_palette_category_pins";

impl ActionCategory {
    /// Display label for the category group heading.
    pub fn label(self) -> &'static str {
        match self {
            Self::Node => "Node",
            Self::Edge => "Edge",
            Self::Graph => "Graph",
            Self::Persistence => "Persistence",
        }
    }
}

/// Canonical base ordering for action categories in command surfaces.
/// Callers may re-rank based on context, recency, and user pinning;
/// this is the default when no other signal applies.
pub fn default_category_order() -> [ActionCategory; 4] {
    [
        ActionCategory::Node,
        ActionCategory::Edge,
        ActionCategory::Graph,
        ActionCategory::Persistence,
    ]
}

/// Stable machine-readable name for a category. Used when persisting
/// user preferences (pin order, recency ring) across sessions.
pub fn category_persisted_name(category: ActionCategory) -> &'static str {
    match category {
        ActionCategory::Node => "node",
        ActionCategory::Edge => "edge",
        ActionCategory::Graph => "graph",
        ActionCategory::Persistence => "persistence",
    }
}

/// Inverse of [`category_persisted_name`]. Returns `None` for unknown
/// names so callers can decide whether to fall back to a default or
/// surface a diagnostic.
pub fn category_from_persisted_name(name: &str) -> Option<ActionCategory> {
    match name {
        "node" => Some(ActionCategory::Node),
        "edge" => Some(ActionCategory::Edge),
        "graph" => Some(ActionCategory::Graph),
        "persistence" => Some(ActionCategory::Persistence),
        _ => None,
    }
}

/// Stable identifier for a registered action.
///
/// Each variant corresponds to one logical operation. The action
/// content (label, category, enabled state) is resolved at runtime
/// via the render-side `list_actions_for_context` resolver so that
/// control surfaces remain free of hardcoded dispatch tables.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, Serialize, Deserialize)]
pub enum ActionId {
    // Node actions
    NodeNew,
    NodeNewAsTab,
    NodePinToggle,
    NodePinSelected,
    NodeUnpinSelected,
    NodeDelete,
    NodeEditTags,
    NodeChooseFrame,
    NodeAddToFrame,
    NodeAddConnectedToFrame,
    NodeOpenFrame,
    NodeOpenNeighbors,
    NodeOpenConnected,
    NodeOpenSplit,
    NodeDetachToSplit,
    NodeMoveToActivePane,
    NodeWarmSelect,
    NodeRemoveFromGraphlet,
    NodeImportWebFinger,
    NodeResolveNip05,
    NodeResolveMatrix,
    NodeResolveActivityPub,
    NodeRefreshPersonIdentity,
    /// Soft-delete selected nodes → Ghost Node (Tombstone lifecycle).
    NodeMarkTombstone,
    NodeCopyUrl,
    NodeCopyTitle,
    NodeRenderAuto,
    NodeRenderWebView,
    NodeRenderWry,
    // Edge actions
    EdgeConnectPair,
    EdgeConnectBoth,
    EdgeRemoveUser,
    // Graph actions
    GraphFit,
    GraphFitGraphlet,
    GraphCycleFocusRegion,
    GraphToggleOverviewPlane,
    GraphTogglePhysics,
    /// Toggle per-view ghost node (tombstone) visibility.
    GraphToggleGhostNodes,
    GraphPhysicsConfig,
    GraphCommandPalette,
    GraphRadialMenu,
    WorkbenchToggleOverlay,
    FrameSelect,
    FrameOpen,
    FrameOpenAsSplit,
    FrameRename,
    FrameSettings,
    FrameSuppressSplitOffer,
    FrameDelete,
    FrameEnableSplitOffer,
    WorkbenchUnlockSurfaceLayout,
    WorkbenchLockSurfaceLayout,
    WorkbenchRememberLayoutPreference,
    WorkbenchGroupSelectedTiles,
    // Persistence actions
    PersistUndo,
    PersistRedo,
    PersistSaveSnapshot,
    PersistRestoreSession,
    PersistSaveGraph,
    PersistRestoreLatestGraph,
    PersistOpenHub,
    PersistImportBookmarks,
    WorkbenchOpenSettingsPane,
    WorkbenchOpenSettingsOverlay,
    PersistOpenHistoryManager,
    WorkbenchActivateWorkflowDefault,
    WorkbenchActivateWorkflowResearch,
    WorkbenchActivateWorkflowReading,
}

impl ActionId {
    /// Stable `namespace:name` identifier for persistence, logging,
    /// and diagnostic routing. Never changes for a given variant.
    pub fn key(self) -> &'static str {
        match self {
            Self::NodeNew => "node:new",
            Self::NodeNewAsTab => "node:new_as_tab",
            Self::NodePinToggle => "node:pin_toggle",
            Self::NodePinSelected => "node:pin_selected",
            Self::NodeUnpinSelected => "node:unpin_selected",
            Self::NodeDelete => "node:delete",
            Self::NodeEditTags => "node:edit_tags",
            Self::NodeChooseFrame => "node:choose_frame",
            Self::NodeAddToFrame => "node:add_to_frame",
            Self::NodeAddConnectedToFrame => "node:add_connected_to_frame",
            Self::NodeOpenFrame => "node:open_frame",
            Self::NodeOpenNeighbors => "node:open_neighbors",
            Self::NodeOpenConnected => "node:open_connected",
            Self::NodeOpenSplit => "node:open_split",
            Self::NodeDetachToSplit => "node:detach_to_split",
            Self::NodeMoveToActivePane => "node:move_to_active_pane",
            Self::NodeWarmSelect => "node:warm_select",
            Self::NodeRemoveFromGraphlet => "node:remove_from_graphlet",
            Self::NodeImportWebFinger => "node:import_webfinger",
            Self::NodeResolveNip05 => "node:resolve_nip05",
            Self::NodeResolveMatrix => "node:resolve_matrix",
            Self::NodeResolveActivityPub => "node:resolve_activitypub",
            Self::NodeRefreshPersonIdentity => "node:refresh_person_identity",
            Self::NodeMarkTombstone => "node:mark_tombstone",
            Self::NodeCopyUrl => "node:copy_url",
            Self::NodeCopyTitle => "node:copy_title",
            Self::NodeRenderAuto => "node:render_auto",
            Self::NodeRenderWebView => "node:render_webview",
            Self::NodeRenderWry => "node:render_wry",
            Self::EdgeConnectPair => "edge:connect_pair",
            Self::EdgeConnectBoth => "edge:connect_both",
            Self::EdgeRemoveUser => "edge:remove_user",
            Self::GraphFit => "graph:fit",
            Self::GraphFitGraphlet => "graph:fit_graphlet",
            Self::GraphCycleFocusRegion => "graph:cycle_focus_region",
            Self::GraphToggleOverviewPlane => "graph:toggle_overview_plane",
            Self::GraphTogglePhysics => "graph:toggle_physics",
            Self::GraphToggleGhostNodes => "graph:toggle_ghost_nodes",
            Self::GraphPhysicsConfig => "graph:physics_config",
            Self::GraphCommandPalette => "workbench:command_palette_open",
            Self::GraphRadialMenu => "workbench:radial_menu_open",
            Self::WorkbenchToggleOverlay => "workbench:toggle_workbench_overlay",
            Self::FrameSelect => "frame:select",
            Self::FrameOpen => "frame:open",
            Self::FrameOpenAsSplit => "frame:open_as_split",
            Self::FrameRename => "frame:rename",
            Self::FrameSettings => "frame:settings",
            Self::FrameSuppressSplitOffer => "frame:suppress_split_offer",
            Self::FrameDelete => "frame:delete",
            Self::FrameEnableSplitOffer => "frame:enable_split_offer",
            Self::WorkbenchUnlockSurfaceLayout => "workbench:unlock_surface_layout",
            Self::WorkbenchLockSurfaceLayout => "workbench:lock_surface_layout",
            Self::WorkbenchRememberLayoutPreference => "workbench:remember_layout_preference",
            Self::WorkbenchGroupSelectedTiles => "workbench:group_selected_tiles",
            Self::PersistUndo => "persistence:undo",
            Self::PersistRedo => "persistence:redo",
            Self::PersistSaveSnapshot => "persistence:save_snapshot",
            Self::PersistRestoreSession => "persistence:restore_session",
            Self::PersistSaveGraph => "persistence:save_graph",
            Self::PersistRestoreLatestGraph => "persistence:restore_latest_graph",
            Self::PersistOpenHub => "persistence:open_hub",
            Self::PersistImportBookmarks => "import:bookmarks_from_file",
            Self::WorkbenchOpenSettingsPane => "workbench:settings_pane",
            Self::WorkbenchOpenSettingsOverlay => "workbench:settings_overlay",
            Self::PersistOpenHistoryManager => "workbench:open_history_manager",
            Self::WorkbenchActivateWorkflowDefault => "workbench:activate_workflow_default",
            Self::WorkbenchActivateWorkflowResearch => "workbench:activate_workflow_research",
            Self::WorkbenchActivateWorkflowReading => "workbench:activate_workflow_reading",
        }
    }

    /// Short label suitable for a radial menu sector (≤ 12 chars).
    pub fn short_label(self) -> &'static str {
        match self {
            Self::NodeNew => "New",
            Self::NodeNewAsTab => "New Tab",
            Self::NodePinToggle => "Pin",
            Self::NodePinSelected => "Pin",
            Self::NodeUnpinSelected => "Unpin",
            Self::NodeDelete => "Delete",
            Self::NodeEditTags => "Tags",
            Self::NodeChooseFrame => "Choose F",
            Self::NodeAddToFrame => "Add F",
            Self::NodeAddConnectedToFrame => "Add Conn F",
            Self::NodeOpenFrame => "Frame",
            Self::NodeOpenNeighbors => "Neighbors",
            Self::NodeOpenConnected => "Connected",
            Self::NodeOpenSplit => "Split",
            Self::NodeDetachToSplit => "Detach",
            Self::NodeMoveToActivePane => "Move",
            Self::NodeWarmSelect => "Open Cold",
            Self::NodeRemoveFromGraphlet => "Leave Group",
            Self::NodeImportWebFinger => "WebFinger",
            Self::NodeResolveNip05 => "NIP-05",
            Self::NodeResolveMatrix => "Matrix",
            Self::NodeResolveActivityPub => "ActivityPub",
            Self::NodeRefreshPersonIdentity => "Refresh Identity",
            Self::NodeMarkTombstone => "Ghost",
            Self::NodeCopyUrl => "Copy URL",
            Self::NodeCopyTitle => "Copy Title",
            Self::NodeRenderAuto => "Auto",
            Self::NodeRenderWebView => "WebView",
            Self::NodeRenderWry => "Wry",
            Self::EdgeConnectPair => "Pair",
            Self::EdgeConnectBoth => "Both",
            Self::EdgeRemoveUser => "Remove",
            Self::GraphFit => "Fit",
            Self::GraphFitGraphlet => "Fit Graphlet",
            Self::GraphCycleFocusRegion => "Focus",
            Self::GraphToggleOverviewPlane => "Overview",
            Self::GraphTogglePhysics => "Physics",
            Self::GraphToggleGhostNodes => "Ghosts",
            Self::GraphPhysicsConfig => "Config",
            Self::GraphCommandPalette => "Cmd",
            Self::GraphRadialMenu => "Radial",
            Self::WorkbenchToggleOverlay => "Workbench Ovl",
            Self::FrameSelect => "Select F",
            Self::FrameOpen => "Open F",
            Self::FrameOpenAsSplit => "Split F",
            Self::FrameRename => "Rename F",
            Self::FrameSettings => "F Settings",
            Self::FrameSuppressSplitOffer => "Suppress",
            Self::FrameDelete => "Delete F",
            Self::FrameEnableSplitOffer => "Re-enable",
            Self::WorkbenchUnlockSurfaceLayout => "Unlock",
            Self::WorkbenchLockSurfaceLayout => "Lock",
            Self::WorkbenchRememberLayoutPreference => "Remember",
            Self::WorkbenchGroupSelectedTiles => "Group Tiles",
            Self::PersistUndo => "Undo",
            Self::PersistRedo => "Redo",
            Self::PersistSaveSnapshot => "Save W",
            Self::PersistRestoreSession => "Restore W",
            Self::PersistSaveGraph => "Save G",
            Self::PersistRestoreLatestGraph => "Latest G",
            Self::PersistOpenHub => "Persist Ovl",
            Self::PersistImportBookmarks => "Import Bm",
            Self::WorkbenchOpenSettingsPane => "Set Pane",
            Self::WorkbenchOpenSettingsOverlay => "Set Ovl",
            Self::PersistOpenHistoryManager => "History",
            Self::WorkbenchActivateWorkflowDefault => "Workflow D",
            Self::WorkbenchActivateWorkflowResearch => "Workflow R",
            Self::WorkbenchActivateWorkflowReading => "Workflow Read",
        }
    }

    /// Full label suitable for the command palette list.
    pub fn label(self) -> &'static str {
        match self {
            Self::NodeNew => "Create Node",
            Self::NodeNewAsTab => "Create Node as Tab",
            Self::NodePinToggle => "Toggle Pin",
            Self::NodePinSelected => "Pin Selected",
            Self::NodeUnpinSelected => "Unpin Selected",
            Self::NodeDelete => "Delete Selected Node(s)",
            Self::NodeEditTags => "Edit Tags...",
            Self::NodeChooseFrame => "Choose Frame...",
            Self::NodeAddToFrame => "Add To Frame...",
            Self::NodeAddConnectedToFrame => "Add Connected To Frame...",
            Self::NodeOpenFrame => "Open via Frame Route",
            Self::NodeOpenNeighbors => "Open with Neighbors",
            Self::NodeOpenConnected => "Open with Connected",
            Self::NodeOpenSplit => "Open Node in Split",
            Self::NodeDetachToSplit => "Detach Focused to Split",
            Self::NodeMoveToActivePane => "Move Node to Active Pane",
            Self::NodeWarmSelect => "Open Cold Selection as Tiles",
            Self::NodeRemoveFromGraphlet => "Remove from Graphlet",
            Self::NodeImportWebFinger => "Import WebFinger Discovery",
            Self::NodeResolveNip05 => "Resolve NIP-05 Identity",
            Self::NodeResolveMatrix => "Resolve Matrix Profile",
            Self::NodeResolveActivityPub => "Import ActivityPub Actor",
            Self::NodeRefreshPersonIdentity => "Refresh Person Identity",
            Self::NodeMarkTombstone => "Ghost Selected Node(s)",
            Self::NodeCopyUrl => "Copy Node URL",
            Self::NodeCopyTitle => "Copy Node Title",
            Self::NodeRenderAuto => "Render With Auto",
            Self::NodeRenderWebView => "Render With WebView",
            Self::NodeRenderWry => "Render With Wry",
            Self::EdgeConnectPair => "Connect Source -> Target",
            Self::EdgeConnectBoth => "Connect Both Directions",
            Self::EdgeRemoveUser => "Remove User Edge",
            Self::GraphFit => "Fit Graph to Screen",
            Self::GraphFitGraphlet => "Fit Graphlet to Screen",
            Self::GraphCycleFocusRegion => "Cycle Focus Region",
            Self::GraphToggleOverviewPlane => "Toggle Overview Plane",
            Self::GraphTogglePhysics => "Toggle Physics Simulation",
            Self::GraphToggleGhostNodes => "Toggle Ghost Node Visibility",
            Self::GraphPhysicsConfig => "Open Physics Settings",
            Self::GraphCommandPalette => "Open Command Palette",
            Self::GraphRadialMenu => "Open Radial Palette",
            Self::WorkbenchToggleOverlay => "Toggle Workbench Overlay",
            Self::FrameSelect => "Select Frame",
            Self::FrameOpen => "Open Frame",
            Self::FrameOpenAsSplit => "Open Frame As Split",
            Self::FrameRename => "Rename Frame",
            Self::FrameSettings => "Open Frame Settings",
            Self::FrameSuppressSplitOffer => "Suppress Split Offer",
            Self::FrameDelete => "Delete Frame",
            Self::FrameEnableSplitOffer => "Re-enable Split Offer",
            Self::WorkbenchUnlockSurfaceLayout => "Unlock Surface Layout",
            Self::WorkbenchLockSurfaceLayout => "Lock Surface Layout",
            Self::WorkbenchRememberLayoutPreference => "Remember Layout Preference",
            Self::WorkbenchGroupSelectedTiles => "Group Selected Tiles",
            Self::PersistUndo => "Undo",
            Self::PersistRedo => "Redo",
            Self::PersistSaveSnapshot => "Save Frame Snapshot",
            Self::PersistRestoreSession => "Restore Session Frame",
            Self::PersistSaveGraph => "Save Graph Snapshot",
            Self::PersistRestoreLatestGraph => "Restore Latest Graph",
            Self::PersistOpenHub => "Open Persistence Overlay",
            Self::PersistImportBookmarks => "Import Browser Bookmarks...",
            Self::WorkbenchOpenSettingsPane => "Open Settings Pane",
            Self::WorkbenchOpenSettingsOverlay => "Open Settings Overlay",
            Self::PersistOpenHistoryManager => "Open History Manager",
            Self::WorkbenchActivateWorkflowDefault => "Activate Default Workflow",
            Self::WorkbenchActivateWorkflowResearch => "Activate Research Workflow",
            Self::WorkbenchActivateWorkflowReading => "Activate Reading Workflow",
        }
    }

    /// Logical category for grouping in command surfaces.
    pub fn category(self) -> ActionCategory {
        match self {
            Self::NodeNew
            | Self::NodeNewAsTab
            | Self::NodePinToggle
            | Self::NodePinSelected
            | Self::NodeUnpinSelected
            | Self::NodeDelete
            | Self::NodeEditTags
            | Self::NodeChooseFrame
            | Self::NodeAddToFrame
            | Self::NodeAddConnectedToFrame
            | Self::NodeOpenFrame
            | Self::NodeOpenNeighbors
            | Self::NodeOpenConnected
            | Self::NodeOpenSplit
            | Self::NodeDetachToSplit
            | Self::NodeMoveToActivePane
            | Self::NodeCopyUrl
            | Self::NodeCopyTitle
            | Self::NodeRenderAuto
            | Self::NodeRenderWebView
            | Self::NodeRenderWry
            | Self::NodeWarmSelect
            | Self::NodeRemoveFromGraphlet
            | Self::NodeImportWebFinger
            | Self::NodeResolveNip05
            | Self::NodeResolveMatrix
            | Self::NodeResolveActivityPub
            | Self::NodeRefreshPersonIdentity
            | Self::NodeMarkTombstone => ActionCategory::Node,
            Self::EdgeConnectPair | Self::EdgeConnectBoth | Self::EdgeRemoveUser => {
                ActionCategory::Edge
            }
            Self::GraphFit
            | Self::GraphFitGraphlet
            | Self::GraphCycleFocusRegion
            | Self::GraphToggleOverviewPlane
            | Self::GraphTogglePhysics
            | Self::GraphToggleGhostNodes
            | Self::GraphPhysicsConfig
            | Self::GraphCommandPalette
            | Self::GraphRadialMenu
            | Self::WorkbenchToggleOverlay
            | Self::FrameSelect
            | Self::FrameOpen
            | Self::FrameOpenAsSplit
            | Self::FrameRename
            | Self::FrameSettings
            | Self::FrameSuppressSplitOffer
            | Self::FrameDelete
            | Self::FrameEnableSplitOffer
            | Self::WorkbenchUnlockSurfaceLayout
            | Self::WorkbenchLockSurfaceLayout
            | Self::WorkbenchRememberLayoutPreference
            | Self::WorkbenchGroupSelectedTiles => ActionCategory::Graph,
            Self::PersistUndo
            | Self::PersistRedo
            | Self::PersistSaveSnapshot
            | Self::PersistRestoreSession
            | Self::PersistSaveGraph
            | Self::PersistRestoreLatestGraph
            | Self::PersistOpenHub
            | Self::PersistImportBookmarks
            | Self::WorkbenchOpenSettingsPane
            | Self::WorkbenchOpenSettingsOverlay
            | Self::PersistOpenHistoryManager
            | Self::WorkbenchActivateWorkflowDefault
            | Self::WorkbenchActivateWorkflowResearch
            | Self::WorkbenchActivateWorkflowReading => ActionCategory::Persistence,
        }
    }
}

/// Every `ActionId` variant. Useful for generators (settings UI that
/// lists every keybinding, doc exporters, consistency audits) and
/// the render-side dispatch table that wires each variant's enabled
/// predicate into the palette context.
///
/// Returning `&'static [ActionId]` keeps this zero-allocation and
/// embeddable in `const` contexts.
pub fn all_action_ids() -> &'static [ActionId] {
    use ActionId::*;
    &[
        NodeNew,
        NodeNewAsTab,
        NodePinToggle,
        NodePinSelected,
        NodeUnpinSelected,
        NodeDelete,
        NodeEditTags,
        NodeChooseFrame,
        NodeAddToFrame,
        NodeAddConnectedToFrame,
        NodeOpenFrame,
        NodeOpenNeighbors,
        NodeOpenConnected,
        NodeOpenSplit,
        NodeDetachToSplit,
        NodeMoveToActivePane,
        NodeCopyUrl,
        NodeCopyTitle,
        NodeRenderAuto,
        NodeRenderWebView,
        NodeRenderWry,
        NodeWarmSelect,
        NodeRemoveFromGraphlet,
        NodeImportWebFinger,
        NodeResolveNip05,
        NodeResolveMatrix,
        NodeResolveActivityPub,
        NodeRefreshPersonIdentity,
        NodeMarkTombstone,
        EdgeConnectPair,
        EdgeConnectBoth,
        EdgeRemoveUser,
        GraphFit,
        GraphFitGraphlet,
        GraphCycleFocusRegion,
        GraphToggleOverviewPlane,
        GraphTogglePhysics,
        GraphToggleGhostNodes,
        GraphPhysicsConfig,
        GraphCommandPalette,
        GraphRadialMenu,
        WorkbenchToggleOverlay,
        FrameSelect,
        FrameOpen,
        FrameOpenAsSplit,
        FrameRename,
        FrameSettings,
        FrameSuppressSplitOffer,
        FrameDelete,
        FrameEnableSplitOffer,
        WorkbenchUnlockSurfaceLayout,
        WorkbenchLockSurfaceLayout,
        WorkbenchRememberLayoutPreference,
        WorkbenchGroupSelectedTiles,
        PersistUndo,
        PersistRedo,
        PersistSaveSnapshot,
        PersistRestoreSession,
        PersistSaveGraph,
        PersistRestoreLatestGraph,
        PersistOpenHub,
        PersistImportBookmarks,
        WorkbenchOpenSettingsPane,
        WorkbenchOpenSettingsOverlay,
        PersistOpenHistoryManager,
        WorkbenchActivateWorkflowDefault,
        WorkbenchActivateWorkflowResearch,
        WorkbenchActivateWorkflowReading,
    ]
}

/// `true` when `id` matches the `namespace:name` key format the
/// registry enforces for cross-surface routing. Both `namespace` and
/// `name` must be lowercase ASCII alphanumerics plus `_`; exactly one
/// `:` separator; no empty parts.
pub fn action_id_has_namespace_format(id: &str) -> bool {
    let mut parts = id.split(':');
    let Some(namespace) = parts.next() else {
        return false;
    };
    let Some(name) = parts.next() else {
        return false;
    };
    if parts.next().is_some() || namespace.is_empty() || name.is_empty() {
        return false;
    }
    namespace
        .chars()
        .all(|ch| ch.is_ascii_lowercase() || ch.is_ascii_digit() || ch == '_')
        && name
            .chars()
            .all(|ch| ch.is_ascii_lowercase() || ch.is_ascii_digit() || ch == '_')
}