Now DAP logs show the label of each session which makes it much easier to pick out the right one. Also "initialization sequence" now shows up correctly when that view is selected. Release Notes: - N/A ---------
Unified · Split
| @@ -32,12 +32,19 @@ use workspace::{ · 31 unmodified lines | ||
| 32 | 32 | ui::{Button, Clickable, ContextMenu, Label, LabelCommon, PopoverMenu, h_flex}, |
| 33 | 33 | }; |
| 34 | 34 | |
| 35 | +#[derive(Debug, Copy, Clone, PartialEq, Eq)] | |
| 36 | +enum View { | |
| 37 | + AdapterLogs, | |
| 38 | + RpcMessages, | |
| 39 | + InitializationSequence, | |
| 40 | +} | |
| 41 | + | |
| 35 | 42 | struct DapLogView { |
| 36 | 43 | editor: Entity<Editor>, |
| 37 | 44 | focus_handle: FocusHandle, |
| 38 | 45 | log_store: Entity<LogStore>, |
| 39 | 46 | editor_subscriptions: Vec<Subscription>, |
| 40 | − current_view: Option<(SessionId, LogKind)>, | |
| 47 | + current_view: Option<(SessionId, View)>, | |
| 41 | 48 | project: Entity<Project>, |
| 42 | 49 | _subscriptions: Vec<Subscription>, |
| 43 | 50 | } |
| @@ -77,6 +84,7 @@ struct DebugAdapterState { · 33 unmodified lines | ||
| 77 | 84 | id: SessionId, |
| 78 | 85 | log_messages: VecDeque<SharedString>, |
| 79 | 86 | rpc_messages: RpcMessages, |
| 87 | + session_label: SharedString, | |
| 80 | 88 | adapter_name: DebugAdapterName, |
| 81 | 89 | has_adapter_logs: bool, |
| 82 | 90 | is_terminated: bool, |
| @@ -121,12 +129,18 @@ impl MessageKind { · 38 unmodified lines | ||
| 121 | 129 | } |
| 122 | 130 | |
| 123 | 131 | impl DebugAdapterState { |
| 124 | − fn new(id: SessionId, adapter_name: DebugAdapterName, has_adapter_logs: bool) -> Self { | |
| 132 | + fn new( | |
| 133 | + id: SessionId, | |
| 134 | + adapter_name: DebugAdapterName, | |
| 135 | + session_label: SharedString, | |
| 136 | + has_adapter_logs: bool, | |
| 137 | + ) -> Self { | |
| 125 | 138 | Self { |
| 126 | 139 | id, |
| 127 | 140 | log_messages: VecDeque::new(), |
| 128 | 141 | rpc_messages: RpcMessages::new(), |
| 129 | 142 | adapter_name, |
| 143 | + session_label, | |
| 130 | 144 | has_adapter_logs, |
| 131 | 145 | is_terminated: false, |
| 132 | 146 | } |
| @@ -371,18 +385,21 @@ impl LogStore { · 238 unmodified lines | ||
| 371 | 385 | return None; |
| 372 | 386 | }; |
| 373 | 387 | |
| 374 | − let (adapter_name, has_adapter_logs) = session.read_with(cx, |session, _| { | |
| 375 | − ( | |
| 376 | − session.adapter(), | |
| 377 | − session | |
| 378 | − .adapter_client() | |
| 379 | − .map_or(false, |client| client.has_adapter_logs()), | |
| 380 | − ) | |
| 381 | − }); | |
| 388 | + let (adapter_name, session_label, has_adapter_logs) = | |
| 389 | + session.read_with(cx, |session, _| { | |
| 390 | + ( | |
| 391 | + session.adapter(), | |
| 392 | + session.label(), | |
| 393 | + session | |
| 394 | + .adapter_client() | |
| 395 | + .map_or(false, |client| client.has_adapter_logs()), | |
| 396 | + ) | |
| 397 | + }); | |
| 382 | 398 | |
| 383 | 399 | state.insert(DebugAdapterState::new( |
| 384 | 400 | id.session_id, |
| 385 | 401 | adapter_name, |
| 402 | + session_label, | |
| 386 | 403 | has_adapter_logs, |
| 387 | 404 | )); |
| 388 | 405 | |
| @@ -506,12 +523,13 @@ impl Render for DapLogToolbarItemView { · 117 unmodified lines | ||
| 506 | 523 | current_client |
| 507 | 524 | .map(|sub_item| { |
| 508 | 525 | Cow::Owned(format!( |
| 509 | − "{} ({}) - {}", | |
| 526 | + "{} - {} - {}", | |
| 510 | 527 | sub_item.adapter_name, |
| 511 | − sub_item.session_id.0, | |
| 528 | + sub_item.session_label, | |
| 512 | 529 | match sub_item.selected_entry { |
| 513 | − LogKind::Adapter => ADAPTER_LOGS, | |
| 514 | − LogKind::Rpc => RPC_MESSAGES, | |
| 530 | + View::AdapterLogs => ADAPTER_LOGS, | |
| 531 | + View::RpcMessages => RPC_MESSAGES, | |
| 532 | + View::InitializationSequence => INITIALIZATION_SEQUENCE, | |
| 515 | 533 | } |
| 516 | 534 | )) |
| 517 | 535 | }) |
| @@ -529,8 +547,8 @@ impl Render for DapLogToolbarItemView { · 11 unmodified lines | ||
| 529 | 547 | .pl_2() |
| 530 | 548 | .child( |
| 531 | 549 | Label::new(format!( |
| 532 | − "{}. {}", | |
| 533 | − row.session_id.0, row.adapter_name, | |
| 550 | + "{} - {}", | |
| 551 | + row.adapter_name, row.session_label | |
| 534 | 552 | )) |
| 535 | 553 | .color(workspace::ui::Color::Muted), |
| 536 | 554 | ) |
| @@ -669,9 +687,16 @@ impl DapLogView { · 132 unmodified lines | ||
| 669 | 687 | |
| 670 | 688 | let events_subscriptions = cx.subscribe(&log_store, |log_view, _, event, cx| match event { |
| 671 | 689 | Event::NewLogEntry { id, entry, kind } => { |
| 672 | − if log_view.current_view == Some((id.session_id, *kind)) | |
| 673 | − && log_view.project == *id.project | |
| 674 | − { | |
| 690 | + let is_current_view = match (log_view.current_view, *kind) { | |
| 691 | + (Some((i, View::AdapterLogs)), LogKind::Adapter) | |
| 692 | + | (Some((i, View::RpcMessages)), LogKind::Rpc) | |
| 693 | + if i == id.session_id => | |
| 694 | + { | |
| 695 | + log_view.project == *id.project | |
| 696 | + } | |
| 697 | + _ => false, | |
| 698 | + }; | |
| 699 | + if is_current_view { | |
| 675 | 700 | log_view.editor.update(cx, |editor, cx| { |
| 676 | 701 | editor.set_read_only(false); |
| 677 | 702 | let last_point = editor.buffer().read(cx).len(cx); |
| @@ -768,10 +793,11 @@ impl DapLogView { · 90 unmodified lines | ||
| 768 | 793 | .map(|state| DapMenuItem { |
| 769 | 794 | session_id: state.id, |
| 770 | 795 | adapter_name: state.adapter_name.clone(), |
| 796 | + session_label: state.session_label.clone(), | |
| 771 | 797 | has_adapter_logs: state.has_adapter_logs, |
| 772 | 798 | selected_entry: self |
| 773 | 799 | .current_view |
| 774 | − .map_or(LogKind::Adapter, |(_, kind)| kind), | |
| 800 | + .map_or(View::AdapterLogs, |(_, kind)| kind), | |
| 775 | 801 | }) |
| 776 | 802 | .collect::<Vec<_>>() |
| 777 | 803 | }) |
| @@ -789,7 +815,7 @@ impl DapLogView { · 11 unmodified lines | ||
| 789 | 815 | .map(|state| log_contents(state.iter().cloned())) |
| 790 | 816 | }); |
| 791 | 817 | if let Some(rpc_log) = rpc_log { |
| 792 | − self.current_view = Some((id.session_id, LogKind::Rpc)); | |
| 818 | + self.current_view = Some((id.session_id, View::RpcMessages)); | |
| 793 | 819 | let (editor, editor_subscriptions) = Self::editor_for_logs(rpc_log, window, cx); |
| 794 | 820 | let language = self.project.read(cx).languages().language_for_name("JSON"); |
| 795 | 821 | editor |
| @@ -830,7 +856,7 @@ impl DapLogView { · 34 unmodified lines | ||
| 830 | 856 | .map(|state| log_contents(state.iter().cloned())) |
| 831 | 857 | }); |
| 832 | 858 | if let Some(message_log) = message_log { |
| 833 | − self.current_view = Some((id.session_id, LogKind::Adapter)); | |
| 859 | + self.current_view = Some((id.session_id, View::AdapterLogs)); | |
| 834 | 860 | let (editor, editor_subscriptions) = Self::editor_for_logs(message_log, window, cx); |
| 835 | 861 | editor |
| 836 | 862 | .read(cx) |
| @@ -859,7 +885,7 @@ impl DapLogView { · 22 unmodified lines | ||
| 859 | 885 | .map(|state| log_contents(state.iter().cloned())) |
| 860 | 886 | }); |
| 861 | 887 | if let Some(rpc_log) = rpc_log { |
| 862 | − self.current_view = Some((id.session_id, LogKind::Rpc)); | |
| 888 | + self.current_view = Some((id.session_id, View::InitializationSequence)); | |
| 863 | 889 | let (editor, editor_subscriptions) = Self::editor_for_logs(rpc_log, window, cx); |
| 864 | 890 | let language = self.project.read(cx).languages().language_for_name("JSON"); |
| 865 | 891 | editor |
| @@ -899,11 +925,12 @@ fn log_contents(lines: impl Iterator<Item = SharedString>) -> String { · 33 unmodified lines | ||
| 899 | 925 | } |
| 900 | 926 | |
| 901 | 927 | #[derive(Clone, PartialEq)] |
| 902 | −pub(crate) struct DapMenuItem { | |
| 903 | − pub session_id: SessionId, | |
| 904 | − pub adapter_name: DebugAdapterName, | |
| 905 | − pub has_adapter_logs: bool, | |
| 906 | − pub selected_entry: LogKind, | |
| 928 | +struct DapMenuItem { | |
| 929 | + session_id: SessionId, | |
| 930 | + session_label: SharedString, | |
| 931 | + adapter_name: DebugAdapterName, | |
| 932 | + has_adapter_logs: bool, | |
| 933 | + selected_entry: View, | |
| 907 | 934 | } |
| 908 | 935 | |
| 909 | 936 | const ADAPTER_LOGS: &str = "Adapter Logs"; |
| @@ -11,7 +11,7 @@ use project::worktree_store::WorktreeStore; · 10 unmodified lines | ||
| 11 | 11 | use rpc::proto; |
| 12 | 12 | use running::RunningState; |
| 13 | 13 | use std::{cell::OnceCell, sync::OnceLock}; |
| 14 | −use ui::{Indicator, Tooltip, prelude::*}; | |
| 14 | +use ui::{Indicator, prelude::*}; | |
| 15 | 15 | use util::truncate_and_trailoff; |
| 16 | 16 | use workspace::{ |
| 17 | 17 | CollaboratorId, FollowableItem, ViewId, Workspace, |
| @@ -158,7 +158,6 @@ impl DebugSession { · 140 unmodified lines | ||
| 158 | 158 | |
| 159 | 159 | h_flex() |
| 160 | 160 | .id("session-label") |
| 161 | − .tooltip(Tooltip::text(format!("Session {}", self.session_id(cx).0,))) | |
| 162 | 161 | .ml(depth * px(16.0)) |
| 163 | 162 | .gap_2() |
| 164 | 163 | .when_some(icon, |this, indicator| this.child(indicator)) |