subspace_dashboard/lib.rs
1//! The dashboard interface. Every dashboard is a crate that implements
2//! [`Dashboard`] for one GPUI view; the app lists each dashboard once, in
3//! `framework/host/app/src/registry.rs`, and drives it through [`DashboardHandle`].
4//!
5//! The app shell owns the window, the dashboard switcher, the ⌘K palette,
6//! help, toasts, wrap, the density jig and reload; a dashboard owns its view,
7//! its toolbar controls, its commands, its item search and its keys. A
8//! dashboard talks to the shell with [`DashboardEvent`]s and reads the shell's
9//! choices from globals ([`Wrap`], [`Density`], [`Services`]).
10//!
11//! Dashboards that show grouped rows with a detail panel implement
12//! [`ListDashboard`] too and render with [`list::render`].
13
14pub mod action;
15pub mod activity_mark;
16pub mod alerts;
17pub mod anchored;
18pub mod animated_collapsible;
19pub mod artwork;
20pub mod avatar;
21pub mod badge;
22pub mod chart;
23pub mod chat_bubble;
24pub mod chat_input;
25pub mod chat_sessions;
26pub mod code;
27pub mod composer;
28pub mod context_text;
29pub mod contracts;
30pub mod contrast;
31pub mod copy_details;
32pub mod dates;
33pub mod density;
34pub mod dialog;
35pub mod dock_panel;
36pub mod feedback;
37pub mod fields;
38pub mod find_in_page;
39pub mod github_sign_in;
40pub mod glass;
41pub mod help;
42pub mod html;
43pub mod icon_button;
44pub mod images;
45pub mod links;
46pub mod list;
47pub mod markdown_editor;
48// Keep the bundled editor's upstream API intact for its own tests and updates.
49#[allow(dead_code, unused_imports)]
50#[path = "../vendor/markdown-editor/src/lib.rs"]
51mod markdown_engine;
52extern crate gpui_kit as gpui;
53pub mod measure;
54pub mod media;
55pub mod menu;
56pub mod native_grid;
57pub mod notifications;
58pub mod overflow_toolbar;
59pub mod panel;
60pub mod prefetch;
61pub mod prefs;
62mod product;
63pub mod reference_card;
64pub mod refresh;
65pub mod repositories;
66pub mod retained;
67pub mod reveal;
68pub mod rich;
69pub mod row_menu;
70pub mod search_adapter;
71pub mod secret;
72pub mod settings;
73pub mod slider;
74pub mod surface_header;
75pub mod tabs;
76#[cfg(feature = "test-support")]
77pub mod test_support;
78pub mod toggle;
79pub mod tokens;
80pub mod toolbar_label;
81pub mod truncated;
82pub mod typography;
83pub mod workspace;
84
85use std::sync::Arc;
86use std::time::Duration;
87
88use gpui_kit::{
89 AnyElement, App, Context, EventEmitter, Focusable, Global, KeyBinding, Render, SharedString,
90 Window, actions,
91};
92use subspace_core::config::Config;
93use subspace_core::credentials::Credentials;
94use subspace_core::search::SearchIndex;
95
96/// How long a toast stays: longer for an error or one with a link, which
97/// the user may want to act on.
98const SHORT_TOAST: Duration = Duration::from_secs(4);
99const LONG_TOAST: Duration = Duration::from_secs(8);
100
101pub use artwork::BoardArtwork;
102pub use chat_input::{ChatInput, ChatInputEvent};
103pub use density::{Density, DensityPreview};
104pub use list::{Body, Detail, Glyph, Group, ListDashboard, ListState, Row, Section, ServiceLink};
105pub use product::CurrentProduct;
106pub use row_menu::RowMenu;
107pub use subspace_agent_model::ContextRef as AgentContext;
108pub use subspace_agent_tools::{AgentTool, Catalog, HelpImage, ToolEnvironment};
109pub use subspace_core::search::SearchDoc;
110pub use tokens::{ThemeId, ThemeTones, Tokens, Tone};
111pub use typography::{Typography, heading_font};
112
113actions!(
114 subspace,
115 [
116 /// Open connection settings for the visible dashboard.
117 ConfigureBoard,
118 /// Select the next visible row or group header.
119 SelectNext,
120 /// Select the previous visible row or group header.
121 SelectPrevious,
122 /// Select the first line.
123 SelectFirst,
124 /// Select the last line.
125 SelectLast,
126 /// Open the selected row's details, or fold or unfold the selected group.
127 Activate,
128 /// Close the detail panel.
129 CloseDetail,
130 /// Add the selected row and its open details to the Copilot chat.
131 AddToChat,
132 /// Add the text selected in a detail pane to the Copilot chat.
133 AddSelectionToChat,
134 ]
135);
136
137/// Key context of a dashboard's view.
138pub const DASHBOARD_CONTEXT: &str = "Dashboard";
139/// Key context of menus and dialogs: shell and dashboard keys stay off while
140/// one has focus (REQ-06).
141pub const MODAL_CONTEXT: &str = "SubspaceModal";
142/// Context owned by a dashboard that routes raw keys to its focused view.
143pub const RAW_KEYS_CONTEXT: &str = "SubspaceRawKeys";
144
145/// The key context predicate for keys without `secondary`, `ctrl` or `alt`
146/// in the view named `context`: they do not act while a text field, a menu or
147/// a dialog has focus (REQ-06), nor while a view that owns raw keys has it,
148/// because a plain key belongs to that view instead. Dashboards bind their
149/// own plain keys with `Some(&view_keys(Self::ID))`.
150///
151/// A dashboard key that does carry `secondary`, `ctrl` or `alt` keeps acting
152/// inside a raw-key view, because the shell reserves those combinations: bind
153/// it against `"{context} && !SubspaceModal"` instead.
154pub fn view_keys(context: &str) -> String {
155 format!("{context} && !Input && !{MODAL_CONTEXT} && !{RAW_KEYS_CONTEXT}")
156}
157
158/// App keys remain available unless a dashboard owns raw-key input.
159pub fn app_keys() -> String {
160 format!("!{RAW_KEYS_CONTEXT}")
161}
162
163/// The keystrokes `keys` with the secondary modifier: `cmd` on macOS and
164/// `ctrl` elsewhere. `KeyBinding::new` takes only explicit modifiers, so
165/// `secondary!("shift-c")` stands for the `secondary-shift-c` keymap form.
166#[macro_export]
167macro_rules! secondary {
168 ($keys:literal) => {
169 if cfg!(target_os = "macos") {
170 concat!("cmd-", $keys)
171 } else {
172 concat!("ctrl-", $keys)
173 }
174 };
175}
176
177#[cfg(test)]
178mod painted_border;
179
180#[cfg(test)]
181mod key_context_tests {
182 use super::{RAW_KEYS_CONTEXT, app_keys, view_keys};
183
184 #[test]
185 fn app_keys_excludes_raw_key_context() {
186 assert_eq!(RAW_KEYS_CONTEXT, "SubspaceRawKeys");
187 assert_eq!(app_keys(), "!SubspaceRawKeys");
188 }
189
190 #[test]
191 fn plain_view_keys_stand_down_in_a_raw_key_view() {
192 assert_eq!(
193 view_keys("Subspace"),
194 "Subspace && !Input && !SubspaceModal && !SubspaceRawKeys"
195 );
196 }
197}
198
199/// The list keys every [`ListDashboard`] shares and the keys of the shared
200/// components. The app binds them once.
201pub fn bind_keys(cx: &mut App) {
202 let context = view_keys(DASHBOARD_CONTEXT);
203 let context = Some(context.as_str());
204 cx.bind_keys([
205 KeyBinding::new("j", SelectNext, context),
206 KeyBinding::new("down", SelectNext, context),
207 KeyBinding::new("k", SelectPrevious, context),
208 KeyBinding::new("up", SelectPrevious, context),
209 KeyBinding::new("home", SelectFirst, context),
210 KeyBinding::new("end", SelectLast, context),
211 KeyBinding::new("enter", Activate, context),
212 KeyBinding::new("escape", CloseDetail, context),
213 KeyBinding::new("escape", find_in_page::Close, context),
214 ]);
215 menu::bind_keys(cx);
216 composer::bind_keys(cx);
217 chat_input::bind_keys(cx);
218 panel::bind_keys(cx);
219}
220
221/// Help rows for the list keys, before a dashboard's own keys.
222pub const LIST_KEYS: &[KeyHelp] = &[
223 KeyHelp::new("j / ↓", "Next row"),
224 KeyHelp::new("k / ↑", "Previous row"),
225 KeyHelp::new("Enter", "Open details, or fold or unfold a group"),
226 KeyHelp::new("Esc", "Close details"),
227];
228
229/// One row of the help overlay: a key and what it does.
230#[derive(Debug, Clone, Copy, PartialEq, Eq)]
231pub struct KeyHelp {
232 pub key: &'static str,
233 pub meaning: &'static str,
234}
235
236impl KeyHelp {
237 pub const fn new(key: &'static str, meaning: &'static str) -> Self {
238 Self { key, meaning }
239 }
240}
241
242// ---- Events: dashboard to shell -------------------------------------------------
243
244#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
245pub enum ToastTone {
246 #[default]
247 Info,
248 Error,
249}
250
251/// A link in a toast. Only `https` links show.
252#[derive(Debug, Clone, PartialEq, Eq)]
253pub struct ToastLink {
254 pub href: SharedString,
255 pub label: SharedString,
256}
257
258/// A short message at the bottom left (REQ-12).
259#[derive(Debug, Clone, PartialEq, Eq)]
260pub struct Toast {
261 pub text: SharedString,
262 pub tone: ToastTone,
263 pub link: Option<ToastLink>,
264}
265
266impl Toast {
267 pub fn info(text: impl Into<SharedString>) -> Self {
268 Self {
269 text: text.into(),
270 tone: ToastTone::Info,
271 link: None,
272 }
273 }
274
275 pub fn error(text: impl Into<SharedString>) -> Self {
276 Self {
277 tone: ToastTone::Error,
278 ..Self::info(text)
279 }
280 }
281
282 pub fn link(mut self, href: impl Into<SharedString>, label: impl Into<SharedString>) -> Self {
283 self.link = Some(ToastLink {
284 href: href.into(),
285 label: label.into(),
286 });
287 self
288 }
289
290 /// 4 s for information, 8 s for an error or a toast with a link.
291 pub fn duration(&self) -> Duration {
292 match self.tone == ToastTone::Error || self.link.is_some() {
293 true => LONG_TOAST,
294 false => SHORT_TOAST,
295 }
296 }
297}
298
299/// Which palette to open: commands then items (⌘K), or items only (`/`).
300#[derive(Debug, Clone, Copy, PartialEq, Eq)]
301pub enum PaletteMode {
302 Commands,
303 Items,
304}
305
306/// A cloud agent task to replay in a chat tab. The dashboard that lists the
307/// tasks knows the id, the name and the page; the chat pane connects.
308#[derive(Debug, Clone, PartialEq, Eq)]
309pub struct CloudSession {
310 /// The GitHub cloud agent task id.
311 pub task_id: SharedString,
312 /// The task's name, shown until the session reports its own.
313 pub title: SharedString,
314 /// The task's session page on GitHub, empty when the row has none.
315 pub url: SharedString,
316}
317
318/// What a dashboard asks of the Copilot chat pane the shell owns. The chat
319/// pane holds the one agent runtime, so a dashboard never touches it
320/// directly; it reads [`chat_sessions::sessions`] and asks with this.
321#[derive(Debug, Clone, PartialEq, Eq)]
322pub enum ChatRequest {
323 /// Ask the runtime for a fresh saved-session list.
324 ListSessions,
325 /// Show the saved session in a chat tab, opening the pane when closed.
326 OpenSession(SharedString),
327 /// Replay a cloud agent task's last session in a read-only chat tab.
328 OpenCloudSession(CloudSession),
329 /// Open a validated local search citation in the visible Subspace board.
330 OpenInSubspace(SharedString),
331 /// Refresh the board currently visible beside chat.
332 RefreshVisibleBoard,
333}
334
335/// What a dashboard asks of the shell. Emit with `cx.emit(...)`.
336#[derive(Debug, Clone, PartialEq)]
337pub enum DashboardEvent {
338 Toast(Toast),
339 OpenPalette(PaletteMode),
340 /// An item's details opened; the shell adds it to the recent items of
341 /// the item search. The value is the item's [`SearchDoc::id`].
342 Opened(SharedString),
343 /// Show the board that answers a contract and open a link it owns.
344 Navigate(BoardNavigation),
345 /// Return to a view the person came from, as an issue page's Back does.
346 /// The shell shows `board` and asks it to restore `location`. When
347 /// either no longer exists, the shell stays on the requesting board and
348 /// says so, so the requester shows its own fallback first.
349 Return(ReturnPoint),
350 /// Something the Copilot chat pane should do.
351 Chat(ChatRequest),
352 /// The dashboard wrote the config file through a checked immediate edit
353 /// and updated [`Services::config`], as [`repositories::apply`] does. The
354 /// shell rebuilds the agent tools and the MCP catalog from it.
355 ConfigChanged,
356}
357
358#[derive(Debug, Clone, PartialEq, Eq)]
359pub struct BoardNavigation {
360 pub responder: contracts::MessageKey,
361 pub url: SharedString,
362 /// The place in the requesting board the link was followed from, such
363 /// as the channel whose issue chip was clicked. A Back on the
364 /// destination returns there. `None` uses the requester's
365 /// [`Dashboard::return_location`] at the time of the request.
366 pub origin: Option<ReturnLocation>,
367}
368
369/// A view the person was on: a board and, optionally, a place in it that
370/// the board restores itself. The shell records one each time it changes the
371/// current board, the *last view*, and gives it to the board it shows with
372/// [`Dashboard::arrived_from`].
373#[derive(Debug, Clone, PartialEq, Eq)]
374pub struct ReturnPoint {
375 /// The board's id.
376 pub board: &'static str,
377 /// What Back names, such as `#discovery` or `PRs`.
378 pub label: SharedString,
379 /// The board's own key for the place, from
380 /// [`Dashboard::return_location`]; `None` returns to the board as it is.
381 pub location: Option<SharedString>,
382}
383
384impl ReturnPoint {
385 /// The text of a Back control that returns here, such as
386 /// *Back to #discovery*.
387 // qual:api - Consumed by app crates through the Framework facade.
388 pub fn back_label(&self) -> SharedString {
389 back_label(&self.label)
390 }
391}
392
393/// The longest destination a Back label shows before it is shortened.
394const BACK_LABEL_CHARS: usize = 32;
395
396/// *Back to* `destination`, shortened with an ellipsis when it is long.
397// qual:api - Consumed by app crates through the Framework facade.
398pub fn back_label(destination: &str) -> SharedString {
399 let mut chars = destination.chars();
400 let short: String = chars.by_ref().take(BACK_LABEL_CHARS).collect();
401 let ellipsis = if chars.next().is_some() { "…" } else { "" };
402 format!("Back to {short}{ellipsis}").into()
403}
404
405/// A place in a board that a later Back can return to.
406#[derive(Debug, Clone, PartialEq, Eq)]
407pub struct ReturnLocation {
408 /// What Back names, such as `#discovery`.
409 pub label: SharedString,
410 /// The board's own key, given back to [`Dashboard::return_to`]. It is
411 /// opaque to the shell and other boards.
412 pub key: SharedString,
413}
414
415/// While a dashboard shows a menu, keys go to the menu and ⌘K closes it
416/// first; while it shows a dialog, keys go to the dialog only (REQ-06).
417#[derive(Debug, Clone, Copy, PartialEq, Eq)]
418pub enum Modal {
419 Menu,
420 Dialog,
421}
422
423// ---- Palette commands -------------------------------------------------------------
424
425mod palette;
426
427pub use palette::{
428 Callback, CommandRun, ItemSearch, PaletteCommand, PaletteOption, PickCallback, Search, SubList,
429};
430
431pub use subspace_search as full_text;
432pub mod log_view;
433pub mod segmented;
434
435/// The shared persistent search service, without owning a board's data model.
436pub fn full_text_service(cx: &App) -> Option<full_text::Service> {
437 services(cx).and_then(|services| services.search.clone())
438}
439
440/// Internal search citations are routed in-app and never sent to the OS URL opener.
441pub struct SearchNavigation(pub std::rc::Rc<dyn Fn(full_text::Target, &mut Window, &mut App)>);
442impl Global for SearchNavigation {}
443
444// ---- Globals the shell sets -------------------------------------------------------
445
446/// The app's wrap toggle (REQ-09): wrapped titles when true, else one line.
447#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
448pub struct Wrap(pub bool);
449
450impl Global for Wrap {}
451
452pub fn wrap(cx: &App) -> bool {
453 cx.try_global::<Wrap>().is_some_and(|wrap| wrap.0)
454}
455
456/// Text selected in a detail pane, held between the pane's context menu and
457/// the shell's [`AddSelectionToChat`] handler, which takes it.
458#[derive(Debug, Clone, Default)]
459pub struct Selection(pub String);
460
461impl Global for Selection {}
462
463pub fn set_selection(cx: &mut App, text: String) {
464 cx.set_global(Selection(text));
465}
466
467/// The held selection, leaving none behind.
468pub fn take_selection(cx: &mut App) -> String {
469 let text = cx.try_global::<Selection>().map(|held| held.0.clone());
470 cx.set_global(Selection::default());
471 text.unwrap_or_default()
472}
473
474/// The config file and the credential sources, loaded once at startup.
475/// Clients take `Arc` clones into background tasks. `tools` is the catalog
476/// of the selected dashboards, which Copilot chat registers.
477pub struct Services {
478 pub config: Arc<Config>,
479 pub credentials: Arc<Credentials>,
480 pub tools: Catalog,
481 pub search: Option<full_text::Service>,
482 /// The config file the settings were read from.
483 pub config_file: std::path::PathBuf,
484}
485
486impl Global for Services {}
487
488impl Services {
489 /// Native board `id`'s own settings file, beside the config file.
490 // qual:api
491 pub fn board_config_file(&self, id: &str) -> std::path::PathBuf {
492 subspace_core::config::board_file(&self.config_file, id)
493 }
494}
495
496pub fn services(cx: &App) -> Option<&Services> {
497 cx.try_global::<Services>()
498}
499
500// ---- The dashboard trait ----------------------------------------------------------
501
502/// A dashboard: one view in the app's switcher.
503///
504/// The app creates each enabled dashboard at startup, or when Settings
505/// enables it, and keeps it while it stays enabled and the window is open,
506/// so a dashboard keeps its state across switches. View work
507/// starts in [`Dashboard::activate`]; process-owned monitoring starts in
508/// [`Dashboard::start_background`]. Run blocking calls with `cx.background_spawn`.
509pub trait Dashboard: Render + Focusable + EventEmitter<DashboardEvent> {
510 /// Stable identifier, such as `board`. Lower case, no spaces. Also the
511 /// view's key context and the prefix of its stored choices.
512 const ID: &'static str;
513 /// The name in the dashboard switcher and the window title.
514 const TITLE: &'static str;
515 /// A concise capability description used by navigation tooltips.
516 const DESCRIPTION: &'static str = Self::TITLE;
517 /// Optional monochrome SVG asset shown before the switcher label.
518 const ICON: Option<&'static str> = None;
519 /// Embedded artwork owned by this board, captured without creating a view.
520 const ARTWORK: BoardArtwork = BoardArtwork::new(&[]);
521 /// The board's own help, compiled in with `include_str!` from a Markdown
522 /// file in the board crate. The shell renders it and the `board_help`
523 /// agent tool returns the same text. Empty means the board has no help
524 /// yet, and then neither the shell nor the tool offers one.
525 const HELP_MARKDOWN: &'static str = "";
526 /// At most three bundled PNG/WebP illustrations, each at most 512 KiB.
527 /// Reference an id in help with ``.
528 const HELP_IMAGES: &'static [HelpImage] = &[];
529 /// Explicit adoption of the Framework's persistent full-text index.
530 const SEARCHABLE: bool = false;
531 /// Keep the view alive, without a tab or background refresh, when
532 /// Settings disables the board while the app runs. Set it for a board
533 /// that owns processes, such as shells or tunnels, that must not end
534 /// silently; enabling the board again shows the same view.
535 const RETAIN_WHEN_DISABLED: bool = false;
536
537 const FIND_VIRTUAL_CONTENT: bool = false;
538
539 /// Optional cheap revision for provider refresh; None follows every owner notification.
540 fn find_revision(&self, _cx: &App) -> Option<u64> {
541 None
542 }
543
544 /// Whether the current view uses loaded virtual documents rather than rendered text.
545 fn find_virtual_content(&self, _cx: &App) -> bool {
546 Self::FIND_VIRTUAL_CONTENT
547 }
548
549 /// Loaded virtual text for local find; ordinary shared text registers itself.
550 fn find_documents(&self, _cx: &App) -> (SharedString, Vec<find_in_page::Document>) {
551 (SharedString::default(), Vec::new())
552 }
553 fn reveal_find_document(&mut self, _id: &str, _window: &mut Window, _cx: &mut Context<Self>) {}
554
555 /// Safe data-only refresh. Implementations must not activate views, start
556 /// runtimes or request interactive credentials.
557 fn background_refresh(&mut self, _cx: &mut Context<Self>) {}
558
559 /// Static settings pages and feature declarations owned by this board.
560 /// Registration calls this without constructing the dashboard.
561 fn settings() -> settings::BoardSettings
562 where
563 Self: Sized,
564 {
565 settings::BoardSettings::default()
566 }
567
568 /// Board-owned settings controls, retained within the outer Save/Cancel draft.
569 fn settings_editor() -> Option<settings::SettingsEditorFactory>
570 where
571 Self: Sized,
572 {
573 None
574 }
575
576 /// Requirements for the shell-owned shared service editor. Registration
577 /// captures these without constructing a board or loading credentials.
578 fn connection_settings() -> settings::ConnectionSettings
579 where
580 Self: Sized,
581 {
582 settings::ConnectionSettings::default()
583 }
584
585 /// The contract messages this board publishes, subscribes to, requests
586 /// and answers. Registration captures them without constructing the
587 /// board; the broker routes nothing else (see [`contracts`]).
588 fn contracts() -> contracts::BoardContracts
589 where
590 Self: Sized,
591 {
592 contracts::BoardContracts::default()
593 }
594
595 fn new(window: &mut Window, cx: &mut Context<Self>) -> Self
596 where
597 Self: Sized;
598
599 /// Starts process-owned GUI work after services and notification delivery exist,
600 /// at startup and again when Settings enables the board after a stop.
601 /// Headless tool registration never calls this hook.
602 fn start_background(_cx: &mut App)
603 where
604 Self: Sized,
605 {
606 }
607
608 /// Stops the work [`Dashboard::start_background`] started, when Settings
609 /// disables the board while the app runs. A later start must work again.
610 fn stop_background(_cx: &mut App)
611 where
612 Self: Sized,
613 {
614 }
615
616 /// Resolve a process-local notification target against current account/access state.
617 /// Called before activation on notification-driven window creation.
618 fn open_notification(&mut self, _target: u64, _window: &mut Window, _cx: &mut Context<Self>) {}
619
620 /// The agent tools this dashboard advertises. Copilot chat and the MCP
621 /// server register them when the product selects the dashboard. Called
622 /// without a window, so it must not touch GPUI.
623 fn agent_tools(_environment: &ToolEnvironment) -> Vec<Arc<dyn AgentTool>>
624 where
625 Self: Sized,
626 {
627 Vec::new()
628 }
629
630 /// Bind this dashboard's own keys, in the context `view_keys(Self::ID)`.
631 /// Runs once per process, when the app first creates the dashboard.
632 fn bind_keys(_cx: &mut App)
633 where
634 Self: Sized,
635 {
636 }
637
638 /// Called each time the dashboard becomes the visible one.
639 fn activate(&mut self, _window: &mut Window, _cx: &mut Context<Self>) {}
640
641 /// Called when another dashboard becomes the visible one, such as to
642 /// stop a timer or close a menu.
643 fn deactivate(&mut self, _window: &mut Window, _cx: &mut Context<Self>) {}
644
645 /// Called when a shell overlay, such as the palette, help or a dialog,
646 /// starts or stops covering the board area. GPUI draws overlays above
647 /// the board, but a native child view, such as a web view, draws above
648 /// GPUI, so a board that owns one hides it while `covered` is true.
649 fn covered(&mut self, _covered: bool, _window: &mut Window, _cx: &mut Context<Self>) {}
650
651 /// Optional context appended after the registered board title by the shell.
652 /// `None` gives the board name without context.
653 fn window_title(&self, _cx: &App) -> Option<SharedString> {
654 None
655 }
656
657 /// Active configuration source offered only for explicit per-report path
658 /// consent. Return a path, never file contents, URLs or credential values.
659 /// The shell redacts it before the form can display or include it.
660 fn diagnostic_config_path(&self, _cx: &App) -> Option<std::path::PathBuf> {
661 None
662 }
663
664 /// Controls in the toolbar after the dashboard switcher, such as the
665 /// sprint picker.
666 fn render_toolbar(
667 &mut self,
668 _window: &mut Window,
669 _cx: &mut Context<Self>,
670 ) -> Option<AnyElement> {
671 None
672 }
673
674 /// Short status for the toolbar, such as item counts.
675 fn status(&self, _cx: &App) -> Option<SharedString> {
676 None
677 }
678
679 /// The docks this Space has on the workspace shell, and whether each
680 /// shows now. The shell's status bar draws a switch for each dock
681 /// reported: the navigator's at its leading end, the inspector's at its
682 /// trailing end. The default, [`workspace::SpaceDocks::NONE`], draws none.
683 fn docks(&self, _cx: &App) -> workspace::SpaceDocks {
684 workspace::SpaceDocks::NONE
685 }
686
687 /// Show or hide `dock`: its status bar switch was used. Keep the choice
688 /// with the Space's other stored choices and notify. The default does
689 /// nothing.
690 fn toggle_dock(
691 &mut self,
692 _dock: workspace::SpaceDock,
693 _window: &mut Window,
694 _cx: &mut Context<Self>,
695 ) {
696 }
697
698 /// A short mark on this dashboard's switcher tab, such as a count of
699 /// running work or `!` for something that waits. `None`, the default,
700 /// leaves the tab plain.
701 fn badge(&self, _cx: &App) -> Option<SharedString> {
702 None
703 }
704
705 /// True while the dashboard loads: the reload button shows it.
706 fn busy(&self, _cx: &App) -> bool {
707 false
708 }
709
710 /// The selected row, which item commands act on: the palette's header.
711 fn subject(&self, _cx: &App) -> Option<Row> {
712 None
713 }
714
715 /// Selection identity for agent queries. Do not export credentials or secret
716 /// finding previews. Specific dashboards add service identifiers as needed.
717 fn agent_context(&self, cx: &App) -> Option<AgentContext> {
718 let row = self.subject(cx)?;
719 Some(AgentContext {
720 key: format!("{}:{}", Self::ID, row.key),
721 label: format!("{}: {}", Self::TITLE, row.title),
722 content: format!(
723 "Dashboard: {}\nItem key: {}\nTitle: {}",
724 Self::ID,
725 row.key,
726 row.title
727 ),
728 })
729 }
730
731 /// Commands for the palette, in order. The app adds its own after them.
732 fn commands(&self, _cx: &Context<Self>) -> Vec<PaletteCommand> {
733 Vec::new()
734 }
735
736 /// The item search for `/` and the palette; `None` when there is
737 /// nothing to search.
738 fn search(&self, _cx: &App) -> Option<Search> {
739 None
740 }
741
742 /// Reveal the item with document id `id`, select it and open its details.
743 fn open_search_result(&mut self, _id: &str, _window: &mut Window, _cx: &mut Context<Self>) {}
744
745 /// Open a link owned by this board, if it can be read in its current scope.
746 fn open_link(&mut self, _url: &str, _cx: &mut Context<Self>) -> bool {
747 false
748 }
749
750 /// The place the person is looking at, such as the channel they read,
751 /// for a Back on another board that returns here. `None`, the default,
752 /// returns to the board as it is.
753 fn return_location(&self, _cx: &App) -> Option<ReturnLocation> {
754 None
755 }
756
757 /// The shell is about to make this board current, coming from `from`:
758 /// the board view shown before, or `None` when no board was showing. A
759 /// link the shell opens next ([`Dashboard::open_link`]) came from there.
760 fn arrived_from(&mut self, _from: Option<ReturnPoint>, _cx: &mut Context<Self>) {}
761
762 /// Show a place this board gave as [`Dashboard::return_location`].
763 /// False when it no longer exists, such as a channel left since.
764 fn return_to(&mut self, _key: &str, _window: &mut Window, _cx: &mut Context<Self>) -> bool {
765 false
766 }
767
768 /// Open a validated retained search hit through board-owned navigation.
769 fn open_indexed_result(
770 &mut self,
771 hit: &full_text::Hit,
772 window: &mut Window,
773 cx: &mut Context<Self>,
774 ) {
775 self.open_search_result(&hit.document.navigation, window, cx);
776 }
777
778 /// Retained views keep the permit and validate it at presentation boundaries.
779 fn open_indexed_result_fenced(
780 &mut self,
781 hit: &full_text::Hit,
782 permit: full_text::ReadPermit,
783 window: &mut Window,
784 cx: &mut Context<Self>,
785 ) {
786 if permit.valid() {
787 self.open_indexed_result(hit, window, cx);
788 }
789 }
790
791 /// Whether a menu or a dialog of the dashboard is open.
792 fn modal(&self, _cx: &App) -> Option<Modal> {
793 None
794 }
795
796 /// Close the dashboard's menu; the shell calls this before it opens the
797 /// palette.
798 fn dismiss(&mut self, _window: &mut Window, _cx: &mut Context<Self>) {}
799
800 /// Help rows for this dashboard's keys.
801 fn keys(&self) -> &'static [KeyHelp] {
802 LIST_KEYS
803 }
804
805 /// A note under the help's key list.
806 fn help_foot(&self) -> Option<SharedString> {
807 None
808 }
809
810 /// Programs currently running in this dashboard, shown before quitting.
811 fn quit_warnings(&self, _cx: &App) -> Vec<SharedString> {
812 Vec::new()
813 }
814
815 /// Load the dashboard's data again.
816 fn reload(&mut self, window: &mut Window, cx: &mut Context<Self>);
817}
818
819mod handle;
820
821pub use handle::{DashboardHandle, EventSink};