Merge pull request #34: feat(help): local support packages with opt-in debug logging
# Conflicts: # docs/decisions/README.md
@@ -0,0 +1,39 @@
1
name: Bug report
2
description: Report a bug with client data and a local support package
3
title: "Bug: "
4
labels: ["bug"]
5
body:
6
- type: markdown
7
attributes:
8
value: |
9
File bugs on [danieldaeschle/rusty-teams](https://github.com/danieldaeschle/rusty-teams/issues). Prefer **Settings → Help → Create support package**, then attach those files. Do not paste tokens, cookies, or passwords.
10
- type: textarea
11
id: what-happened
12
attributes:
13
label: What happened
14
description: Steps to reproduce and what you saw.
15
placeholder: 1. Open … 2. Click … 3. …
16
validations:
17
required: true
18
- type: textarea
19
id: expected
20
attributes:
21
label: Expected
22
description: What should have happened instead.
23
validations:
24
required: true
25
- type: textarea
26
id: client
27
attributes:
28
label: Client data
29
description: Paste the Client block from Help (or leave blank if you attach client.md).
30
render: markdown
31
validations:
32
required: false
33
- type: checkboxes
34
id: attachments
35
attributes:
36
label: Support package
37
options:
38
- label: I attached the support package files (client.md, scrubbed diagnostics.log, call reports) or explained why not
39
required: false
@@ -0,0 +1,39 @@1
name: Bug report2
description: Report a bug with client data and a local support package3
title: "Bug: "4
labels: ["bug"]5
body:6
- type: markdown7
attributes:8
value: |9
File bugs on [danieldaeschle/rusty-teams](https://github.com/danieldaeschle/rusty-teams/issues). Prefer **Settings → Help → Create support package**, then attach those files. Do not paste tokens, cookies, or passwords.10
- type: textarea11
id: what-happened12
attributes:13
label: What happened14
description: Steps to reproduce and what you saw.15
placeholder: 1. Open … 2. Click … 3. …16
validations:17
required: true18
- type: textarea19
id: expected20
attributes:21
label: Expected22
description: What should have happened instead.23
validations:24
required: true25
- type: textarea26
id: client27
attributes:28
label: Client data29
description: Paste the Client block from Help (or leave blank if you attach client.md).30
render: markdown31
validations:32
required: false33
- type: checkboxes34
id: attachments35
attributes:36
label: Support package37
options:38
- label: I attached the support package files (client.md, scrubbed diagnostics.log, call reports) or explained why not39
required: false@@ -115,9 +115,118 @@ settings:
115
115
mcp:
116
116
en: MCP
117
117
de: MCP
118
help:
119
en: Help
120
de: Hilfe
118
121
about:
119
122
en: About
120
123
de: Info
124
help:
125
caption_client:
126
en: CLIENT
127
de: CLIENT
128
caption_paths:
129
en: PATHS
130
de: PFADE
131
caption_packages:
132
en: SUPPORT PACKAGES
133
de: SUPPORT-PAKETE
134
caption_actions:
135
en: SUPPORT
136
de: SUPPORT
137
packages_empty:
138
en: No support packages yet
139
de: Noch keine Support-Pakete
140
copy_path_tooltip:
141
en: Copy path
142
de: Pfad kopieren
143
preview_truncated:
144
en: Showing the first 256 KB
145
de: Es werden die ersten 256 KB angezeigt
146
preview_binary:
147
en: This file is not plain text and cannot be previewed here.
148
de: Diese Datei ist kein Klartext und kann hier nicht angezeigt werden.
149
preview_error:
150
en: Could not read this file.
151
de: Diese Datei konnte nicht gelesen werden.
152
version:
153
en: Version
154
de: Version
155
platform:
156
en: Platform
157
de: Plattform
158
locale:
159
en: Language and timezone
160
de: Sprache und Zeitzone
161
signed_in:
162
en: Signed in
163
de: Angemeldet
164
yes:
165
en: Yes
166
de: Ja
167
no:
168
en: No
169
de: Nein
170
debug_logging:
171
en: Debug logging
172
de: Debug-Protokollierung
173
debug_logging_on_detail:
174
en: Writing diagnostics.log — turn off when you are done
175
de: Schreibt diagnostics.log — danach wieder ausschalten
176
debug_logging_off_detail:
177
en: Off by default — enable before reproducing a bug
178
de: Standardmässig aus — vor der Fehlerreproduktion einschalten
179
clear_logs:
180
en: Clear logs
181
de: Logs leeren
182
clear_logs_detail:
183
en: Removes diagnostics, crash logs, and call dumps on this computer
184
de: Entfernt Diagnosen, Absturzprotokolle und Anruf-Dumps auf diesem Computer
185
clear_logs_button:
186
en: Clear
187
de: Leeren
188
logs_path:
189
en: Logs root
190
de: Log-Root
191
bundles_path:
192
en: Support packages
193
de: Support-Pakete
194
detail:
195
en: Create a local support package, then open an upstream GitHub issue and attach the files. Nothing is uploaded automatically.
196
de: Erstellen Sie ein lokales Support-Paket, öffnen Sie danach ein Upstream-GitHub-Issue und hängen Sie die Dateien an. Es wird nichts automatisch hochgeladen.
197
create_bundle:
198
en: Support package
199
de: Support-Paket
200
create_bundle_detail:
201
en: Scrubbed diagnostics and recent call reports on this computer
202
de: Bereinigte Diagnosen und aktuelle Anrufberichte auf diesem Computer
203
create_bundle_button:
204
en: Create
205
de: Erstellen
206
open_issue:
207
en: GitHub issue
208
de: GitHub-Issue
209
open_issue_detail:
210
en: Opens danieldaeschle/rusty-teams with a pre-filled draft
211
de: Öffnet danieldaeschle/rusty-teams mit vorausgefülltem Entwurf
212
open_issue_button:
213
en: Open
214
de: Öffnen
215
copy_summary:
216
en: Client summary
217
de: Client-Zusammenfassung
218
copy_summary_detail:
219
en: Copy the same English block used in the issue
220
de: Denselben englischen Block wie im Issue kopieren
221
copy_button:
222
en: Copy
223
de: Kopieren
224
open_logs:
225
en: Logs folder
226
de: Log-Ordner
227
open_logs_detail:
228
en: diagnostics.log and call dumps
229
de: diagnostics.log und Anruf-Dumps
121
230
caption:
122
231
system:
123
232
en: SYSTEM
@@ -115,9 +115,118 @@ settings:115
mcp:115
mcp:116
en: MCP116
en: MCP117
de: MCP117
de: MCP118
help:119
en: Help120
de: Hilfe118
about:121
about:119
en: About122
en: About120
de: Info123
de: Info124
help:125
caption_client:126
en: CLIENT127
de: CLIENT128
caption_paths:129
en: PATHS130
de: PFADE131
caption_packages:132
en: SUPPORT PACKAGES133
de: SUPPORT-PAKETE134
caption_actions:135
en: SUPPORT136
de: SUPPORT137
packages_empty:138
en: No support packages yet139
de: Noch keine Support-Pakete140
copy_path_tooltip:141
en: Copy path142
de: Pfad kopieren143
preview_truncated:144
en: Showing the first 256 KB145
de: Es werden die ersten 256 KB angezeigt146
preview_binary:147
en: This file is not plain text and cannot be previewed here.148
de: Diese Datei ist kein Klartext und kann hier nicht angezeigt werden.149
preview_error:150
en: Could not read this file.151
de: Diese Datei konnte nicht gelesen werden.152
version:153
en: Version154
de: Version155
platform:156
en: Platform157
de: Plattform158
locale:159
en: Language and timezone160
de: Sprache und Zeitzone161
signed_in:162
en: Signed in163
de: Angemeldet164
yes:165
en: Yes166
de: Ja167
no:168
en: No169
de: Nein170
debug_logging:171
en: Debug logging172
de: Debug-Protokollierung173
debug_logging_on_detail:174
en: Writing diagnostics.log — turn off when you are done175
de: Schreibt diagnostics.log — danach wieder ausschalten176
debug_logging_off_detail:177
en: Off by default — enable before reproducing a bug178
de: Standardmässig aus — vor der Fehlerreproduktion einschalten179
clear_logs:180
en: Clear logs181
de: Logs leeren182
clear_logs_detail:183
en: Removes diagnostics, crash logs, and call dumps on this computer184
de: Entfernt Diagnosen, Absturzprotokolle und Anruf-Dumps auf diesem Computer185
clear_logs_button:186
en: Clear187
de: Leeren188
logs_path:189
en: Logs root190
de: Log-Root191
bundles_path:192
en: Support packages193
de: Support-Pakete194
detail:195
en: Create a local support package, then open an upstream GitHub issue and attach the files. Nothing is uploaded automatically.196
de: Erstellen Sie ein lokales Support-Paket, öffnen Sie danach ein Upstream-GitHub-Issue und hängen Sie die Dateien an. Es wird nichts automatisch hochgeladen.197
create_bundle:198
en: Support package199
de: Support-Paket200
create_bundle_detail:201
en: Scrubbed diagnostics and recent call reports on this computer202
de: Bereinigte Diagnosen und aktuelle Anrufberichte auf diesem Computer203
create_bundle_button:204
en: Create205
de: Erstellen206
open_issue:207
en: GitHub issue208
de: GitHub-Issue209
open_issue_detail:210
en: Opens danieldaeschle/rusty-teams with a pre-filled draft211
de: Öffnet danieldaeschle/rusty-teams mit vorausgefülltem Entwurf212
open_issue_button:213
en: Open214
de: Öffnen215
copy_summary:216
en: Client summary217
de: Client-Zusammenfassung218
copy_summary_detail:219
en: Copy the same English block used in the issue220
de: Denselben englischen Block wie im Issue kopieren221
copy_button:222
en: Copy223
de: Kopieren224
open_logs:225
en: Logs folder226
de: Log-Ordner227
open_logs_detail:228
en: diagnostics.log and call dumps229
de: diagnostics.log und Anruf-Dumps121
caption:230
caption:122
system:231
system:123
en: SYSTEM232
en: SYSTEM@@ -1,21 +1,46 @@
1
1
use std::backtrace::Backtrace;
2
use std::fs::OpenOptions;
3
use std::io::Write;
2
use std::fs;
4
3
use std::panic::PanicHookInfo;
5
use std::path::PathBuf;
4
use std::path::{Path, PathBuf};
5
use std::sync::OnceLock;
6
6
7
7
pub const CRASH_LOG_FILE: &str = "crash.log";
8
const MAX_BYTES: u64 = 256 * 1024;
9
const RING_SLOTS: u32 = 1;
10
const MERGE_CAP_BYTES: u64 = 128 * 1024;
11
12
static PATH: OnceLock<PathBuf> = OnceLock::new();
8
13
9
14
pub fn install(path: PathBuf) {
15
let _ = PATH.set(path.clone());
10
16
let previous = std::panic::take_hook();
11
17
std::panic::set_hook(Box::new(move |info| {
12
if let Ok(mut file) = OpenOptions::new().create(true).append(true).open(&path) {
13
let _ = file.write_all(entry(info, &Backtrace::force_capture().to_string()).as_bytes());
14
}
18
let body = entry(info, &Backtrace::force_capture().to_string());
19
let _ = crate::diagnostics::append_rotated(&path, MAX_BYTES, RING_SLOTS, &body);
15
20
previous(info);
16
21
}));
17
22
}
18
23
24
pub fn path() -> Option<PathBuf> {
25
PATH.get().cloned()
26
}
27
28
pub fn read_merged(max_bytes: u64) -> String {
29
let Some(path) = PATH.get() else {
30
return String::new();
31
};
32
crate::diagnostics::read_ring_merged(path, RING_SLOTS, max_bytes.min(MERGE_CAP_BYTES).max(1))
33
}
34
35
pub fn clear_files(root: &Path) {
36
for name in [CRASH_LOG_FILE, &format!("{CRASH_LOG_FILE}.1")] {
37
let path = root.join(name);
38
if path.exists() {
39
let _ = fs::remove_file(path);
40
}
41
}
42
}
43
19
44
fn entry(info: &PanicHookInfo<'_>, backtrace: &str) -> String {
20
45
let location = info
21
46
.location()
@@ -1,21 +1,46 @@1
use std::backtrace::Backtrace;1
use std::backtrace::Backtrace;2
use std::fs::OpenOptions;2
use std::fs;3
use std::io::Write;4
use std::panic::PanicHookInfo;3
use std::panic::PanicHookInfo;5
use std::path::PathBuf;4
use std::path::{Path, PathBuf};5
use std::sync::OnceLock;6
6
7
pub const CRASH_LOG_FILE: &str = "crash.log";7
pub const CRASH_LOG_FILE: &str = "crash.log";8
const MAX_BYTES: u64 = 256 * 1024;9
const RING_SLOTS: u32 = 1;10
const MERGE_CAP_BYTES: u64 = 128 * 1024;11
12
static PATH: OnceLock<PathBuf> = OnceLock::new();8
13
9
pub fn install(path: PathBuf) {14
pub fn install(path: PathBuf) {15
let _ = PATH.set(path.clone());10
let previous = std::panic::take_hook();16
let previous = std::panic::take_hook();11
std::panic::set_hook(Box::new(move |info| {17
std::panic::set_hook(Box::new(move |info| {12
if let Ok(mut file) = OpenOptions::new().create(true).append(true).open(&path) {18
let body = entry(info, &Backtrace::force_capture().to_string());13
let _ = file.write_all(entry(info, &Backtrace::force_capture().to_string()).as_bytes());19
let _ = crate::diagnostics::append_rotated(&path, MAX_BYTES, RING_SLOTS, &body);14
}15
previous(info);20
previous(info);16
}));21
}));17
}22
}18
23
24
pub fn path() -> Option<PathBuf> {25
PATH.get().cloned()26
}27
28
pub fn read_merged(max_bytes: u64) -> String {29
let Some(path) = PATH.get() else {30
return String::new();31
};32
crate::diagnostics::read_ring_merged(path, RING_SLOTS, max_bytes.min(MERGE_CAP_BYTES).max(1))33
}34
35
pub fn clear_files(root: &Path) {36
for name in [CRASH_LOG_FILE, &format!("{CRASH_LOG_FILE}.1")] {37
let path = root.join(name);38
if path.exists() {39
let _ = fs::remove_file(path);40
}41
}42
}43
19
fn entry(info: &PanicHookInfo<'_>, backtrace: &str) -> String {44
fn entry(info: &PanicHookInfo<'_>, backtrace: &str) -> String {20
let location = info45
let location = info21
.location()46
.location()@@ -1,13 +1,33 @@
1
use std::fs::OpenOptions;
1
use std::fs::{self, OpenOptions};
2
2
use std::io::Write;
3
use std::path::PathBuf;
3
use std::path::{Path, PathBuf};
4
use std::sync::atomic::{AtomicBool, Ordering};
4
5
use std::sync::OnceLock;
5
6
6
7
pub const DIAGNOSTICS_FILE: &str = "diagnostics.log";
8
pub const DIAGNOSTICS_SETTING_KEY: &str = "diagnostics_enabled";
9
pub const ENV_DEBUG_LOG: &str = "RUSTY_TEAMS_DEBUG_LOG";
10
7
11
const MAX_BYTES: u64 = 1024 * 1024;
12
const RING_SLOTS: u32 = 2;
13
const MERGE_CAP_BYTES: u64 = 1024 * 1024;
8
14
const SLOW_UI_HANDLER: std::time::Duration = std::time::Duration::from_millis(30);
9
15
10
16
static PATH: OnceLock<PathBuf> = OnceLock::new();
17
static ENABLED: AtomicBool = AtomicBool::new(false);
18
19
const OWN_CRATE_PREFIXES: [&str; 10] = [
20
"app",
21
"app_base",
22
"state",
23
"calling",
24
"chatsvc",
25
"session",
26
"webview",
27
"mcp",
28
"agents",
29
"teams",
30
];
11
31
12
32
const WEBRTC_AUDIO_MARKERS: [&str; 5] = [
13
33
"AdmProxy",
@@ -21,50 +41,45 @@ const ENDPOINT_DUMP_LINES: std::ops::Range<u32> = 4040..4170;
21
41
22
42
pub fn install(path: PathBuf) {
23
43
let _ = PATH.set(path);
24
if log::set_logger(&WebrtcAudioLog).is_ok() {
44
if log::set_logger(&DiagnosticsLog).is_ok() {
25
45
log::set_max_level(log::LevelFilter::Debug);
26
46
}
47
crate::support::install_panic_diagnostics_hook();
27
48
}
28
49
29
struct WebrtcAudioLog;
30
31
impl log::Log for WebrtcAudioLog {
32
fn enabled(&self, metadata: &log::Metadata<'_>) -> bool {
33
metadata.target() == "libwebrtc"
34
}
35
36
fn log(&self, entry: &log::Record<'_>) {
37
if !self.enabled(entry.metadata()) {
38
return;
39
}
40
let text = entry.args().to_string();
41
if keeps_webrtc_line(&text) {
42
record(format!("webrtc: {text}"));
43
}
44
}
50
pub fn is_enabled() -> bool {
51
ENABLED.load(Ordering::Relaxed)
52
}
45
53
46
fn flush(&self) {}
54
pub fn set_enabled(on: bool) {
55
ENABLED.store(on, Ordering::Relaxed);
47
56
}
48
57
49
fn keeps_webrtc_line(text: &str) -> bool {
50
WEBRTC_AUDIO_MARKERS
51
.iter()
52
.any(|marker| text.contains(marker))
53
&& !WEBRTC_SKIPPED.iter().any(|skipped| text.contains(skipped))
54
&& !is_endpoint_dump(text)
58
pub fn enable_from_override() -> bool {
59
let on = std::env::args().any(|arg| arg == "--debug-log")
60
|| std::env::var(ENV_DEBUG_LOG)
61
.map(|value| matches!(value.as_str(), "1" | "true" | "TRUE" | "yes" | "YES"))
62
.unwrap_or(false);
63
if on {
64
set_enabled(true);
65
}
66
on
55
67
}
56
68
57
fn is_endpoint_dump(text: &str) -> bool {
58
text.split_once("audio_device_core_win.cc:")
59
.and_then(|(_, rest)| rest.split_once(')'))
60
.and_then(|(line, _)| line.parse::<u32>().ok())
61
.is_some_and(|line| ENDPOINT_DUMP_LINES.contains(&line))
69
pub fn load_enabled_from_store(stored: Option<&str>) -> bool {
70
let on = stored == Some("1");
71
set_enabled(on || is_enabled());
72
is_enabled()
62
73
}
63
74
64
75
pub fn directory() -> Option<PathBuf> {
65
76
PATH.get().and_then(|path| path.parent()).map(PathBuf::from)
66
77
}
67
78
79
pub fn path() -> Option<PathBuf> {
80
PATH.get().cloned()
81
}
82
68
83
pub fn record_if_slow(label: &str, elapsed: std::time::Duration) {
69
84
if elapsed >= SLOW_UI_HANDLER {
70
85
record(format!(
@@ -75,21 +90,120 @@ pub fn record_if_slow(label: &str, elapsed: std::time::Duration) {
75
90
}
76
91
77
92
pub fn record(message: impl AsRef<str>) {
93
if !is_enabled() {
94
return;
95
}
78
96
let message = message.as_ref();
79
97
eprintln!("{message}");
80
98
let Some(path) = PATH.get() else {
81
99
return;
82
100
};
83
let full = std::fs::metadata(path).is_ok_and(|metadata| metadata.len() > MAX_BYTES);
84
let file = OpenOptions::new()
85
.create(true)
86
.write(true)
87
.append(!full)
88
.truncate(full)
89
.open(path);
90
if let Ok(mut file) = file {
91
let _ = writeln!(file, "{} {message}", line_prefix());
101
if let Err(error) = append_rotated(path, MAX_BYTES, RING_SLOTS, &format!("{} {message}\n", line_prefix()))
102
{
103
eprintln!("diagnostics write failed: {error}");
104
}
105
}
106
107
/// Chronological merge of rotated slots then current (capped), for support packages.
108
pub fn read_merged(max_bytes: u64) -> String {
109
let Some(path) = PATH.get() else {
110
return String::new();
111
};
112
read_ring_merged(path, RING_SLOTS, max_bytes.min(MERGE_CAP_BYTES).max(1))
113
}
114
115
pub fn clear_logs() -> std::io::Result<()> {
116
let Some(root) = directory() else {
117
return Ok(());
118
};
119
for name in [
120
DIAGNOSTICS_FILE,
121
&format!("{DIAGNOSTICS_FILE}.1"),
122
&format!("{DIAGNOSTICS_FILE}.2"),
123
crate::crash_log::CRASH_LOG_FILE,
124
&format!("{}.1", crate::crash_log::CRASH_LOG_FILE),
125
] {
126
let path = root.join(name);
127
if path.exists() {
128
let _ = fs::remove_file(&path);
129
}
130
}
131
let dumps = root.join(crate::support::CALL_DUMPS_DIR);
132
if dumps.is_dir() {
133
for entry in fs::read_dir(&dumps)?.flatten() {
134
let path = entry.path();
135
if path.is_dir() {
136
let _ = fs::remove_dir_all(path);
137
} else {
138
let _ = fs::remove_file(path);
139
}
140
}
92
141
}
142
Ok(())
143
}
144
145
pub(crate) fn append_rotated(
146
path: &Path,
147
max_bytes: u64,
148
ring_slots: u32,
149
line: &str,
150
) -> std::io::Result<()> {
151
if path
152
.metadata()
153
.map(|meta| meta.len() >= max_bytes)
154
.unwrap_or(false)
155
{
156
rotate_ring(path, ring_slots)?;
157
}
158
if let Some(parent) = path.parent() {
159
fs::create_dir_all(parent)?;
160
}
161
let mut file = OpenOptions::new().create(true).append(true).open(path)?;
162
file.write_all(line.as_bytes())
163
}
164
165
fn rotate_ring(path: &Path, ring_slots: u32) -> std::io::Result<()> {
166
for slot in (1..ring_slots).rev() {
167
let from = ring_path(path, slot);
168
let to = ring_path(path, slot + 1);
169
if from.exists() {
170
let _ = fs::remove_file(&to);
171
fs::rename(&from, &to)?;
172
}
173
}
174
let first = ring_path(path, 1);
175
let _ = fs::remove_file(&first);
176
if path.exists() {
177
fs::rename(path, &first)?;
178
}
179
Ok(())
180
}
181
182
fn ring_path(path: &Path, slot: u32) -> PathBuf {
183
path.with_file_name(format!(
184
"{}.{}",
185
path.file_name().and_then(|name| name.to_str()).unwrap_or(DIAGNOSTICS_FILE),
186
slot
187
))
188
}
189
190
pub(crate) fn read_ring_merged(path: &Path, slots: u32, max_bytes: u64) -> String {
191
let mut parts = Vec::new();
192
for slot in (1..=slots).rev() {
193
let sibling = ring_path(path, slot);
194
if let Ok(text) = fs::read_to_string(&sibling) {
195
parts.push(text);
196
}
197
}
198
if let Ok(text) = fs::read_to_string(path) {
199
parts.push(text);
200
}
201
let merged = parts.join("");
202
if merged.len() as u64 <= max_bytes {
203
return merged;
204
}
205
let start = merged.len() - max_bytes as usize;
206
merged[start..].to_owned()
93
207
}
94
208
95
209
fn line_prefix() -> String {
@@ -100,31 +214,144 @@ fn line_prefix() -> String {
100
214
)
101
215
}
102
216
217
struct DiagnosticsLog;
218
219
impl log::Log for DiagnosticsLog {
220
fn enabled(&self, metadata: &log::Metadata<'_>) -> bool {
221
if !is_enabled() {
222
return false;
223
}
224
let target = metadata.target();
225
if target == "libwebrtc" {
226
return true;
227
}
228
if is_own_crate(target) {
229
return metadata.level() <= log::Level::Info;
230
}
231
metadata.level() <= log::Level::Warn
232
}
233
234
fn log(&self, entry: &log::Record<'_>) {
235
if !self.enabled(entry.metadata()) {
236
return;
237
}
238
let target = entry.metadata().target();
239
let text = entry.args().to_string();
240
if target == "libwebrtc" {
241
if keeps_webrtc_line(entry.metadata().level(), &text) {
242
record(format!("webrtc: {text}"));
243
}
244
return;
245
}
246
let level = entry.metadata().level().as_str().to_ascii_lowercase();
247
let short = target.split("::").next().unwrap_or(target);
248
record(format!("{level} {short}: {text}"));
249
}
250
251
fn flush(&self) {}
252
}
253
254
fn is_own_crate(target: &str) -> bool {
255
let root = target.split("::").next().unwrap_or(target);
256
OWN_CRATE_PREFIXES
257
.iter()
258
.any(|prefix| root == *prefix || root.starts_with(&format!("{prefix}_")))
259
}
260
261
fn keeps_webrtc_line(level: log::Level, text: &str) -> bool {
262
if level <= log::Level::Warn
263
&& (text.contains("peer_connection")
264
|| text.contains("PeerConnection")
265
|| text.contains("ICE")
266
|| text.contains("ice_"))
267
{
268
return true;
269
}
270
WEBRTC_AUDIO_MARKERS
271
.iter()
272
.any(|marker| text.contains(marker))
273
&& !WEBRTC_SKIPPED.iter().any(|skipped| text.contains(skipped))
274
&& !is_endpoint_dump(text)
275
}
276
277
fn is_endpoint_dump(text: &str) -> bool {
278
text.split_once("audio_device_core_win.cc:")
279
.and_then(|(_, rest)| rest.split_once(')'))
280
.and_then(|(line, _)| line.parse::<u32>().ok())
281
.is_some_and(|line| ENDPOINT_DUMP_LINES.contains(&line))
282
}
283
103
284
#[cfg(test)]
104
285
mod tests {
105
use super::keeps_webrtc_line;
286
use super::*;
287
use tempfile::tempdir;
106
288
107
289
#[test]
108
290
fn audio_lines_are_kept_and_endpoint_dumps_and_noise_are_skipped() {
109
assert!(keeps_webrtc_line("(audio_device_impl.cc:123): Init"));
291
assert!(keeps_webrtc_line(log::Level::Debug, "(audio_device_impl.cc:123): Init"));
110
292
assert!(keeps_webrtc_line(
293
log::Level::Debug,
111
294
"(webrtc_voice_engine.cc:10): WebRtcVoiceEngine::Init"
112
295
));
113
296
assert!(!keeps_webrtc_line(
297
log::Level::Debug,
114
298
"(audio_device_core_win.cc:4090): endpoint 3"
115
299
));
116
300
assert!(keeps_webrtc_line(
301
log::Level::Debug,
117
302
"(audio_device_core_win.cc:412): AvRevertMmThreadCharacteristics() is OK"
118
303
));
119
304
assert!(!keeps_webrtc_line(
305
log::Level::Debug,
120
306
"(audio_device_buffer.cc:450): [REC : 10000msec, 48kHz] callbacks: 1000"
121
307
));
122
308
assert!(!keeps_webrtc_line(
309
log::Level::Debug,
123
310
"(audio_device_pulse_linux.cc:2236): requesting data"
124
311
));
125
312
assert!(!keeps_webrtc_line(
313
log::Level::Debug,
126
314
"(audio_device_pulse_linux.cc:2256): will write"
127
315
));
128
assert!(!keeps_webrtc_line("(peer_connection.cc:55): something"));
316
assert!(!keeps_webrtc_line(
317
log::Level::Debug,
318
"(peer_connection.cc:55): something"
319
));
320
assert!(keeps_webrtc_line(
321
log::Level::Warn,
322
"(peer_connection.cc:55): ICE failed"
323
));
324
}
325
326
#[test]
327
fn enabled_gate_defaults_and_toggles() {
328
set_enabled(false);
329
assert!(!is_enabled());
330
set_enabled(true);
331
assert!(is_enabled());
332
set_enabled(false);
333
assert!(!is_enabled());
334
}
335
336
#[test]
337
fn ring_rotation_preserves_previous_content() {
338
let root = tempdir().unwrap();
339
let path = root.path().join(DIAGNOSTICS_FILE);
340
fs::write(&path, "a".repeat(MAX_BYTES as usize)).unwrap();
341
append_rotated(&path, MAX_BYTES, RING_SLOTS, "fresh-line\n").unwrap();
342
assert!(ring_path(&path, 1).exists());
343
let current = fs::read_to_string(&path).unwrap();
344
assert!(current.contains("fresh-line"));
345
assert!(!current.contains(&"a".repeat(32)));
346
let previous = fs::read_to_string(ring_path(&path, 1)).unwrap();
347
assert!(previous.starts_with('a'));
348
}
349
350
#[test]
351
fn own_crate_prefixes_match() {
352
assert!(is_own_crate("app::linux_browser"));
353
assert!(is_own_crate("state::notice"));
354
assert!(is_own_crate("app_base::diagnostics"));
355
assert!(!is_own_crate("hyper::client"));
129
356
}
130
357
}
@@ -1,13 +1,33 @@1
use std::fs::OpenOptions;1
use std::fs::{self, OpenOptions};2
use std::io::Write;2
use std::io::Write;3
use std::path::PathBuf;3
use std::path::{Path, PathBuf};4
use std::sync::atomic::{AtomicBool, Ordering};4
use std::sync::OnceLock;5
use std::sync::OnceLock;5
6
6
pub const DIAGNOSTICS_FILE: &str = "diagnostics.log";7
pub const DIAGNOSTICS_FILE: &str = "diagnostics.log";8
pub const DIAGNOSTICS_SETTING_KEY: &str = "diagnostics_enabled";9
pub const ENV_DEBUG_LOG: &str = "RUSTY_TEAMS_DEBUG_LOG";10
7
const MAX_BYTES: u64 = 1024 * 1024;11
const MAX_BYTES: u64 = 1024 * 1024;12
const RING_SLOTS: u32 = 2;13
const MERGE_CAP_BYTES: u64 = 1024 * 1024;8
const SLOW_UI_HANDLER: std::time::Duration = std::time::Duration::from_millis(30);14
const SLOW_UI_HANDLER: std::time::Duration = std::time::Duration::from_millis(30);9
15
10
static PATH: OnceLock<PathBuf> = OnceLock::new();16
static PATH: OnceLock<PathBuf> = OnceLock::new();17
static ENABLED: AtomicBool = AtomicBool::new(false);18
19
const OWN_CRATE_PREFIXES: [&str; 10] = [20
"app",21
"app_base",22
"state",23
"calling",24
"chatsvc",25
"session",26
"webview",27
"mcp",28
"agents",29
"teams",30
];11
31
12
const WEBRTC_AUDIO_MARKERS: [&str; 5] = [32
const WEBRTC_AUDIO_MARKERS: [&str; 5] = [13
"AdmProxy",33
"AdmProxy",@@ -21,50 +41,45 @@ const ENDPOINT_DUMP_LINES: std::ops::Range<u32> = 4040..4170;21
41
22
pub fn install(path: PathBuf) {42
pub fn install(path: PathBuf) {23
let _ = PATH.set(path);43
let _ = PATH.set(path);24
if log::set_logger(&WebrtcAudioLog).is_ok() {44
if log::set_logger(&DiagnosticsLog).is_ok() {25
log::set_max_level(log::LevelFilter::Debug);45
log::set_max_level(log::LevelFilter::Debug);26
}46
}47
crate::support::install_panic_diagnostics_hook();27
}48
}28
49
29
struct WebrtcAudioLog;50
pub fn is_enabled() -> bool {30
51
ENABLED.load(Ordering::Relaxed)31
impl log::Log for WebrtcAudioLog {52
}32
fn enabled(&self, metadata: &log::Metadata<'_>) -> bool {33
metadata.target() == "libwebrtc"34
}35
36
fn log(&self, entry: &log::Record<'_>) {37
if !self.enabled(entry.metadata()) {38
return;39
}40
let text = entry.args().to_string();41
if keeps_webrtc_line(&text) {42
record(format!("webrtc: {text}"));43
}44
}45
53
46
fn flush(&self) {}54
pub fn set_enabled(on: bool) {55
ENABLED.store(on, Ordering::Relaxed);47
}56
}48
57
49
fn keeps_webrtc_line(text: &str) -> bool {58
pub fn enable_from_override() -> bool {50
WEBRTC_AUDIO_MARKERS59
let on = std::env::args().any(|arg| arg == "--debug-log")51
.iter()60
|| std::env::var(ENV_DEBUG_LOG)52
.any(|marker| text.contains(marker))61
.map(|value| matches!(value.as_str(), "1" | "true" | "TRUE" | "yes" | "YES"))53
&& !WEBRTC_SKIPPED.iter().any(|skipped| text.contains(skipped))62
.unwrap_or(false);54
&& !is_endpoint_dump(text)63
if on {64
set_enabled(true);65
}66
on55
}67
}56
68
57
fn is_endpoint_dump(text: &str) -> bool {69
pub fn load_enabled_from_store(stored: Option<&str>) -> bool {58
text.split_once("audio_device_core_win.cc:")70
let on = stored == Some("1");59
.and_then(|(_, rest)| rest.split_once(')'))71
set_enabled(on || is_enabled());60
.and_then(|(line, _)| line.parse::<u32>().ok())72
is_enabled()61
.is_some_and(|line| ENDPOINT_DUMP_LINES.contains(&line))62
}73
}63
74
64
pub fn directory() -> Option<PathBuf> {75
pub fn directory() -> Option<PathBuf> {65
PATH.get().and_then(|path| path.parent()).map(PathBuf::from)76
PATH.get().and_then(|path| path.parent()).map(PathBuf::from)66
}77
}67
78
79
pub fn path() -> Option<PathBuf> {80
PATH.get().cloned()81
}82
68
pub fn record_if_slow(label: &str, elapsed: std::time::Duration) {83
pub fn record_if_slow(label: &str, elapsed: std::time::Duration) {69
if elapsed >= SLOW_UI_HANDLER {84
if elapsed >= SLOW_UI_HANDLER {70
record(format!(85
record(format!(@@ -75,21 +90,120 @@ pub fn record_if_slow(label: &str, elapsed: std::time::Duration) {75
}90
}76
91
77
pub fn record(message: impl AsRef<str>) {92
pub fn record(message: impl AsRef<str>) {93
if !is_enabled() {94
return;95
}78
let message = message.as_ref();96
let message = message.as_ref();79
eprintln!("{message}");97
eprintln!("{message}");80
let Some(path) = PATH.get() else {98
let Some(path) = PATH.get() else {81
return;99
return;82
};100
};83
let full = std::fs::metadata(path).is_ok_and(|metadata| metadata.len() > MAX_BYTES);101
if let Err(error) = append_rotated(path, MAX_BYTES, RING_SLOTS, &format!("{} {message}\n", line_prefix()))84
let file = OpenOptions::new()102
{85
.create(true)103
eprintln!("diagnostics write failed: {error}");86
.write(true)104
}87
.append(!full)105
}88
.truncate(full)106
89
.open(path);107
/// Chronological merge of rotated slots then current (capped), for support packages.90
if let Ok(mut file) = file {108
pub fn read_merged(max_bytes: u64) -> String {91
let _ = writeln!(file, "{} {message}", line_prefix());109
let Some(path) = PATH.get() else {110
return String::new();111
};112
read_ring_merged(path, RING_SLOTS, max_bytes.min(MERGE_CAP_BYTES).max(1))113
}114
115
pub fn clear_logs() -> std::io::Result<()> {116
let Some(root) = directory() else {117
return Ok(());118
};119
for name in [120
DIAGNOSTICS_FILE,121
&format!("{DIAGNOSTICS_FILE}.1"),122
&format!("{DIAGNOSTICS_FILE}.2"),123
crate::crash_log::CRASH_LOG_FILE,124
&format!("{}.1", crate::crash_log::CRASH_LOG_FILE),125
] {126
let path = root.join(name);127
if path.exists() {128
let _ = fs::remove_file(&path);129
}130
}131
let dumps = root.join(crate::support::CALL_DUMPS_DIR);132
if dumps.is_dir() {133
for entry in fs::read_dir(&dumps)?.flatten() {134
let path = entry.path();135
if path.is_dir() {136
let _ = fs::remove_dir_all(path);137
} else {138
let _ = fs::remove_file(path);139
}140
}92
}141
}142
Ok(())143
}144
145
pub(crate) fn append_rotated(146
path: &Path,147
max_bytes: u64,148
ring_slots: u32,149
line: &str,150
) -> std::io::Result<()> {151
if path152
.metadata()153
.map(|meta| meta.len() >= max_bytes)154
.unwrap_or(false)155
{156
rotate_ring(path, ring_slots)?;157
}158
if let Some(parent) = path.parent() {159
fs::create_dir_all(parent)?;160
}161
let mut file = OpenOptions::new().create(true).append(true).open(path)?;162
file.write_all(line.as_bytes())163
}164
165
fn rotate_ring(path: &Path, ring_slots: u32) -> std::io::Result<()> {166
for slot in (1..ring_slots).rev() {167
let from = ring_path(path, slot);168
let to = ring_path(path, slot + 1);169
if from.exists() {170
let _ = fs::remove_file(&to);171
fs::rename(&from, &to)?;172
}173
}174
let first = ring_path(path, 1);175
let _ = fs::remove_file(&first);176
if path.exists() {177
fs::rename(path, &first)?;178
}179
Ok(())180
}181
182
fn ring_path(path: &Path, slot: u32) -> PathBuf {183
path.with_file_name(format!(184
"{}.{}",185
path.file_name().and_then(|name| name.to_str()).unwrap_or(DIAGNOSTICS_FILE),186
slot187
))188
}189
190
pub(crate) fn read_ring_merged(path: &Path, slots: u32, max_bytes: u64) -> String {191
let mut parts = Vec::new();192
for slot in (1..=slots).rev() {193
let sibling = ring_path(path, slot);194
if let Ok(text) = fs::read_to_string(&sibling) {195
parts.push(text);196
}197
}198
if let Ok(text) = fs::read_to_string(path) {199
parts.push(text);200
}201
let merged = parts.join("");202
if merged.len() as u64 <= max_bytes {203
return merged;204
}205
let start = merged.len() - max_bytes as usize;206
merged[start..].to_owned()93
}207
}94
208
95
fn line_prefix() -> String {209
fn line_prefix() -> String {@@ -100,31 +214,144 @@ fn line_prefix() -> String {100
)214
)101
}215
}102
216
217
struct DiagnosticsLog;218
219
impl log::Log for DiagnosticsLog {220
fn enabled(&self, metadata: &log::Metadata<'_>) -> bool {221
if !is_enabled() {222
return false;223
}224
let target = metadata.target();225
if target == "libwebrtc" {226
return true;227
}228
if is_own_crate(target) {229
return metadata.level() <= log::Level::Info;230
}231
metadata.level() <= log::Level::Warn232
}233
234
fn log(&self, entry: &log::Record<'_>) {235
if !self.enabled(entry.metadata()) {236
return;237
}238
let target = entry.metadata().target();239
let text = entry.args().to_string();240
if target == "libwebrtc" {241
if keeps_webrtc_line(entry.metadata().level(), &text) {242
record(format!("webrtc: {text}"));243
}244
return;245
}246
let level = entry.metadata().level().as_str().to_ascii_lowercase();247
let short = target.split("::").next().unwrap_or(target);248
record(format!("{level} {short}: {text}"));249
}250
251
fn flush(&self) {}252
}253
254
fn is_own_crate(target: &str) -> bool {255
let root = target.split("::").next().unwrap_or(target);256
OWN_CRATE_PREFIXES257
.iter()258
.any(|prefix| root == *prefix || root.starts_with(&format!("{prefix}_")))259
}260
261
fn keeps_webrtc_line(level: log::Level, text: &str) -> bool {262
if level <= log::Level::Warn263
&& (text.contains("peer_connection")264
|| text.contains("PeerConnection")265
|| text.contains("ICE")266
|| text.contains("ice_"))267
{268
return true;269
}270
WEBRTC_AUDIO_MARKERS271
.iter()272
.any(|marker| text.contains(marker))273
&& !WEBRTC_SKIPPED.iter().any(|skipped| text.contains(skipped))274
&& !is_endpoint_dump(text)275
}276
277
fn is_endpoint_dump(text: &str) -> bool {278
text.split_once("audio_device_core_win.cc:")279
.and_then(|(_, rest)| rest.split_once(')'))280
.and_then(|(line, _)| line.parse::<u32>().ok())281
.is_some_and(|line| ENDPOINT_DUMP_LINES.contains(&line))282
}283
103
#[cfg(test)]284
#[cfg(test)]104
mod tests {285
mod tests {105
use super::keeps_webrtc_line;286
use super::*;287
use tempfile::tempdir;106
288
107
#[test]289
#[test]108
fn audio_lines_are_kept_and_endpoint_dumps_and_noise_are_skipped() {290
fn audio_lines_are_kept_and_endpoint_dumps_and_noise_are_skipped() {109
assert!(keeps_webrtc_line("(audio_device_impl.cc:123): Init"));291
assert!(keeps_webrtc_line(log::Level::Debug, "(audio_device_impl.cc:123): Init"));110
assert!(keeps_webrtc_line(292
assert!(keeps_webrtc_line(293
log::Level::Debug,111
"(webrtc_voice_engine.cc:10): WebRtcVoiceEngine::Init"294
"(webrtc_voice_engine.cc:10): WebRtcVoiceEngine::Init"112
));295
));113
assert!(!keeps_webrtc_line(296
assert!(!keeps_webrtc_line(297
log::Level::Debug,114
"(audio_device_core_win.cc:4090): endpoint 3"298
"(audio_device_core_win.cc:4090): endpoint 3"115
));299
));116
assert!(keeps_webrtc_line(300
assert!(keeps_webrtc_line(301
log::Level::Debug,117
"(audio_device_core_win.cc:412): AvRevertMmThreadCharacteristics() is OK"302
"(audio_device_core_win.cc:412): AvRevertMmThreadCharacteristics() is OK"118
));303
));119
assert!(!keeps_webrtc_line(304
assert!(!keeps_webrtc_line(305
log::Level::Debug,120
"(audio_device_buffer.cc:450): [REC : 10000msec, 48kHz] callbacks: 1000"306
"(audio_device_buffer.cc:450): [REC : 10000msec, 48kHz] callbacks: 1000"121
));307
));122
assert!(!keeps_webrtc_line(308
assert!(!keeps_webrtc_line(309
log::Level::Debug,123
"(audio_device_pulse_linux.cc:2236): requesting data"310
"(audio_device_pulse_linux.cc:2236): requesting data"124
));311
));125
assert!(!keeps_webrtc_line(312
assert!(!keeps_webrtc_line(313
log::Level::Debug,126
"(audio_device_pulse_linux.cc:2256): will write"314
"(audio_device_pulse_linux.cc:2256): will write"127
));315
));128
assert!(!keeps_webrtc_line("(peer_connection.cc:55): something"));316
assert!(!keeps_webrtc_line(317
log::Level::Debug,318
"(peer_connection.cc:55): something"319
));320
assert!(keeps_webrtc_line(321
log::Level::Warn,322
"(peer_connection.cc:55): ICE failed"323
));324
}325
326
#[test]327
fn enabled_gate_defaults_and_toggles() {328
set_enabled(false);329
assert!(!is_enabled());330
set_enabled(true);331
assert!(is_enabled());332
set_enabled(false);333
assert!(!is_enabled());334
}335
336
#[test]337
fn ring_rotation_preserves_previous_content() {338
let root = tempdir().unwrap();339
let path = root.path().join(DIAGNOSTICS_FILE);340
fs::write(&path, "a".repeat(MAX_BYTES as usize)).unwrap();341
append_rotated(&path, MAX_BYTES, RING_SLOTS, "fresh-line\n").unwrap();342
assert!(ring_path(&path, 1).exists());343
let current = fs::read_to_string(&path).unwrap();344
assert!(current.contains("fresh-line"));345
assert!(!current.contains(&"a".repeat(32)));346
let previous = fs::read_to_string(ring_path(&path, 1)).unwrap();347
assert!(previous.starts_with('a'));348
}349
350
#[test]351
fn own_crate_prefixes_match() {352
assert!(is_own_crate("app::linux_browser"));353
assert!(is_own_crate("state::notice"));354
assert!(is_own_crate("app_base::diagnostics"));355
assert!(!is_own_crate("hyper::client"));129
}356
}130
}357
}@@ -37,6 +37,7 @@ pub mod runtime;
37
37
pub mod schedule_time;
38
38
pub mod single_instance;
39
39
pub mod stickers;
40
pub mod support;
40
41
pub mod task_dialog;
41
42
pub mod theme;
42
43
pub mod translation;
@@ -37,6 +37,7 @@ pub mod runtime;37
pub mod schedule_time;37
pub mod schedule_time;38
pub mod single_instance;38
pub mod single_instance;39
pub mod stickers;39
pub mod stickers;40
pub mod support;40
pub mod task_dialog;41
pub mod task_dialog;41
pub mod theme;42
pub mod theme;42
pub mod translation;43
pub mod translation;@@ -0,0 +1,490 @@
1
use std::path::{Path, PathBuf};
2
3
use crate::diagnostics;
4
use crate::version;
5
6
pub const SUPPORT_BUNDLES_DIR: &str = "support-bundles";
7
pub const CALL_REPORTS_DIR: &str = "call-reports";
8
pub const CALL_DUMPS_DIR: &str = "call-dumps";
9
pub const CRASH_LOG_FILE: &str = "crash.log";
10
11
/// Upstream tracker — fork mirror has Issues disabled.
12
pub const GITHUB_ISSUES_NEW: &str = "https://github.com/danieldaeschle/rusty-teams/issues/new";
13
14
/// Runtime facts for Help, `client.md`, clipboard, and issue drafts. English keys only.
15
#[derive(Debug, Clone, PartialEq, Eq)]
16
pub struct ClientInfo {
17
pub version: String,
18
pub build: String,
19
pub os: String,
20
pub arch: String,
21
pub session: String,
22
pub ui_locale: String,
23
pub timezone: String,
24
pub signed_in: bool,
25
pub call_reports: bool,
26
pub debug_logging: bool,
27
pub audio_input: String,
28
pub audio_output: String,
29
pub camera: String,
30
pub logs_root: String,
31
pub support_bundles_root: String,
32
}
33
34
impl ClientInfo {
35
pub fn capture(
36
package_version: &str,
37
ui_locale: &str,
38
signed_in: bool,
39
call_reports: bool,
40
audio_input: impl Into<String>,
41
audio_output: impl Into<String>,
42
camera: impl Into<String>,
43
) -> Self {
44
let logs_root = local_data_dir()
45
.map(|path| path.display().to_string())
46
.unwrap_or_else(|| "unknown".to_owned());
47
let support_bundles_root = support_bundles_dir()
48
.map(|path| path.display().to_string())
49
.unwrap_or_else(|| "unknown".to_owned());
50
ClientInfo {
51
version: package_version.to_owned(),
52
build: version::build_version().to_owned(),
53
os: std::env::consts::OS.to_owned(),
54
arch: std::env::consts::ARCH.to_owned(),
55
session: desktop_session(),
56
ui_locale: ui_locale.to_owned(),
57
timezone: timezone_name(),
58
signed_in,
59
call_reports,
60
debug_logging: diagnostics::is_enabled(),
61
audio_input: audio_input.into(),
62
audio_output: audio_output.into(),
63
camera: camera.into(),
64
logs_root,
65
support_bundles_root,
66
}
67
}
68
69
pub fn markdown(&self) -> String {
70
format!(
71
"### Client\n\
72
- Version: {}\n\
73
- Build: {}\n\
74
- OS: {} ({})\n\
75
- Session: {}\n\
76
- UI language: {}\n\
77
- Timezone: {}\n\
78
- Signed in: {}\n\
79
- Call reports: {}\n\
80
- Debug logging: {}\n\
81
- Audio input: {}\n\
82
- Audio output: {}\n\
83
- Camera: {}\n\
84
- Logs root: {}\n\
85
- Support bundles: {}\n",
86
self.version,
87
self.build,
88
self.os,
89
self.arch,
90
self.session,
91
self.ui_locale,
92
self.timezone,
93
yes_no(self.signed_in),
94
yes_no(self.call_reports),
95
yes_no(self.debug_logging),
96
self.audio_input,
97
self.audio_output,
98
self.camera,
99
self.logs_root,
100
self.support_bundles_root,
101
)
102
}
103
104
pub fn one_line(&self) -> String {
105
format!(
106
"client version={} build={} os={}/{} session={} locale={} tz={} signed_in={} call_reports={} debug_logging={} logs={}",
107
self.version,
108
self.build,
109
self.os,
110
self.arch,
111
self.session,
112
self.ui_locale,
113
self.timezone,
114
yes_no(self.signed_in),
115
yes_no(self.call_reports),
116
yes_no(self.debug_logging),
117
self.logs_root,
118
)
119
}
120
}
121
122
fn yes_no(value: bool) -> &'static str {
123
if value { "yes" } else { "no" }
124
}
125
126
pub fn desktop_session() -> String {
127
#[cfg(target_os = "linux")]
128
{
129
std::env::var("XDG_SESSION_TYPE")
130
.ok()
131
.filter(|value| !value.is_empty())
132
.unwrap_or_else(|| "unknown".to_owned())
133
}
134
#[cfg(target_os = "macos")]
135
{
136
"macos".to_owned()
137
}
138
#[cfg(target_os = "windows")]
139
{
140
"windows".to_owned()
141
}
142
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
143
{
144
"unknown".to_owned()
145
}
146
}
147
148
fn timezone_name() -> String {
149
std::env::var("TZ")
150
.ok()
151
.filter(|value| !value.is_empty())
152
.unwrap_or_else(|| format!("{}", chrono::Local::now().offset()))
153
}
154
155
/// OS local application data root for `ms-teams-linux` (legacy product directory name).
156
pub fn local_data_dir() -> Option<PathBuf> {
157
directories::ProjectDirs::from("", "", store::DATA_DIR_NAME)
158
.map(|directories| directories.data_local_dir().to_path_buf())
159
}
160
161
pub fn diagnostics_log_path() -> Option<PathBuf> {
162
local_data_dir().map(|root| root.join(diagnostics::DIAGNOSTICS_FILE))
163
}
164
165
pub fn crash_log_path() -> Option<PathBuf> {
166
local_data_dir().map(|root| root.join(CRASH_LOG_FILE))
167
}
168
169
pub fn call_dumps_dir() -> Option<PathBuf> {
170
local_data_dir().map(|root| root.join(CALL_DUMPS_DIR))
171
}
172
173
pub fn call_reports_dir() -> Option<PathBuf> {
174
local_data_dir().map(|root| root.join(CALL_REPORTS_DIR))
175
}
176
177
pub fn support_bundles_dir() -> Option<PathBuf> {
178
local_data_dir().map(|root| root.join(SUPPORT_BUNDLES_DIR))
179
}
180
181
pub fn support_bundles_directory(data_dir: &Path) -> PathBuf {
182
data_dir.join(SUPPORT_BUNDLES_DIR)
183
}
184
185
pub fn bundle_folder_name(utc: chrono::DateTime<chrono::Utc>) -> String {
186
format!("support-{}", utc.format("%Y%m%dT%H%M%SZ"))
187
}
188
189
#[derive(Debug, Clone, PartialEq, Eq)]
190
pub struct SupportBundleEntry {
191
pub directory: PathBuf,
192
pub name: String,
193
}
194
195
#[derive(Debug, Clone, PartialEq, Eq)]
196
pub struct BundleFileEntry {
197
pub path: PathBuf,
198
pub name: String,
199
pub size_bytes: u64,
200
}
201
202
/// Newest-first list of package folders under `support-bundles/`.
203
pub fn list_support_bundles(root: &Path) -> std::io::Result<Vec<SupportBundleEntry>> {
204
if !root.is_dir() {
205
return Ok(Vec::new());
206
}
207
let mut entries: Vec<SupportBundleEntry> = std::fs::read_dir(root)?
208
.filter_map(Result::ok)
209
.map(|entry| entry.path())
210
.filter(|path| path.is_dir())
211
.filter_map(|directory| {
212
let name = directory.file_name()?.to_string_lossy().into_owned();
213
Some(SupportBundleEntry { directory, name })
214
})
215
.collect();
216
entries.sort_by(|left, right| right.name.cmp(&left.name));
217
Ok(entries)
218
}
219
220
pub fn list_bundle_files(bundle: &Path) -> std::io::Result<Vec<BundleFileEntry>> {
221
if !bundle.is_dir() {
222
return Ok(Vec::new());
223
}
224
let mut files: Vec<BundleFileEntry> = std::fs::read_dir(bundle)?
225
.filter_map(Result::ok)
226
.map(|entry| entry.path())
227
.filter(|path| path.is_file())
228
.filter_map(|path| {
229
let name = path.file_name()?.to_string_lossy().into_owned();
230
let size_bytes = std::fs::metadata(&path).ok()?.len();
231
Some(BundleFileEntry {
232
path,
233
name,
234
size_bytes,
235
})
236
})
237
.collect();
238
files.sort_by(|left, right| left.name.cmp(&right.name));
239
Ok(files)
240
}
241
242
/// Remove one support package directory. Refuses paths outside `parent` when provided.
243
pub fn delete_support_bundle(bundle: &Path, parent: Option<&Path>) -> std::io::Result<()> {
244
if let Some(parent) = parent {
245
let canonical_parent = parent.canonicalize().unwrap_or_else(|_| parent.to_path_buf());
246
let canonical_bundle = bundle.canonicalize().unwrap_or_else(|_| bundle.to_path_buf());
247
if !canonical_bundle.starts_with(&canonical_parent) {
248
return Err(std::io::Error::new(
249
std::io::ErrorKind::InvalidInput,
250
"bundle path is outside the support-bundles directory",
251
));
252
}
253
}
254
if bundle.is_dir() {
255
std::fs::remove_dir_all(bundle)?;
256
}
257
Ok(())
258
}
259
260
pub fn ensure_dir(path: &Path) -> std::io::Result<()> {
261
std::fs::create_dir_all(path)
262
}
263
264
pub fn format_bytes(size: u64) -> String {
265
const KB: u64 = 1024;
266
const MB: u64 = KB * 1024;
267
if size >= MB {
268
format!("{:.1} MB", size as f64 / MB as f64)
269
} else if size >= KB {
270
format!("{:.1} KB", size as f64 / KB as f64)
271
} else {
272
format!("{size} B")
273
}
274
}
275
276
pub fn issue_title() -> &'static str {
277
"Bug report"
278
}
279
280
pub fn issue_body(client: &ClientInfo, bundle: &SupportBundlePaths) -> String {
281
format!(
282
"## What happened\n\n\
283
<!-- Describe the bug -->\n\n\
284
## Expected\n\n\
285
<!-- What should happen -->\n\n\
286
{}\n\
287
Support package folder: `{}`\n\
288
Support package path: `{}`\n\n\
289
Attach the files from that folder (do not paste secrets).\n",
290
client.markdown(),
291
bundle.folder_name,
292
bundle.directory.display(),
293
)
294
}
295
296
#[derive(Debug, Clone, PartialEq, Eq)]
297
pub struct SupportBundlePaths {
298
pub directory: PathBuf,
299
pub folder_name: String,
300
}
301
302
pub fn issue_url(client: &ClientInfo, bundle: &SupportBundlePaths) -> String {
303
format!(
304
"{GITHUB_ISSUES_NEW}?title={}&body={}",
305
encode_query(issue_title()),
306
encode_query(&issue_body(client, bundle))
307
)
308
}
309
310
pub fn encode_query(value: &str) -> String {
311
let mut out = String::with_capacity(value.len() * 3);
312
for byte in value.bytes() {
313
match byte {
314
b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => {
315
out.push(byte as char);
316
}
317
b' ' => out.push_str("%20"),
318
_ => out.push_str(&format!("%{byte:02X}")),
319
}
320
}
321
out
322
}
323
324
/// Append a client snapshot when debug logging is on (after store/locale when possible).
325
pub fn record_startup_client_line(
326
package_version: &str,
327
ui_locale: &str,
328
signed_in: bool,
329
call_reports: bool,
330
) {
331
if !diagnostics::is_enabled() {
332
return;
333
}
334
let info = ClientInfo::capture(
335
package_version,
336
ui_locale,
337
signed_in,
338
call_reports,
339
"n/a",
340
"n/a",
341
"n/a",
342
);
343
diagnostics::record(info.one_line());
344
}
345
346
/// Chain a panic hook that also writes a short line into the diagnostics log.
347
pub fn install_panic_diagnostics_hook() {
348
let previous = std::panic::take_hook();
349
std::panic::set_hook(Box::new(move |info| {
350
let payload = info.payload();
351
let message = payload
352
.downcast_ref::<&str>()
353
.copied()
354
.map(str::to_owned)
355
.or_else(|| payload.downcast_ref::<String>().cloned())
356
.unwrap_or_else(|| "non-text panic payload".to_owned());
357
let location = info
358
.location()
359
.map(|location| {
360
format!(
361
"{}:{}:{}",
362
location.file(),
363
location.line(),
364
location.column()
365
)
366
})
367
.unwrap_or_else(|| "unknown".to_owned());
368
diagnostics::record(format!("panic at {location}: {message}"));
369
previous(info);
370
}));
371
}
372
373
pub fn readme_text() -> &'static str {
374
"Attach the files in this folder to a GitHub issue on danieldaeschle/rusty-teams.\n\
375
The app store, cookies, and tokens are not included.\n"
376
}
377
378
#[cfg(test)]
379
mod tests {
380
use super::*;
381
382
fn sample_client() -> ClientInfo {
383
ClientInfo {
384
version: "0.3.0".into(),
385
build: "abc".into(),
386
os: "linux".into(),
387
arch: "x86_64".into(),
388
session: "wayland".into(),
389
ui_locale: "de".into(),
390
timezone: "Europe/Zurich".into(),
391
signed_in: true,
392
call_reports: false,
393
debug_logging: true,
394
audio_input: "Default device".into(),
395
audio_output: "Default device".into(),
396
camera: "none".into(),
397
logs_root: "/tmp/ms-teams-linux".into(),
398
support_bundles_root: "/tmp/ms-teams-linux/support-bundles".into(),
399
}
400
}
401
402
#[test]
403
fn markdown_block_lists_stable_keys_and_paths() {
404
let text = sample_client().markdown();
405
assert!(text.contains("- Version: 0.3.0"));
406
assert!(text.contains("- Build: abc"));
407
assert!(text.contains("- OS: linux (x86_64)"));
408
assert!(text.contains("- Session: wayland"));
409
assert!(text.contains("- Signed in: yes"));
410
assert!(text.contains("- Call reports: no"));
411
assert!(text.contains("- Logs root: /tmp/ms-teams-linux"));
412
assert!(text.contains("- Support bundles: /tmp/ms-teams-linux/support-bundles"));
413
assert!(!text.contains('@'));
414
}
415
416
#[test]
417
fn layout_relative_names_are_stable() {
418
assert_eq!(SUPPORT_BUNDLES_DIR, "support-bundles");
419
assert_eq!(CALL_REPORTS_DIR, "call-reports");
420
assert_eq!(CALL_DUMPS_DIR, "call-dumps");
421
assert_eq!(CRASH_LOG_FILE, "crash.log");
422
assert_eq!(diagnostics::DIAGNOSTICS_FILE, "diagnostics.log");
423
let root = PathBuf::from("/data/ms-teams-linux");
424
assert_eq!(
425
support_bundles_directory(&root),
426
root.join("support-bundles")
427
);
428
}
429
430
#[test]
431
fn issue_url_encodes_spaces_and_newlines() {
432
let info = sample_client();
433
let bundle = SupportBundlePaths {
434
directory: PathBuf::from("/tmp/ms-teams-linux/support-bundles/support-20260101T000000Z"),
435
folder_name: "support-20260101T000000Z".into(),
436
};
437
let url = issue_url(&info, &bundle);
438
assert!(url.starts_with(GITHUB_ISSUES_NEW));
439
assert!(url.contains("title=Bug%20report"));
440
assert!(url.contains("body="));
441
assert!(url.contains("support-20260101T000000Z"));
442
assert!(!url.contains(' '));
443
}
444
445
#[test]
446
fn encode_query_percent_encodes_specials() {
447
assert_eq!(encode_query("a b"), "a%20b");
448
assert_eq!(encode_query("a&b"), "a%26b");
449
}
450
451
#[test]
452
fn list_and_delete_support_bundles_in_temp_dir() {
453
let root = tempfile::tempdir().unwrap();
454
let bundles = root.path().join(SUPPORT_BUNDLES_DIR);
455
let older = bundles.join("support-20260101T000000Z");
456
let newer = bundles.join("support-20260102T000000Z");
457
std::fs::create_dir_all(&older).unwrap();
458
std::fs::create_dir_all(&newer).unwrap();
459
std::fs::write(older.join("client.md"), "old").unwrap();
460
std::fs::write(newer.join("client.md"), "new").unwrap();
461
std::fs::write(newer.join("diagnostics.log"), "log").unwrap();
462
463
let listed = list_support_bundles(&bundles).unwrap();
464
assert_eq!(listed.len(), 2);
465
assert_eq!(listed[0].name, "support-20260102T000000Z");
466
assert_eq!(listed[1].name, "support-20260101T000000Z");
467
468
let files = list_bundle_files(&newer).unwrap();
469
assert_eq!(files.len(), 2);
470
assert_eq!(files[0].name, "client.md");
471
assert_eq!(files[1].name, "diagnostics.log");
472
473
delete_support_bundle(&newer, Some(&bundles)).unwrap();
474
let listed = list_support_bundles(&bundles).unwrap();
475
assert_eq!(listed.len(), 1);
476
assert_eq!(listed[0].name, "support-20260101T000000Z");
477
assert!(!newer.exists());
478
}
479
480
#[test]
481
fn delete_refuses_paths_outside_parent() {
482
let root = tempfile::tempdir().unwrap();
483
let bundles = root.path().join(SUPPORT_BUNDLES_DIR);
484
let outside = root.path().join("other");
485
std::fs::create_dir_all(&bundles).unwrap();
486
std::fs::create_dir_all(&outside).unwrap();
487
assert!(delete_support_bundle(&outside, Some(&bundles)).is_err());
488
assert!(outside.exists());
489
}
490
}
@@ -0,0 +1,490 @@1
use std::path::{Path, PathBuf};2
3
use crate::diagnostics;4
use crate::version;5
6
pub const SUPPORT_BUNDLES_DIR: &str = "support-bundles";7
pub const CALL_REPORTS_DIR: &str = "call-reports";8
pub const CALL_DUMPS_DIR: &str = "call-dumps";9
pub const CRASH_LOG_FILE: &str = "crash.log";10
11
/// Upstream tracker — fork mirror has Issues disabled.12
pub const GITHUB_ISSUES_NEW: &str = "https://github.com/danieldaeschle/rusty-teams/issues/new";13
14
/// Runtime facts for Help, `client.md`, clipboard, and issue drafts. English keys only.15
#[derive(Debug, Clone, PartialEq, Eq)]16
pub struct ClientInfo {17
pub version: String,18
pub build: String,19
pub os: String,20
pub arch: String,21
pub session: String,22
pub ui_locale: String,23
pub timezone: String,24
pub signed_in: bool,25
pub call_reports: bool,26
pub debug_logging: bool,27
pub audio_input: String,28
pub audio_output: String,29
pub camera: String,30
pub logs_root: String,31
pub support_bundles_root: String,32
}33
34
impl ClientInfo {35
pub fn capture(36
package_version: &str,37
ui_locale: &str,38
signed_in: bool,39
call_reports: bool,40
audio_input: impl Into<String>,41
audio_output: impl Into<String>,42
camera: impl Into<String>,43
) -> Self {44
let logs_root = local_data_dir()45
.map(|path| path.display().to_string())46
.unwrap_or_else(|| "unknown".to_owned());47
let support_bundles_root = support_bundles_dir()48
.map(|path| path.display().to_string())49
.unwrap_or_else(|| "unknown".to_owned());50
ClientInfo {51
version: package_version.to_owned(),52
build: version::build_version().to_owned(),53
os: std::env::consts::OS.to_owned(),54
arch: std::env::consts::ARCH.to_owned(),55
session: desktop_session(),56
ui_locale: ui_locale.to_owned(),57
timezone: timezone_name(),58
signed_in,59
call_reports,60
debug_logging: diagnostics::is_enabled(),61
audio_input: audio_input.into(),62
audio_output: audio_output.into(),63
camera: camera.into(),64
logs_root,65
support_bundles_root,66
}67
}68
69
pub fn markdown(&self) -> String {70
format!(71
"### Client\n\72
- Version: {}\n\73
- Build: {}\n\74
- OS: {} ({})\n\75
- Session: {}\n\76
- UI language: {}\n\77
- Timezone: {}\n\78
- Signed in: {}\n\79
- Call reports: {}\n\80
- Debug logging: {}\n\81
- Audio input: {}\n\82
- Audio output: {}\n\83
- Camera: {}\n\84
- Logs root: {}\n\85
- Support bundles: {}\n",86
self.version,87
self.build,88
self.os,89
self.arch,90
self.session,91
self.ui_locale,92
self.timezone,93
yes_no(self.signed_in),94
yes_no(self.call_reports),95
yes_no(self.debug_logging),96
self.audio_input,97
self.audio_output,98
self.camera,99
self.logs_root,100
self.support_bundles_root,101
)102
}103
104
pub fn one_line(&self) -> String {105
format!(106
"client version={} build={} os={}/{} session={} locale={} tz={} signed_in={} call_reports={} debug_logging={} logs={}",107
self.version,108
self.build,109
self.os,110
self.arch,111
self.session,112
self.ui_locale,113
self.timezone,114
yes_no(self.signed_in),115
yes_no(self.call_reports),116
yes_no(self.debug_logging),117
self.logs_root,118
)119
}120
}121
122
fn yes_no(value: bool) -> &'static str {123
if value { "yes" } else { "no" }124
}125
126
pub fn desktop_session() -> String {127
#[cfg(target_os = "linux")]128
{129
std::env::var("XDG_SESSION_TYPE")130
.ok()131
.filter(|value| !value.is_empty())132
.unwrap_or_else(|| "unknown".to_owned())133
}134
#[cfg(target_os = "macos")]135
{136
"macos".to_owned()137
}138
#[cfg(target_os = "windows")]139
{140
"windows".to_owned()141
}142
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]143
{144
"unknown".to_owned()145
}146
}147
148
fn timezone_name() -> String {149
std::env::var("TZ")150
.ok()151
.filter(|value| !value.is_empty())152
.unwrap_or_else(|| format!("{}", chrono::Local::now().offset()))153
}154
155
/// OS local application data root for `ms-teams-linux` (legacy product directory name).156
pub fn local_data_dir() -> Option<PathBuf> {157
directories::ProjectDirs::from("", "", store::DATA_DIR_NAME)158
.map(|directories| directories.data_local_dir().to_path_buf())159
}160
161
pub fn diagnostics_log_path() -> Option<PathBuf> {162
local_data_dir().map(|root| root.join(diagnostics::DIAGNOSTICS_FILE))163
}164
165
pub fn crash_log_path() -> Option<PathBuf> {166
local_data_dir().map(|root| root.join(CRASH_LOG_FILE))167
}168
169
pub fn call_dumps_dir() -> Option<PathBuf> {170
local_data_dir().map(|root| root.join(CALL_DUMPS_DIR))171
}172
173
pub fn call_reports_dir() -> Option<PathBuf> {174
local_data_dir().map(|root| root.join(CALL_REPORTS_DIR))175
}176
177
pub fn support_bundles_dir() -> Option<PathBuf> {178
local_data_dir().map(|root| root.join(SUPPORT_BUNDLES_DIR))179
}180
181
pub fn support_bundles_directory(data_dir: &Path) -> PathBuf {182
data_dir.join(SUPPORT_BUNDLES_DIR)183
}184
185
pub fn bundle_folder_name(utc: chrono::DateTime<chrono::Utc>) -> String {186
format!("support-{}", utc.format("%Y%m%dT%H%M%SZ"))187
}188
189
#[derive(Debug, Clone, PartialEq, Eq)]190
pub struct SupportBundleEntry {191
pub directory: PathBuf,192
pub name: String,193
}194
195
#[derive(Debug, Clone, PartialEq, Eq)]196
pub struct BundleFileEntry {197
pub path: PathBuf,198
pub name: String,199
pub size_bytes: u64,200
}201
202
/// Newest-first list of package folders under `support-bundles/`.203
pub fn list_support_bundles(root: &Path) -> std::io::Result<Vec<SupportBundleEntry>> {204
if !root.is_dir() {205
return Ok(Vec::new());206
}207
let mut entries: Vec<SupportBundleEntry> = std::fs::read_dir(root)?208
.filter_map(Result::ok)209
.map(|entry| entry.path())210
.filter(|path| path.is_dir())211
.filter_map(|directory| {212
let name = directory.file_name()?.to_string_lossy().into_owned();213
Some(SupportBundleEntry { directory, name })214
})215
.collect();216
entries.sort_by(|left, right| right.name.cmp(&left.name));217
Ok(entries)218
}219
220
pub fn list_bundle_files(bundle: &Path) -> std::io::Result<Vec<BundleFileEntry>> {221
if !bundle.is_dir() {222
return Ok(Vec::new());223
}224
let mut files: Vec<BundleFileEntry> = std::fs::read_dir(bundle)?225
.filter_map(Result::ok)226
.map(|entry| entry.path())227
.filter(|path| path.is_file())228
.filter_map(|path| {229
let name = path.file_name()?.to_string_lossy().into_owned();230
let size_bytes = std::fs::metadata(&path).ok()?.len();231
Some(BundleFileEntry {232
path,233
name,234
size_bytes,235
})236
})237
.collect();238
files.sort_by(|left, right| left.name.cmp(&right.name));239
Ok(files)240
}241
242
/// Remove one support package directory. Refuses paths outside `parent` when provided.243
pub fn delete_support_bundle(bundle: &Path, parent: Option<&Path>) -> std::io::Result<()> {244
if let Some(parent) = parent {245
let canonical_parent = parent.canonicalize().unwrap_or_else(|_| parent.to_path_buf());246
let canonical_bundle = bundle.canonicalize().unwrap_or_else(|_| bundle.to_path_buf());247
if !canonical_bundle.starts_with(&canonical_parent) {248
return Err(std::io::Error::new(249
std::io::ErrorKind::InvalidInput,250
"bundle path is outside the support-bundles directory",251
));252
}253
}254
if bundle.is_dir() {255
std::fs::remove_dir_all(bundle)?;256
}257
Ok(())258
}259
260
pub fn ensure_dir(path: &Path) -> std::io::Result<()> {261
std::fs::create_dir_all(path)262
}263
264
pub fn format_bytes(size: u64) -> String {265
const KB: u64 = 1024;266
const MB: u64 = KB * 1024;267
if size >= MB {268
format!("{:.1} MB", size as f64 / MB as f64)269
} else if size >= KB {270
format!("{:.1} KB", size as f64 / KB as f64)271
} else {272
format!("{size} B")273
}274
}275
276
pub fn issue_title() -> &'static str {277
"Bug report"278
}279
280
pub fn issue_body(client: &ClientInfo, bundle: &SupportBundlePaths) -> String {281
format!(282
"## What happened\n\n\283
<!-- Describe the bug -->\n\n\284
## Expected\n\n\285
<!-- What should happen -->\n\n\286
{}\n\287
Support package folder: `{}`\n\288
Support package path: `{}`\n\n\289
Attach the files from that folder (do not paste secrets).\n",290
client.markdown(),291
bundle.folder_name,292
bundle.directory.display(),293
)294
}295
296
#[derive(Debug, Clone, PartialEq, Eq)]297
pub struct SupportBundlePaths {298
pub directory: PathBuf,299
pub folder_name: String,300
}301
302
pub fn issue_url(client: &ClientInfo, bundle: &SupportBundlePaths) -> String {303
format!(304
"{GITHUB_ISSUES_NEW}?title={}&body={}",305
encode_query(issue_title()),306
encode_query(&issue_body(client, bundle))307
)308
}309
310
pub fn encode_query(value: &str) -> String {311
let mut out = String::with_capacity(value.len() * 3);312
for byte in value.bytes() {313
match byte {314
b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => {315
out.push(byte as char);316
}317
b' ' => out.push_str("%20"),318
_ => out.push_str(&format!("%{byte:02X}")),319
}320
}321
out322
}323
324
/// Append a client snapshot when debug logging is on (after store/locale when possible).325
pub fn record_startup_client_line(326
package_version: &str,327
ui_locale: &str,328
signed_in: bool,329
call_reports: bool,330
) {331
if !diagnostics::is_enabled() {332
return;333
}334
let info = ClientInfo::capture(335
package_version,336
ui_locale,337
signed_in,338
call_reports,339
"n/a",340
"n/a",341
"n/a",342
);343
diagnostics::record(info.one_line());344
}345
346
/// Chain a panic hook that also writes a short line into the diagnostics log.347
pub fn install_panic_diagnostics_hook() {348
let previous = std::panic::take_hook();349
std::panic::set_hook(Box::new(move |info| {350
let payload = info.payload();351
let message = payload352
.downcast_ref::<&str>()353
.copied()354
.map(str::to_owned)355
.or_else(|| payload.downcast_ref::<String>().cloned())356
.unwrap_or_else(|| "non-text panic payload".to_owned());357
let location = info358
.location()359
.map(|location| {360
format!(361
"{}:{}:{}",362
location.file(),363
location.line(),364
location.column()365
)366
})367
.unwrap_or_else(|| "unknown".to_owned());368
diagnostics::record(format!("panic at {location}: {message}"));369
previous(info);370
}));371
}372
373
pub fn readme_text() -> &'static str {374
"Attach the files in this folder to a GitHub issue on danieldaeschle/rusty-teams.\n\375
The app store, cookies, and tokens are not included.\n"376
}377
378
#[cfg(test)]379
mod tests {380
use super::*;381
382
fn sample_client() -> ClientInfo {383
ClientInfo {384
version: "0.3.0".into(),385
build: "abc".into(),386
os: "linux".into(),387
arch: "x86_64".into(),388
session: "wayland".into(),389
ui_locale: "de".into(),390
timezone: "Europe/Zurich".into(),391
signed_in: true,392
call_reports: false,393
debug_logging: true,394
audio_input: "Default device".into(),395
audio_output: "Default device".into(),396
camera: "none".into(),397
logs_root: "/tmp/ms-teams-linux".into(),398
support_bundles_root: "/tmp/ms-teams-linux/support-bundles".into(),399
}400
}401
402
#[test]403
fn markdown_block_lists_stable_keys_and_paths() {404
let text = sample_client().markdown();405
assert!(text.contains("- Version: 0.3.0"));406
assert!(text.contains("- Build: abc"));407
assert!(text.contains("- OS: linux (x86_64)"));408
assert!(text.contains("- Session: wayland"));409
assert!(text.contains("- Signed in: yes"));410
assert!(text.contains("- Call reports: no"));411
assert!(text.contains("- Logs root: /tmp/ms-teams-linux"));412
assert!(text.contains("- Support bundles: /tmp/ms-teams-linux/support-bundles"));413
assert!(!text.contains('@'));414
}415
416
#[test]417
fn layout_relative_names_are_stable() {418
assert_eq!(SUPPORT_BUNDLES_DIR, "support-bundles");419
assert_eq!(CALL_REPORTS_DIR, "call-reports");420
assert_eq!(CALL_DUMPS_DIR, "call-dumps");421
assert_eq!(CRASH_LOG_FILE, "crash.log");422
assert_eq!(diagnostics::DIAGNOSTICS_FILE, "diagnostics.log");423
let root = PathBuf::from("/data/ms-teams-linux");424
assert_eq!(425
support_bundles_directory(&root),426
root.join("support-bundles")427
);428
}429
430
#[test]431
fn issue_url_encodes_spaces_and_newlines() {432
let info = sample_client();433
let bundle = SupportBundlePaths {434
directory: PathBuf::from("/tmp/ms-teams-linux/support-bundles/support-20260101T000000Z"),435
folder_name: "support-20260101T000000Z".into(),436
};437
let url = issue_url(&info, &bundle);438
assert!(url.starts_with(GITHUB_ISSUES_NEW));439
assert!(url.contains("title=Bug%20report"));440
assert!(url.contains("body="));441
assert!(url.contains("support-20260101T000000Z"));442
assert!(!url.contains(' '));443
}444
445
#[test]446
fn encode_query_percent_encodes_specials() {447
assert_eq!(encode_query("a b"), "a%20b");448
assert_eq!(encode_query("a&b"), "a%26b");449
}450
451
#[test]452
fn list_and_delete_support_bundles_in_temp_dir() {453
let root = tempfile::tempdir().unwrap();454
let bundles = root.path().join(SUPPORT_BUNDLES_DIR);455
let older = bundles.join("support-20260101T000000Z");456
let newer = bundles.join("support-20260102T000000Z");457
std::fs::create_dir_all(&older).unwrap();458
std::fs::create_dir_all(&newer).unwrap();459
std::fs::write(older.join("client.md"), "old").unwrap();460
std::fs::write(newer.join("client.md"), "new").unwrap();461
std::fs::write(newer.join("diagnostics.log"), "log").unwrap();462
463
let listed = list_support_bundles(&bundles).unwrap();464
assert_eq!(listed.len(), 2);465
assert_eq!(listed[0].name, "support-20260102T000000Z");466
assert_eq!(listed[1].name, "support-20260101T000000Z");467
468
let files = list_bundle_files(&newer).unwrap();469
assert_eq!(files.len(), 2);470
assert_eq!(files[0].name, "client.md");471
assert_eq!(files[1].name, "diagnostics.log");472
473
delete_support_bundle(&newer, Some(&bundles)).unwrap();474
let listed = list_support_bundles(&bundles).unwrap();475
assert_eq!(listed.len(), 1);476
assert_eq!(listed[0].name, "support-20260101T000000Z");477
assert!(!newer.exists());478
}479
480
#[test]481
fn delete_refuses_paths_outside_parent() {482
let root = tempfile::tempdir().unwrap();483
let bundles = root.path().join(SUPPORT_BUNDLES_DIR);484
let outside = root.path().join("other");485
std::fs::create_dir_all(&bundles).unwrap();486
std::fs::create_dir_all(&outside).unwrap();487
assert!(delete_support_bundle(&outside, Some(&bundles)).is_err());488
assert!(outside.exists());489
}490
}@@ -1,7 +1,7 @@
1
1
mod common_words;
2
2
mod document;
3
3
mod markdown;
4
mod scrub;
4
pub mod scrub;
5
5
mod series;
6
6
mod storage;
7
7
mod web_shadow;
@@ -1,7 +1,7 @@1
mod common_words;1
mod common_words;2
mod document;2
mod document;3
mod markdown;3
mod markdown;4
mod scrub;4
pub mod scrub;5
mod series;5
mod series;6
mod storage;6
mod storage;7
mod web_shadow;7
mod web_shadow;@@ -4,8 +4,6 @@ use std::path::{Path, PathBuf};
4
4
5
5
use super::Document;
6
6
7
#[cfg(not(test))]
8
const REPORT_DIRECTORY: &str = "call-reports";
9
7
const KEEP_REPORTS: usize = 30;
10
8
const JSON_EXTENSION: &str = "json";
11
9
const MARKDOWN_EXTENSION: &str = "md";
@@ -23,9 +21,8 @@ pub fn report_directory() -> PathBuf {
23
21
24
22
#[cfg(not(test))]
25
23
pub fn report_directory() -> PathBuf {
26
directories::ProjectDirs::from("", "", store::DATA_DIR_NAME)
27
.map(|directories| directories.data_local_dir().join(REPORT_DIRECTORY))
28
.unwrap_or_else(|| PathBuf::from(REPORT_DIRECTORY))
24
app_base::support::call_reports_dir()
25
.unwrap_or_else(|| PathBuf::from(app_base::support::CALL_REPORTS_DIR))
29
26
}
30
27
31
28
pub fn save_report(directory: &Path, document: &Document) -> io::Result<SavedReport> {
@@ -4,8 +4,6 @@ use std::path::{Path, PathBuf};4
4
5
use super::Document;5
use super::Document;6
6
7
#[cfg(not(test))]8
const REPORT_DIRECTORY: &str = "call-reports";9
const KEEP_REPORTS: usize = 30;7
const KEEP_REPORTS: usize = 30;10
const JSON_EXTENSION: &str = "json";8
const JSON_EXTENSION: &str = "json";11
const MARKDOWN_EXTENSION: &str = "md";9
const MARKDOWN_EXTENSION: &str = "md";@@ -23,9 +21,8 @@ pub fn report_directory() -> PathBuf {23
21
24
#[cfg(not(test))]22
#[cfg(not(test))]25
pub fn report_directory() -> PathBuf {23
pub fn report_directory() -> PathBuf {26
directories::ProjectDirs::from("", "", store::DATA_DIR_NAME)24
app_base::support::call_reports_dir()27
.map(|directories| directories.data_local_dir().join(REPORT_DIRECTORY))25
.unwrap_or_else(|| PathBuf::from(app_base::support::CALL_REPORTS_DIR))28
.unwrap_or_else(|| PathBuf::from(REPORT_DIRECTORY))29
}26
}30
27
31
pub fn save_report(directory: &Path, document: &Document) -> io::Result<SavedReport> {28
pub fn save_report(directory: &Path, document: &Document) -> io::Result<SavedReport> {@@ -293,6 +293,14 @@ impl AppState {
293
293
conversation_id,
294
294
video,
295
295
));
296
if let Some(call) = self.call.as_ref() {
297
crate::diagnostics::record(format!(
298
"calls: start kind={:?} incoming={} peer_chars={}",
299
call.model.kind,
300
call.model.incoming,
301
call.model.peer_name.chars().count()
302
));
303
}
296
304
if self.call_share_sound {
297
305
self.send_call_command(CallCommand::SetShareSound(true));
298
306
}
@@ -628,6 +636,11 @@ impl AppState {
628
636
return;
629
637
};
630
638
let elapsed = call.model.elapsed(Instant::now());
639
crate::diagnostics::record(format!(
640
"calls: end kind={:?} reason={reason:?} elapsed_ms={}",
641
call.model.kind,
642
elapsed.map(|value| value.as_millis()).unwrap_or(0)
643
));
631
644
let consult = call.consult.take();
632
645
let notice = match &consult {
633
646
Some(consult) if consult.transfer == ConsultTransfer::Done => {
@@ -293,6 +293,14 @@ impl AppState {293
conversation_id,293
conversation_id,294
video,294
video,295
));295
));296
if let Some(call) = self.call.as_ref() {297
crate::diagnostics::record(format!(298
"calls: start kind={:?} incoming={} peer_chars={}",299
call.model.kind,300
call.model.incoming,301
call.model.peer_name.chars().count()302
));303
}296
if self.call_share_sound {304
if self.call_share_sound {297
self.send_call_command(CallCommand::SetShareSound(true));305
self.send_call_command(CallCommand::SetShareSound(true));298
}306
}@@ -628,6 +636,11 @@ impl AppState {628
return;636
return;629
};637
};630
let elapsed = call.model.elapsed(Instant::now());638
let elapsed = call.model.elapsed(Instant::now());639
crate::diagnostics::record(format!(640
"calls: end kind={:?} reason={reason:?} elapsed_ms={}",641
call.model.kind,642
elapsed.map(|value| value.as_millis()).unwrap_or(0)643
));631
let consult = call.consult.take();644
let consult = call.consult.take();632
let notice = match &consult {645
let notice = match &consult {633
Some(consult) if consult.transfer == ConsultTransfer::Done => {646
Some(consult) if consult.transfer == ConsultTransfer::Done => {@@ -23,7 +23,6 @@ const START_RETRY_STEADY: Duration = Duration::from_secs(10);
23
23
pub(super) const NOT_READY: &str =
24
24
"Could not reach the Teams calling service. Check your connection and try again.";
25
25
const READY_WAIT: Duration = Duration::from_secs(30);
26
const CALL_DUMPS_DIR: &str = "call-dumps";
27
26
28
27
pub struct CallLauncher {
29
28
engine: watch::Sender<Option<CallEngine>>,
@@ -368,9 +367,12 @@ async fn start_engine(
368
367
)> {
369
368
let session = Session::with_transport(transport.clone(), SessionConfig::for_app()).await?;
370
369
let poll_session = Session::with_transport(transport, SessionConfig::for_app()).await?;
370
let dump_dir = app_base::diagnostics::is_enabled()
371
.then(|| crate::support::call_dumps_dir())
372
.flatten();
371
373
let config = EngineConfig {
372
374
ringable,
373
dump_dir: crate::diagnostics::directory().map(|directory| directory.join(CALL_DUMPS_DIR)),
375
dump_dir,
374
376
..EngineConfig::default()
375
377
};
376
378
CallEngine::start(session, poll_session, config).await
@@ -23,7 +23,6 @@ const START_RETRY_STEADY: Duration = Duration::from_secs(10);23
pub(super) const NOT_READY: &str =23
pub(super) const NOT_READY: &str =24
"Could not reach the Teams calling service. Check your connection and try again.";24
"Could not reach the Teams calling service. Check your connection and try again.";25
const READY_WAIT: Duration = Duration::from_secs(30);25
const READY_WAIT: Duration = Duration::from_secs(30);26
const CALL_DUMPS_DIR: &str = "call-dumps";27
26
28
pub struct CallLauncher {27
pub struct CallLauncher {29
engine: watch::Sender<Option<CallEngine>>,28
engine: watch::Sender<Option<CallEngine>>,@@ -368,9 +367,12 @@ async fn start_engine(368
)> {367
)> {369
let session = Session::with_transport(transport.clone(), SessionConfig::for_app()).await?;368
let session = Session::with_transport(transport.clone(), SessionConfig::for_app()).await?;370
let poll_session = Session::with_transport(transport, SessionConfig::for_app()).await?;369
let poll_session = Session::with_transport(transport, SessionConfig::for_app()).await?;370
let dump_dir = app_base::diagnostics::is_enabled()371
.then(|| crate::support::call_dumps_dir())372
.flatten();371
let config = EngineConfig {373
let config = EngineConfig {372
ringable,374
ringable,373
dump_dir: crate::diagnostics::directory().map(|directory| directory.join(CALL_DUMPS_DIR)),375
dump_dir,374
..EngineConfig::default()376
..EngineConfig::default()375
};377
};376
CallEngine::start(session, poll_session, config).await378
CallEngine::start(session, poll_session, config).await@@ -60,6 +60,8 @@ mod sidebar_load;
60
60
pub mod sidebar_model;
61
61
pub mod sound_actions;
62
62
pub mod stored_outgoing;
63
pub mod support_actions;
64
pub mod support_bundle;
63
65
pub mod task_dialog;
64
66
pub mod team_admin;
65
67
pub mod translation_actions;
@@ -72,6 +74,6 @@ pub use app_base::{
72
74
demo_chart_cards, demo_gifs, demo_input_cards, demo_library, demo_recap, diagnostics,
73
75
downloads, emoticons, format, frame_log, fuzzy, image_clipboard, image_view_math, inline_image,
74
76
presence_link, read_state, recap, remote_image, runtime, schedule_time, single_instance,
75
stickers, theme, translation, updater, user_activity, zoom,
77
stickers, support, theme, translation, updater, user_activity, zoom,
76
78
};
77
79
pub use app_ui_kit::render;
@@ -60,6 +60,8 @@ mod sidebar_load;60
pub mod sidebar_model;60
pub mod sidebar_model;61
pub mod sound_actions;61
pub mod sound_actions;62
pub mod stored_outgoing;62
pub mod stored_outgoing;63
pub mod support_actions;64
pub mod support_bundle;63
pub mod task_dialog;65
pub mod task_dialog;64
pub mod team_admin;66
pub mod team_admin;65
pub mod translation_actions;67
pub mod translation_actions;@@ -72,6 +74,6 @@ pub use app_base::{72
demo_chart_cards, demo_gifs, demo_input_cards, demo_library, demo_recap, diagnostics,74
demo_chart_cards, demo_gifs, demo_input_cards, demo_library, demo_recap, diagnostics,73
downloads, emoticons, format, frame_log, fuzzy, image_clipboard, image_view_math, inline_image,75
downloads, emoticons, format, frame_log, fuzzy, image_clipboard, image_view_math, inline_image,74
presence_link, read_state, recap, remote_image, runtime, schedule_time, single_instance,76
presence_link, read_state, recap, remote_image, runtime, schedule_time, single_instance,75
stickers, theme, translation, updater, user_activity, zoom,77
stickers, support, theme, translation, updater, user_activity, zoom,76
};78
};77
pub use app_ui_kit::render;79
pub use app_ui_kit::render;@@ -51,6 +51,7 @@ impl AppState {
51
51
action: Option<NoticeAction>,
52
52
cx: &mut Context<Self>,
53
53
) {
54
log::info!("notice: {text}");
54
55
self.notice_count += 1;
55
56
let id = self.notice_count;
56
57
self.notice = Some(Notice { id, text, action });
@@ -51,6 +51,7 @@ impl AppState {51
action: Option<NoticeAction>,51
action: Option<NoticeAction>,52
cx: &mut Context<Self>,52
cx: &mut Context<Self>,53
) {53
) {54
log::info!("notice: {text}");54
self.notice_count += 1;55
self.notice_count += 1;55
let id = self.notice_count;56
let id = self.notice_count;56
self.notice = Some(Notice { id, text, action });57
self.notice = Some(Notice { id, text, action });@@ -13,6 +13,7 @@ pub enum SettingsSection {
13
13
Devices,
14
14
Agents,
15
15
Mcp,
16
Help,
16
17
About,
17
18
}
18
19
@@ -13,6 +13,7 @@ pub enum SettingsSection {13
Devices,13
Devices,14
Agents,14
Agents,15
Mcp,15
Mcp,16
Help,16
About,17
About,17
}18
}18
19
@@ -0,0 +1,105 @@
1
use gpui_kit::Context;
2
3
use crate::app_state::AppState;
4
use crate::notice::NoticeAction;
5
use crate::support::{self, ClientInfo, SupportBundlePaths};
6
use crate::support_bundle::{self, SupportBundle};
7
use calling::DeviceChoice;
8
9
impl AppState {
10
pub fn client_info(&self) -> ClientInfo {
11
let locale = app_base::ui_locale::effective_locale(app_base::ui_locale::load(&self.store));
12
ClientInfo::capture(
13
env!("CARGO_PKG_VERSION"),
14
locale,
15
self.directory.me.is_some(),
16
self.call_report_enabled,
17
device_label(&self.call_input),
18
device_label(&self.call_output),
19
device_label(&self.call_camera),
20
)
21
}
22
23
pub fn create_support_bundle(&self) -> Result<SupportBundle, String> {
24
let data_dir =
25
support::local_data_dir().ok_or_else(|| "data directory unavailable".to_owned())?;
26
support_bundle::write_support_bundle(&data_dir, &self.client_info())
27
.map_err(|error| error.to_string())
28
}
29
30
pub fn github_issue_url_for_bundle(&self, bundle: &SupportBundle) -> String {
31
support::issue_url(
32
&self.client_info(),
33
&SupportBundlePaths {
34
directory: bundle.directory.clone(),
35
folder_name: bundle.folder_name.clone(),
36
},
37
)
38
}
39
40
pub fn reveal_support_bundle(bundle: &SupportBundle) {
41
crate::downloads::reveal_in_file_manager(&bundle.directory);
42
}
43
44
pub fn reveal_logs_folder() {
45
if let Some(directory) = support::local_data_dir().or_else(app_base::diagnostics::directory)
46
{
47
crate::downloads::reveal_in_file_manager(&directory);
48
}
49
}
50
51
pub fn open_github_issue_with_bundle(&mut self, cx: &mut Context<Self>) -> Result<(), String> {
52
let bundle = self.create_support_bundle()?;
53
let url = self.github_issue_url_for_bundle(&bundle);
54
let folder = bundle.directory.clone();
55
crate::external_browser::open_url(cx, &self.store, &url);
56
let action = NoticeAction::new("Open folder", move |_, _| {
57
crate::downloads::reveal_in_file_manager(&folder);
58
});
59
self.raise_notice(
60
format!(
61
"Support package ready: {}. Attach those files to the GitHub issue.",
62
bundle.folder_name
63
),
64
Some(action),
65
cx,
66
);
67
Ok(())
68
}
69
70
pub fn diagnostics_enabled(&self) -> bool {
71
app_base::diagnostics::is_enabled()
72
}
73
74
pub fn set_diagnostics_enabled(&mut self, on: bool, cx: &mut Context<Self>) {
75
app_base::diagnostics::set_enabled(on);
76
let _ = self.store.set_meta(
77
app_base::diagnostics::DIAGNOSTICS_SETTING_KEY,
78
if on { "1" } else { "0" },
79
);
80
if on {
81
app_base::support::record_startup_client_line(
82
env!("CARGO_PKG_VERSION"),
83
app_base::ui_locale::effective_locale(app_base::ui_locale::load(&self.store)),
84
self.directory.me.is_some(),
85
self.call_report_enabled,
86
);
87
}
88
cx.notify();
89
}
90
91
pub fn clear_diagnostic_logs(&mut self, cx: &mut Context<Self>) {
92
if let Err(error) = app_base::diagnostics::clear_logs() {
93
app_base::diagnostics::record(format!("clear logs: {error}"));
94
}
95
cx.notify();
96
}
97
}
98
99
fn device_label(choice: &DeviceChoice) -> String {
100
match choice {
101
DeviceChoice::SystemDefault => "default".to_owned(),
102
DeviceChoice::Device(key) if key.is_empty() => "none".to_owned(),
103
DeviceChoice::Device(_) => "selected".to_owned(),
104
}
105
}
@@ -0,0 +1,105 @@1
use gpui_kit::Context;2
3
use crate::app_state::AppState;4
use crate::notice::NoticeAction;5
use crate::support::{self, ClientInfo, SupportBundlePaths};6
use crate::support_bundle::{self, SupportBundle};7
use calling::DeviceChoice;8
9
impl AppState {10
pub fn client_info(&self) -> ClientInfo {11
let locale = app_base::ui_locale::effective_locale(app_base::ui_locale::load(&self.store));12
ClientInfo::capture(13
env!("CARGO_PKG_VERSION"),14
locale,15
self.directory.me.is_some(),16
self.call_report_enabled,17
device_label(&self.call_input),18
device_label(&self.call_output),19
device_label(&self.call_camera),20
)21
}22
23
pub fn create_support_bundle(&self) -> Result<SupportBundle, String> {24
let data_dir =25
support::local_data_dir().ok_or_else(|| "data directory unavailable".to_owned())?;26
support_bundle::write_support_bundle(&data_dir, &self.client_info())27
.map_err(|error| error.to_string())28
}29
30
pub fn github_issue_url_for_bundle(&self, bundle: &SupportBundle) -> String {31
support::issue_url(32
&self.client_info(),33
&SupportBundlePaths {34
directory: bundle.directory.clone(),35
folder_name: bundle.folder_name.clone(),36
},37
)38
}39
40
pub fn reveal_support_bundle(bundle: &SupportBundle) {41
crate::downloads::reveal_in_file_manager(&bundle.directory);42
}43
44
pub fn reveal_logs_folder() {45
if let Some(directory) = support::local_data_dir().or_else(app_base::diagnostics::directory)46
{47
crate::downloads::reveal_in_file_manager(&directory);48
}49
}50
51
pub fn open_github_issue_with_bundle(&mut self, cx: &mut Context<Self>) -> Result<(), String> {52
let bundle = self.create_support_bundle()?;53
let url = self.github_issue_url_for_bundle(&bundle);54
let folder = bundle.directory.clone();55
crate::external_browser::open_url(cx, &self.store, &url);56
let action = NoticeAction::new("Open folder", move |_, _| {57
crate::downloads::reveal_in_file_manager(&folder);58
});59
self.raise_notice(60
format!(61
"Support package ready: {}. Attach those files to the GitHub issue.",62
bundle.folder_name63
),64
Some(action),65
cx,66
);67
Ok(())68
}69
70
pub fn diagnostics_enabled(&self) -> bool {71
app_base::diagnostics::is_enabled()72
}73
74
pub fn set_diagnostics_enabled(&mut self, on: bool, cx: &mut Context<Self>) {75
app_base::diagnostics::set_enabled(on);76
let _ = self.store.set_meta(77
app_base::diagnostics::DIAGNOSTICS_SETTING_KEY,78
if on { "1" } else { "0" },79
);80
if on {81
app_base::support::record_startup_client_line(82
env!("CARGO_PKG_VERSION"),83
app_base::ui_locale::effective_locale(app_base::ui_locale::load(&self.store)),84
self.directory.me.is_some(),85
self.call_report_enabled,86
);87
}88
cx.notify();89
}90
91
pub fn clear_diagnostic_logs(&mut self, cx: &mut Context<Self>) {92
if let Err(error) = app_base::diagnostics::clear_logs() {93
app_base::diagnostics::record(format!("clear logs: {error}"));94
}95
cx.notify();96
}97
}98
99
fn device_label(choice: &DeviceChoice) -> String {100
match choice {101
DeviceChoice::SystemDefault => "default".to_owned(),102
DeviceChoice::Device(key) if key.is_empty() => "none".to_owned(),103
DeviceChoice::Device(_) => "selected".to_owned(),104
}105
}@@ -0,0 +1,189 @@
1
use std::fs;
2
use std::io;
3
use std::path::{Path, PathBuf};
4
5
use app_base::support::{self, ClientInfo};
6
use app_call_model::report::report_directory;
7
use app_call_model::report::scrub::Scrubber;
8
use chrono::Utc;
9
10
const KEEP_CALL_REPORTS: usize = 3;
11
const DIAGNOSTICS_NAME: &str = "diagnostics.log";
12
const CRASH_NAME: &str = "crash.log";
13
const TIMELINE_NAME: &str = "last-call-timeline.log";
14
const DIAGNOSTICS_MERGE_CAP: u64 = 1024 * 1024;
15
const CRASH_MERGE_CAP: u64 = 128 * 1024;
16
17
#[derive(Debug, Clone, PartialEq, Eq)]
18
pub struct SupportBundle {
19
pub directory: PathBuf,
20
pub folder_name: String,
21
}
22
23
pub fn write_support_bundle(data_dir: &Path, client: &ClientInfo) -> io::Result<SupportBundle> {
24
write_support_bundle_from(data_dir, client, &report_directory())
25
}
26
27
fn write_support_bundle_from(
28
data_dir: &Path,
29
client: &ClientInfo,
30
call_reports: &Path,
31
) -> io::Result<SupportBundle> {
32
let folder_name = support::bundle_folder_name(Utc::now());
33
let directory = support::support_bundles_directory(data_dir).join(&folder_name);
34
fs::create_dir_all(&directory)?;
35
fs::write(directory.join("client.md"), client.markdown())?;
36
fs::write(directory.join("README.md"), support::readme_text())?;
37
write_scrubbed_text(
38
&app_base::diagnostics::read_merged(DIAGNOSTICS_MERGE_CAP),
39
&directory.join(DIAGNOSTICS_NAME),
40
)?;
41
write_scrubbed_text(
42
&app_base::crash_log::read_merged(CRASH_MERGE_CAP),
43
&directory.join(CRASH_NAME),
44
)?;
45
copy_recent_call_reports(&directory, call_reports)?;
46
copy_latest_call_timeline(&directory)?;
47
Ok(SupportBundle {
48
directory,
49
folder_name,
50
})
51
}
52
53
fn write_scrubbed_text(raw: &str, destination: &Path) -> io::Result<()> {
54
if raw.trim().is_empty() {
55
return Ok(());
56
}
57
let mut scrubber = Scrubber::default();
58
let scrubbed = scrubber.scrub(raw);
59
fs::write(destination, scrubbed)
60
}
61
62
fn copy_recent_call_reports(bundle: &Path, reports: &Path) -> io::Result<()> {
63
if !reports.is_dir() {
64
return Ok(());
65
}
66
let mut markdown: Vec<PathBuf> = fs::read_dir(reports)?
67
.filter_map(Result::ok)
68
.map(|entry| entry.path())
69
.filter(|path| path.extension().is_some_and(|ext| ext == "md"))
70
.collect();
71
markdown.sort();
72
let start = markdown.len().saturating_sub(KEEP_CALL_REPORTS);
73
for path in &markdown[start..] {
74
let Some(name) = path.file_name() else {
75
continue;
76
};
77
fs::copy(path, bundle.join(name))?;
78
let json = path.with_extension("json");
79
if json.is_file() {
80
if let Some(json_name) = json.file_name() {
81
fs::copy(&json, bundle.join(json_name))?;
82
}
83
}
84
}
85
Ok(())
86
}
87
88
fn copy_latest_call_timeline(bundle: &Path) -> io::Result<()> {
89
let Some(dumps) = support::call_dumps_dir() else {
90
return Ok(());
91
};
92
if !dumps.is_dir() {
93
return Ok(());
94
}
95
let mut dirs: Vec<PathBuf> = fs::read_dir(&dumps)?
96
.filter_map(Result::ok)
97
.map(|entry| entry.path())
98
.filter(|path| path.is_dir())
99
.collect();
100
dirs.sort();
101
let Some(latest) = dirs.last() else {
102
return Ok(());
103
};
104
let timeline = latest.join("timeline.txt");
105
if !timeline.is_file() {
106
return Ok(());
107
}
108
let raw = fs::read_to_string(timeline)?;
109
write_scrubbed_text(&raw, &bundle.join(TIMELINE_NAME))
110
}
111
112
#[cfg(test)]
113
mod tests {
114
use super::*;
115
use tempfile::tempdir;
116
117
fn sample_client() -> ClientInfo {
118
ClientInfo {
119
version: "0.1.0".into(),
120
build: "test".into(),
121
os: "linux".into(),
122
arch: "x86_64".into(),
123
session: "wayland".into(),
124
ui_locale: "en".into(),
125
timezone: "UTC+0".into(),
126
signed_in: true,
127
call_reports: true,
128
debug_logging: true,
129
audio_input: "Default device".into(),
130
audio_output: "Default device".into(),
131
camera: "none".into(),
132
logs_root: "/tmp/data".into(),
133
support_bundles_root: "/tmp/data/support-bundles".into(),
134
}
135
}
136
137
#[test]
138
fn support_bundle_scrubs_secrets_and_skips_store() {
139
let root = tempdir().unwrap();
140
let data = root.path().join("data");
141
fs::create_dir_all(&data).unwrap();
142
let diagnostics = data.join(DIAGNOSTICS_NAME);
143
fs::write(
144
&diagnostics,
145
"ok line\nbearer eyJhbGciOiJIUzI1NiJ9.aaa.bbb\nemail user@example.com\n",
146
)
147
.unwrap();
148
fs::write(data.join("store.db"), "secret-store").unwrap();
149
150
app_base::diagnostics::install(diagnostics.clone());
151
app_base::diagnostics::set_enabled(true);
152
if let Some(live) = app_base::diagnostics::path() {
153
let _ = fs::write(
154
&live,
155
"ok line\nbearer eyJhbGciOiJIUzI1NiJ9.aaa.bbb\nemail user@example.com\n",
156
);
157
}
158
159
let reports = root.path().join("call-reports");
160
fs::create_dir_all(&reports).unwrap();
161
let bundle = write_support_bundle_from(&data, &sample_client(), &reports).unwrap();
162
let client = fs::read_to_string(bundle.directory.join("client.md")).unwrap();
163
assert!(client.contains("### Client"));
164
assert!(client.contains("Debug logging:"));
165
let log_path = bundle.directory.join(DIAGNOSTICS_NAME);
166
if log_path.is_file() {
167
let log = fs::read_to_string(&log_path).unwrap();
168
assert!(!log.contains("eyJhbGciOiJIUzI1NiJ9"));
169
assert!(!log.contains("user@example.com"));
170
}
171
assert!(!bundle.directory.join("store.db").exists());
172
assert!(bundle.directory.join("README.md").is_file());
173
}
174
175
#[test]
176
fn support_bundle_copies_matching_call_report_json() {
177
let root = tempdir().unwrap();
178
let data = root.path().join("data");
179
fs::create_dir_all(&data).unwrap();
180
let reports = root.path().join("call-reports");
181
fs::create_dir_all(&reports).unwrap();
182
fs::write(reports.join("20260101T000000Z-echo.md"), "# report\n").unwrap();
183
fs::write(reports.join("20260101T000000Z-echo.json"), "{\"schema\":1}\n").unwrap();
184
185
let bundle = write_support_bundle_from(&data, &sample_client(), &reports).unwrap();
186
assert!(bundle.directory.join("20260101T000000Z-echo.md").is_file());
187
assert!(bundle.directory.join("20260101T000000Z-echo.json").is_file());
188
}
189
}
@@ -0,0 +1,189 @@1
use std::fs;2
use std::io;3
use std::path::{Path, PathBuf};4
5
use app_base::support::{self, ClientInfo};6
use app_call_model::report::report_directory;7
use app_call_model::report::scrub::Scrubber;8
use chrono::Utc;9
10
const KEEP_CALL_REPORTS: usize = 3;11
const DIAGNOSTICS_NAME: &str = "diagnostics.log";12
const CRASH_NAME: &str = "crash.log";13
const TIMELINE_NAME: &str = "last-call-timeline.log";14
const DIAGNOSTICS_MERGE_CAP: u64 = 1024 * 1024;15
const CRASH_MERGE_CAP: u64 = 128 * 1024;16
17
#[derive(Debug, Clone, PartialEq, Eq)]18
pub struct SupportBundle {19
pub directory: PathBuf,20
pub folder_name: String,21
}22
23
pub fn write_support_bundle(data_dir: &Path, client: &ClientInfo) -> io::Result<SupportBundle> {24
write_support_bundle_from(data_dir, client, &report_directory())25
}26
27
fn write_support_bundle_from(28
data_dir: &Path,29
client: &ClientInfo,30
call_reports: &Path,31
) -> io::Result<SupportBundle> {32
let folder_name = support::bundle_folder_name(Utc::now());33
let directory = support::support_bundles_directory(data_dir).join(&folder_name);34
fs::create_dir_all(&directory)?;35
fs::write(directory.join("client.md"), client.markdown())?;36
fs::write(directory.join("README.md"), support::readme_text())?;37
write_scrubbed_text(38
&app_base::diagnostics::read_merged(DIAGNOSTICS_MERGE_CAP),39
&directory.join(DIAGNOSTICS_NAME),40
)?;41
write_scrubbed_text(42
&app_base::crash_log::read_merged(CRASH_MERGE_CAP),43
&directory.join(CRASH_NAME),44
)?;45
copy_recent_call_reports(&directory, call_reports)?;46
copy_latest_call_timeline(&directory)?;47
Ok(SupportBundle {48
directory,49
folder_name,50
})51
}52
53
fn write_scrubbed_text(raw: &str, destination: &Path) -> io::Result<()> {54
if raw.trim().is_empty() {55
return Ok(());56
}57
let mut scrubber = Scrubber::default();58
let scrubbed = scrubber.scrub(raw);59
fs::write(destination, scrubbed)60
}61
62
fn copy_recent_call_reports(bundle: &Path, reports: &Path) -> io::Result<()> {63
if !reports.is_dir() {64
return Ok(());65
}66
let mut markdown: Vec<PathBuf> = fs::read_dir(reports)?67
.filter_map(Result::ok)68
.map(|entry| entry.path())69
.filter(|path| path.extension().is_some_and(|ext| ext == "md"))70
.collect();71
markdown.sort();72
let start = markdown.len().saturating_sub(KEEP_CALL_REPORTS);73
for path in &markdown[start..] {74
let Some(name) = path.file_name() else {75
continue;76
};77
fs::copy(path, bundle.join(name))?;78
let json = path.with_extension("json");79
if json.is_file() {80
if let Some(json_name) = json.file_name() {81
fs::copy(&json, bundle.join(json_name))?;82
}83
}84
}85
Ok(())86
}87
88
fn copy_latest_call_timeline(bundle: &Path) -> io::Result<()> {89
let Some(dumps) = support::call_dumps_dir() else {90
return Ok(());91
};92
if !dumps.is_dir() {93
return Ok(());94
}95
let mut dirs: Vec<PathBuf> = fs::read_dir(&dumps)?96
.filter_map(Result::ok)97
.map(|entry| entry.path())98
.filter(|path| path.is_dir())99
.collect();100
dirs.sort();101
let Some(latest) = dirs.last() else {102
return Ok(());103
};104
let timeline = latest.join("timeline.txt");105
if !timeline.is_file() {106
return Ok(());107
}108
let raw = fs::read_to_string(timeline)?;109
write_scrubbed_text(&raw, &bundle.join(TIMELINE_NAME))110
}111
112
#[cfg(test)]113
mod tests {114
use super::*;115
use tempfile::tempdir;116
117
fn sample_client() -> ClientInfo {118
ClientInfo {119
version: "0.1.0".into(),120
build: "test".into(),121
os: "linux".into(),122
arch: "x86_64".into(),123
session: "wayland".into(),124
ui_locale: "en".into(),125
timezone: "UTC+0".into(),126
signed_in: true,127
call_reports: true,128
debug_logging: true,129
audio_input: "Default device".into(),130
audio_output: "Default device".into(),131
camera: "none".into(),132
logs_root: "/tmp/data".into(),133
support_bundles_root: "/tmp/data/support-bundles".into(),134
}135
}136
137
#[test]138
fn support_bundle_scrubs_secrets_and_skips_store() {139
let root = tempdir().unwrap();140
let data = root.path().join("data");141
fs::create_dir_all(&data).unwrap();142
let diagnostics = data.join(DIAGNOSTICS_NAME);143
fs::write(144
&diagnostics,145
"ok line\nbearer eyJhbGciOiJIUzI1NiJ9.aaa.bbb\nemail user@example.com\n",146
)147
.unwrap();148
fs::write(data.join("store.db"), "secret-store").unwrap();149
150
app_base::diagnostics::install(diagnostics.clone());151
app_base::diagnostics::set_enabled(true);152
if let Some(live) = app_base::diagnostics::path() {153
let _ = fs::write(154
&live,155
"ok line\nbearer eyJhbGciOiJIUzI1NiJ9.aaa.bbb\nemail user@example.com\n",156
);157
}158
159
let reports = root.path().join("call-reports");160
fs::create_dir_all(&reports).unwrap();161
let bundle = write_support_bundle_from(&data, &sample_client(), &reports).unwrap();162
let client = fs::read_to_string(bundle.directory.join("client.md")).unwrap();163
assert!(client.contains("### Client"));164
assert!(client.contains("Debug logging:"));165
let log_path = bundle.directory.join(DIAGNOSTICS_NAME);166
if log_path.is_file() {167
let log = fs::read_to_string(&log_path).unwrap();168
assert!(!log.contains("eyJhbGciOiJIUzI1NiJ9"));169
assert!(!log.contains("user@example.com"));170
}171
assert!(!bundle.directory.join("store.db").exists());172
assert!(bundle.directory.join("README.md").is_file());173
}174
175
#[test]176
fn support_bundle_copies_matching_call_report_json() {177
let root = tempdir().unwrap();178
let data = root.path().join("data");179
fs::create_dir_all(&data).unwrap();180
let reports = root.path().join("call-reports");181
fs::create_dir_all(&reports).unwrap();182
fs::write(reports.join("20260101T000000Z-echo.md"), "# report\n").unwrap();183
fs::write(reports.join("20260101T000000Z-echo.json"), "{\"schema\":1}\n").unwrap();184
185
let bundle = write_support_bundle_from(&data, &sample_client(), &reports).unwrap();186
assert!(bundle.directory.join("20260101T000000Z-echo.md").is_file());187
assert!(bundle.directory.join("20260101T000000Z-echo.json").is_file());188
}189
}@@ -5,5 +5,7 @@ pub mod hooks;
5
5
mod selectable;
6
6
mod syntax;
7
7
8
pub use blocks::{Block, TableCell, layout_blocks, layout_card_blocks, table_images};
8
pub use blocks::{
9
Block, TableCell, layout_blocks, layout_card_blocks, strip_image_placeholders, table_images,
10
};
9
11
pub use elements::{CODE_BLOCK_TAG, CODE_LINE_TAG, render_blocks, render_table};
@@ -5,5 +5,7 @@ pub mod hooks;5
mod selectable;5
mod selectable;6
mod syntax;6
mod syntax;7
7
8
pub use blocks::{Block, TableCell, layout_blocks, layout_card_blocks, table_images};8
pub use blocks::{9
Block, TableCell, layout_blocks, layout_card_blocks, strip_image_placeholders, table_images,10
};9
pub use elements::{CODE_BLOCK_TAG, CODE_LINE_TAG, render_blocks, render_table};11
pub use elements::{CODE_BLOCK_TAG, CODE_LINE_TAG, render_blocks, render_table};@@ -71,6 +71,28 @@ mod tests {
71
71
);
72
72
}
73
73
74
#[test]
75
fn ui_locale_settings_help_keys() {
76
let _guard = locale_test_lock();
77
apply_locale("en");
78
assert_eq!(tr("settings.nav.help"), "Help");
79
assert_eq!(tr("settings.help.create_bundle_button"), "Create");
80
assert_eq!(tr("settings.help.logs_path"), "Logs root");
81
assert_eq!(tr("settings.help.bundles_path"), "Support packages");
82
assert_eq!(tr("settings.help.packages_empty"), "No support packages yet");
83
assert_eq!(tr("settings.help.copy_path_tooltip"), "Copy path");
84
assert_eq!(tr("settings.help.debug_logging"), "Debug logging");
85
apply_locale("de");
86
assert_eq!(tr("settings.nav.help"), "Hilfe");
87
assert_eq!(tr("settings.help.create_bundle_button"), "Erstellen");
88
assert_eq!(tr("settings.help.logs_path"), "Log-Root");
89
assert_eq!(tr("settings.help.bundles_path"), "Support-Pakete");
90
assert_eq!(tr("settings.help.packages_empty"), "Noch keine Support-Pakete");
91
assert_eq!(tr("settings.help.copy_path_tooltip"), "Pfad kopieren");
92
assert_eq!(tr("settings.help.debug_logging"), "Debug-Protokollierung");
93
assert!(tr("settings.help.detail").contains("Support-Paket"));
94
}
95
74
96
#[test]
75
97
fn ui_locale_auth_splash_keys() {
76
98
let _guard = locale_test_lock();
@@ -71,6 +71,28 @@ mod tests {71
);71
);72
}72
}73
73
74
#[test]75
fn ui_locale_settings_help_keys() {76
let _guard = locale_test_lock();77
apply_locale("en");78
assert_eq!(tr("settings.nav.help"), "Help");79
assert_eq!(tr("settings.help.create_bundle_button"), "Create");80
assert_eq!(tr("settings.help.logs_path"), "Logs root");81
assert_eq!(tr("settings.help.bundles_path"), "Support packages");82
assert_eq!(tr("settings.help.packages_empty"), "No support packages yet");83
assert_eq!(tr("settings.help.copy_path_tooltip"), "Copy path");84
assert_eq!(tr("settings.help.debug_logging"), "Debug logging");85
apply_locale("de");86
assert_eq!(tr("settings.nav.help"), "Hilfe");87
assert_eq!(tr("settings.help.create_bundle_button"), "Erstellen");88
assert_eq!(tr("settings.help.logs_path"), "Log-Root");89
assert_eq!(tr("settings.help.bundles_path"), "Support-Pakete");90
assert_eq!(tr("settings.help.packages_empty"), "Noch keine Support-Pakete");91
assert_eq!(tr("settings.help.copy_path_tooltip"), "Pfad kopieren");92
assert_eq!(tr("settings.help.debug_logging"), "Debug-Protokollierung");93
assert!(tr("settings.help.detail").contains("Support-Paket"));94
}95
74
#[test]96
#[test]75
fn ui_locale_auth_splash_keys() {97
fn ui_locale_auth_splash_keys() {76
let _guard = locale_test_lock();98
let _guard = locale_test_lock();@@ -322,6 +322,7 @@ mod frames {
322
322
const SETTINGS_TAGS: &[&str] = &[
323
323
"settings",
324
324
"settings/nav",
325
"settings/nav/help",
325
326
"settings/nav/about",
326
327
"settings/main",
327
328
"settings/main/header",
@@ -330,6 +331,7 @@ mod frames {
330
331
];
331
332
const SETTINGS_BODY: &str = "settings/main/body";
332
333
const SETTINGS_NAV: &str = "settings/nav";
334
const SETTINGS_NAV_HELP: &str = "settings/nav/help";
333
335
const SETTINGS_NAV_ABOUT: &str = "settings/nav/about";
334
336
const NAV_LABEL_SIZE: f32 = 14.;
335
337
const NAV_LINE_HEIGHT: f32 = 20.;
@@ -348,6 +350,11 @@ mod frames {
348
350
content: "settings/nav/about",
349
351
edges: &[Edge::Left, Edge::Right, Edge::Bottom],
350
352
},
353
InsetRule {
354
panel: "settings/nav",
355
content: "settings/nav/help",
356
edges: &[Edge::Left, Edge::Right],
357
},
351
358
InsetRule {
352
359
panel: "settings/main",
353
360
content: "settings/main/header/close",
@@ -363,7 +370,7 @@ mod frames {
363
370
SettingsSection::Agents,
364
371
"Agents pages carry their own PAGE_PADDING side inset, the body narrows its side padding to keep the text edge",
365
372
)];
366
const SETTINGS_SECTIONS: [SettingsSection; 10] = [
373
const SETTINGS_SECTIONS: [SettingsSection; 11] = [
367
374
SettingsSection::General,
368
375
SettingsSection::Notifications,
369
376
SettingsSection::Appearance,
@@ -373,6 +380,7 @@ mod frames {
373
380
SettingsSection::Devices,
374
381
SettingsSection::Agents,
375
382
SettingsSection::Mcp,
383
SettingsSection::Help,
376
384
SettingsSection::About,
377
385
];
378
386
const SIZES: [(f32, f32); 3] = [(640., 480.), (1280., 800.), (1920., 1080.)];
@@ -1622,6 +1630,8 @@ mod frames {
1622
1630
let label_path: &'static str = Box::leak(label_selector(section).into_boxed_str());
1623
1631
let item_path: &'static str = if section == SettingsSection::About {
1624
1632
SETTINGS_NAV_ABOUT
1633
} else if section == SettingsSection::Help {
1634
SETTINGS_NAV_HELP
1625
1635
} else {
1626
1636
Box::leak(item_selector(section).into_boxed_str())
1627
1637
};
@@ -322,6 +322,7 @@ mod frames {322
const SETTINGS_TAGS: &[&str] = &[322
const SETTINGS_TAGS: &[&str] = &[323
"settings",323
"settings",324
"settings/nav",324
"settings/nav",325
"settings/nav/help",325
"settings/nav/about",326
"settings/nav/about",326
"settings/main",327
"settings/main",327
"settings/main/header",328
"settings/main/header",@@ -330,6 +331,7 @@ mod frames {330
];331
];331
const SETTINGS_BODY: &str = "settings/main/body";332
const SETTINGS_BODY: &str = "settings/main/body";332
const SETTINGS_NAV: &str = "settings/nav";333
const SETTINGS_NAV: &str = "settings/nav";334
const SETTINGS_NAV_HELP: &str = "settings/nav/help";333
const SETTINGS_NAV_ABOUT: &str = "settings/nav/about";335
const SETTINGS_NAV_ABOUT: &str = "settings/nav/about";334
const NAV_LABEL_SIZE: f32 = 14.;336
const NAV_LABEL_SIZE: f32 = 14.;335
const NAV_LINE_HEIGHT: f32 = 20.;337
const NAV_LINE_HEIGHT: f32 = 20.;@@ -348,6 +350,11 @@ mod frames {348
content: "settings/nav/about",350
content: "settings/nav/about",349
edges: &[Edge::Left, Edge::Right, Edge::Bottom],351
edges: &[Edge::Left, Edge::Right, Edge::Bottom],350
},352
},353
InsetRule {354
panel: "settings/nav",355
content: "settings/nav/help",356
edges: &[Edge::Left, Edge::Right],357
},351
InsetRule {358
InsetRule {352
panel: "settings/main",359
panel: "settings/main",353
content: "settings/main/header/close",360
content: "settings/main/header/close",@@ -363,7 +370,7 @@ mod frames {363
SettingsSection::Agents,370
SettingsSection::Agents,364
"Agents pages carry their own PAGE_PADDING side inset, the body narrows its side padding to keep the text edge",371
"Agents pages carry their own PAGE_PADDING side inset, the body narrows its side padding to keep the text edge",365
)];372
)];366
const SETTINGS_SECTIONS: [SettingsSection; 10] = [373
const SETTINGS_SECTIONS: [SettingsSection; 11] = [367
SettingsSection::General,374
SettingsSection::General,368
SettingsSection::Notifications,375
SettingsSection::Notifications,369
SettingsSection::Appearance,376
SettingsSection::Appearance,@@ -373,6 +380,7 @@ mod frames {373
SettingsSection::Devices,380
SettingsSection::Devices,374
SettingsSection::Agents,381
SettingsSection::Agents,375
SettingsSection::Mcp,382
SettingsSection::Mcp,383
SettingsSection::Help,376
SettingsSection::About,384
SettingsSection::About,377
];385
];378
const SIZES: [(f32, f32); 3] = [(640., 480.), (1280., 800.), (1920., 1080.)];386
const SIZES: [(f32, f32); 3] = [(640., 480.), (1280., 800.), (1920., 1080.)];@@ -1622,6 +1630,8 @@ mod frames {1622
let label_path: &'static str = Box::leak(label_selector(section).into_boxed_str());1630
let label_path: &'static str = Box::leak(label_selector(section).into_boxed_str());1623
let item_path: &'static str = if section == SettingsSection::About {1631
let item_path: &'static str = if section == SettingsSection::About {1624
SETTINGS_NAV_ABOUT1632
SETTINGS_NAV_ABOUT1633
} else if section == SettingsSection::Help {1634
SETTINGS_NAV_HELP1625
} else {1635
} else {1626
Box::leak(item_selector(section).into_boxed_str())1636
Box::leak(item_selector(section).into_boxed_str())1627
};1637
};@@ -190,12 +190,18 @@ fn main() {
190
190
if let Some(tag) = option_env!("TEAMS_RELEASE_TAG") {
191
191
app_base::version::set_release_tag(tag);
192
192
}
193
crash_log::install(data_path(crash_log::CRASH_LOG_FILE));
193
crash_log::install(
194
app_base::support::crash_log_path().unwrap_or_else(|| data_path(crash_log::CRASH_LOG_FILE)),
195
);
194
196
app_base::native_dumps::install(
195
197
data_path("native-dumps"),
196
data_path(crash_log::CRASH_LOG_FILE),
198
app_base::support::crash_log_path().unwrap_or_else(|| data_path(crash_log::CRASH_LOG_FILE)),
199
);
200
diagnostics::install(
201
app_base::support::diagnostics_log_path()
202
.unwrap_or_else(|| data_path(diagnostics::DIAGNOSTICS_FILE)),
197
203
);
198
diagnostics::install(data_path(diagnostics::DIAGNOSTICS_FILE));
204
let _ = diagnostics::enable_from_override();
199
205
#[cfg(target_os = "linux")]
200
206
app_base::linux_fonts::hide_system_color_emoji();
201
207
let arguments = parse_arguments();
@@ -239,9 +245,20 @@ fn main() {
239
245
open_store(&path)
240
246
};
241
247
let store = Arc::new(store);
242
app_base::ui_locale::apply_locale(app_base::ui_locale::effective_locale(
243
app_base::ui_locale::load(&store),
244
));
248
let stored_diag = store
249
.meta(diagnostics::DIAGNOSTICS_SETTING_KEY)
250
.ok()
251
.flatten();
252
diagnostics::load_enabled_from_store(stored_diag.as_deref());
253
let ui_locale = app_base::ui_locale::effective_locale(app_base::ui_locale::load(&store));
254
app_base::ui_locale::apply_locale(ui_locale);
255
let call_reports = app_call_model::report::load_enabled(&store);
256
app_base::support::record_startup_client_line(
257
env!("CARGO_PKG_VERSION"),
258
ui_locale,
259
crate::data::me(&store).is_some(),
260
call_reports,
261
);
245
262
#[cfg(windows)]
246
263
let sign_in_title = format!(
247
264
"{} - {}",
@@ -190,12 +190,18 @@ fn main() {190
if let Some(tag) = option_env!("TEAMS_RELEASE_TAG") {190
if let Some(tag) = option_env!("TEAMS_RELEASE_TAG") {191
app_base::version::set_release_tag(tag);191
app_base::version::set_release_tag(tag);192
}192
}193
crash_log::install(data_path(crash_log::CRASH_LOG_FILE));193
crash_log::install(194
app_base::support::crash_log_path().unwrap_or_else(|| data_path(crash_log::CRASH_LOG_FILE)),195
);194
app_base::native_dumps::install(196
app_base::native_dumps::install(195
data_path("native-dumps"),197
data_path("native-dumps"),196
data_path(crash_log::CRASH_LOG_FILE),198
app_base::support::crash_log_path().unwrap_or_else(|| data_path(crash_log::CRASH_LOG_FILE)),199
);200
diagnostics::install(201
app_base::support::diagnostics_log_path()202
.unwrap_or_else(|| data_path(diagnostics::DIAGNOSTICS_FILE)),197
);203
);198
diagnostics::install(data_path(diagnostics::DIAGNOSTICS_FILE));204
let _ = diagnostics::enable_from_override();199
#[cfg(target_os = "linux")]205
#[cfg(target_os = "linux")]200
app_base::linux_fonts::hide_system_color_emoji();206
app_base::linux_fonts::hide_system_color_emoji();201
let arguments = parse_arguments();207
let arguments = parse_arguments();@@ -239,9 +245,20 @@ fn main() {239
open_store(&path)245
open_store(&path)240
};246
};241
let store = Arc::new(store);247
let store = Arc::new(store);242
app_base::ui_locale::apply_locale(app_base::ui_locale::effective_locale(248
let stored_diag = store243
app_base::ui_locale::load(&store),249
.meta(diagnostics::DIAGNOSTICS_SETTING_KEY)244
));250
.ok()251
.flatten();252
diagnostics::load_enabled_from_store(stored_diag.as_deref());253
let ui_locale = app_base::ui_locale::effective_locale(app_base::ui_locale::load(&store));254
app_base::ui_locale::apply_locale(ui_locale);255
let call_reports = app_call_model::report::load_enabled(&store);256
app_base::support::record_startup_client_line(257
env!("CARGO_PKG_VERSION"),258
ui_locale,259
crate::data::me(&store).is_some(),260
call_reports,261
);245
#[cfg(windows)]262
#[cfg(windows)]246
let sign_in_title = format!(263
let sign_in_title = format!(247
"{} - {}",264
"{} - {}",@@ -3,9 +3,11 @@ use gpui_kit::assets::IconName;
3
3
use gpui_kit::component::input::{Input, InputEvent, InputState};
4
4
use gpui_kit::component::scroll::ScrollableElement as _;
5
5
use gpui_kit::component::{h_flex, v_flex};
6
use gpui_kit::prelude::FluentBuilder as _;
6
7
use gpui_kit::*;
7
8
8
9
use super::devices::DevicesView;
10
use super::help::HelpView;
9
11
use super::mcp::McpView;
10
12
use super::nav::{NavLayout, NavSearch, first_match, label, matches, render_nav};
11
13
use super::rows::ROW_INSET;
@@ -63,6 +65,7 @@ pub struct SettingsDialog {
63
65
center: Entity<NotificationCenter>,
64
66
section: SettingsSection,
65
67
devices: Option<Entity<DevicesView>>,
68
help: Option<Entity<HelpView>>,
66
69
mcp: Option<Entity<McpView>>,
67
70
agents: Option<Entity<AgentsSettings>>,
68
71
body_scroll: ScrollHandle,
@@ -102,6 +105,7 @@ impl SettingsDialog {
102
105
center,
103
106
section,
104
107
devices: None,
108
help: None,
105
109
mcp: None,
106
110
agents: None,
107
111
body_scroll: ScrollHandle::new(),
@@ -127,6 +131,19 @@ impl SettingsDialog {
127
131
} else {
128
132
self.devices = None;
129
133
}
134
if section == SettingsSection::Help {
135
if self.help.is_none() {
136
let app = self.app.clone();
137
self.help = Some(cx.new(|cx| HelpView::new(app, cx)));
138
} else if let Some(help) = self.help.as_ref() {
139
help.update(cx, |view, cx| {
140
view.reload_bundles();
141
cx.notify();
142
});
143
}
144
} else {
145
self.help = None;
146
}
130
147
if section == SettingsSection::Mcp && self.mcp.is_none() {
131
148
let app = self.app.clone();
132
149
self.mcp = Some(cx.new(|cx| McpView::new(app, window, cx)));
@@ -199,6 +216,10 @@ impl SettingsDialog {
199
216
.mcp
200
217
.clone()
201
218
.map_or_else(|| div().into_any_element(), |view| view.into_any_element()),
219
SettingsSection::Help => self
220
.help
221
.clone()
222
.map_or_else(|| div().into_any_element(), |view| view.into_any_element()),
202
223
SettingsSection::About => about::render().into_any_element(),
203
224
}
204
225
}
@@ -268,25 +289,46 @@ impl Render for SettingsDialog {
268
289
} else {
269
290
metrics.padding
270
291
};
271
let scroll_area = div()
272
.id(SharedString::from(format!(
273
"settings-body-{}",
274
label(self.section)
275
)))
292
let help_preview = self
293
.help
294
.as_ref()
295
.is_some_and(|help| help.read(cx).is_previewing());
296
let content = div()
297
.debug_selector(|| "settings/main/body/content".into())
276
298
.w_full()
277
.flex_1()
278
.min_h_0()
279
.overflow_y_scrollbar()
280
.track_scroll(&self.body_scroll)
281
.px(px(body_inset.max(0.)))
282
.pb(px(metrics.padding))
283
.child(
284
div()
285
.debug_selector(|| "settings/main/body/content".into())
286
.w_full()
287
.max_w(px(CONTENT_MAX_WIDTH))
288
.child(self.content(cx)),
289
);
299
.max_w(px(CONTENT_MAX_WIDTH))
300
.when(help_preview, |content| content.h_full().min_h_0())
301
.child(self.content(cx));
302
let scroll_area = if help_preview {
303
div()
304
.id(SharedString::from(format!(
305
"settings-body-{}",
306
label(self.section)
307
)))
308
.w_full()
309
.flex_1()
310
.min_h_0()
311
.overflow_hidden()
312
.px(px(body_inset.max(0.)))
313
.pb(px(metrics.padding))
314
.child(content)
315
.into_any_element()
316
} else {
317
div()
318
.id(SharedString::from(format!(
319
"settings-body-{}",
320
label(self.section)
321
)))
322
.w_full()
323
.flex_1()
324
.min_h_0()
325
.overflow_y_scrollbar()
326
.track_scroll(&self.body_scroll)
327
.px(px(body_inset.max(0.)))
328
.pb(px(metrics.padding))
329
.child(content)
330
.into_any_element()
331
};
290
332
let body = div()
291
333
.debug_selector(|| "settings/main/body".into())
292
334
.w_full()
@@ -3,9 +3,11 @@ use gpui_kit::assets::IconName;3
use gpui_kit::component::input::{Input, InputEvent, InputState};3
use gpui_kit::component::input::{Input, InputEvent, InputState};4
use gpui_kit::component::scroll::ScrollableElement as _;4
use gpui_kit::component::scroll::ScrollableElement as _;5
use gpui_kit::component::{h_flex, v_flex};5
use gpui_kit::component::{h_flex, v_flex};6
use gpui_kit::prelude::FluentBuilder as _;6
use gpui_kit::*;7
use gpui_kit::*;7
8
8
use super::devices::DevicesView;9
use super::devices::DevicesView;10
use super::help::HelpView;9
use super::mcp::McpView;11
use super::mcp::McpView;10
use super::nav::{NavLayout, NavSearch, first_match, label, matches, render_nav};12
use super::nav::{NavLayout, NavSearch, first_match, label, matches, render_nav};11
use super::rows::ROW_INSET;13
use super::rows::ROW_INSET;@@ -63,6 +65,7 @@ pub struct SettingsDialog {63
center: Entity<NotificationCenter>,65
center: Entity<NotificationCenter>,64
section: SettingsSection,66
section: SettingsSection,65
devices: Option<Entity<DevicesView>>,67
devices: Option<Entity<DevicesView>>,68
help: Option<Entity<HelpView>>,66
mcp: Option<Entity<McpView>>,69
mcp: Option<Entity<McpView>>,67
agents: Option<Entity<AgentsSettings>>,70
agents: Option<Entity<AgentsSettings>>,68
body_scroll: ScrollHandle,71
body_scroll: ScrollHandle,@@ -102,6 +105,7 @@ impl SettingsDialog {102
center,105
center,103
section,106
section,104
devices: None,107
devices: None,108
help: None,105
mcp: None,109
mcp: None,106
agents: None,110
agents: None,107
body_scroll: ScrollHandle::new(),111
body_scroll: ScrollHandle::new(),@@ -127,6 +131,19 @@ impl SettingsDialog {127
} else {131
} else {128
self.devices = None;132
self.devices = None;129
}133
}134
if section == SettingsSection::Help {135
if self.help.is_none() {136
let app = self.app.clone();137
self.help = Some(cx.new(|cx| HelpView::new(app, cx)));138
} else if let Some(help) = self.help.as_ref() {139
help.update(cx, |view, cx| {140
view.reload_bundles();141
cx.notify();142
});143
}144
} else {145
self.help = None;146
}130
if section == SettingsSection::Mcp && self.mcp.is_none() {147
if section == SettingsSection::Mcp && self.mcp.is_none() {131
let app = self.app.clone();148
let app = self.app.clone();132
self.mcp = Some(cx.new(|cx| McpView::new(app, window, cx)));149
self.mcp = Some(cx.new(|cx| McpView::new(app, window, cx)));@@ -199,6 +216,10 @@ impl SettingsDialog {199
.mcp216
.mcp200
.clone()217
.clone()201
.map_or_else(|| div().into_any_element(), |view| view.into_any_element()),218
.map_or_else(|| div().into_any_element(), |view| view.into_any_element()),219
SettingsSection::Help => self220
.help221
.clone()222
.map_or_else(|| div().into_any_element(), |view| view.into_any_element()),202
SettingsSection::About => about::render().into_any_element(),223
SettingsSection::About => about::render().into_any_element(),203
}224
}204
}225
}@@ -268,25 +289,46 @@ impl Render for SettingsDialog {268
} else {289
} else {269
metrics.padding290
metrics.padding270
};291
};271
let scroll_area = div()292
let help_preview = self272
.id(SharedString::from(format!(293
.help273
"settings-body-{}",294
.as_ref()274
label(self.section)295
.is_some_and(|help| help.read(cx).is_previewing());275
)))296
let content = div()297
.debug_selector(|| "settings/main/body/content".into())276
.w_full()298
.w_full()277
.flex_1()299
.max_w(px(CONTENT_MAX_WIDTH))278
.min_h_0()300
.when(help_preview, |content| content.h_full().min_h_0())279
.overflow_y_scrollbar()301
.child(self.content(cx));280
.track_scroll(&self.body_scroll)302
let scroll_area = if help_preview {281
.px(px(body_inset.max(0.)))303
div()282
.pb(px(metrics.padding))304
.id(SharedString::from(format!(283
.child(305
"settings-body-{}",284
div()306
label(self.section)285
.debug_selector(|| "settings/main/body/content".into())307
)))286
.w_full()308
.w_full()287
.max_w(px(CONTENT_MAX_WIDTH))309
.flex_1()288
.child(self.content(cx)),310
.min_h_0()289
);311
.overflow_hidden()312
.px(px(body_inset.max(0.)))313
.pb(px(metrics.padding))314
.child(content)315
.into_any_element()316
} else {317
div()318
.id(SharedString::from(format!(319
"settings-body-{}",320
label(self.section)321
)))322
.w_full()323
.flex_1()324
.min_h_0()325
.overflow_y_scrollbar()326
.track_scroll(&self.body_scroll)327
.px(px(body_inset.max(0.)))328
.pb(px(metrics.padding))329
.child(content)330
.into_any_element()331
};290
let body = div()332
let body = div()291
.debug_selector(|| "settings/main/body".into())333
.debug_selector(|| "settings/main/body".into())292
.w_full()334
.w_full()@@ -0,0 +1,601 @@
1
use std::path::{Path, PathBuf};
2
3
use app_base::downloads::reveal_in_file_manager;
4
use app_base::support::{
5
self, BundleFileEntry, SupportBundleEntry, ensure_dir, format_bytes, list_bundle_files,
6
list_support_bundles,
7
};
8
use app_ui_kit::render::{layout_blocks, render_blocks, strip_image_placeholders};
9
use gpui_kit::assets::IconName;
10
use gpui_kit::component::scroll::ScrollableElement as _;
11
use gpui_kit::component::tooltip::Tooltip;
12
use gpui_kit::component::{ActiveTheme as _, h_flex, v_flex};
13
use gpui_kit::prelude::FluentBuilder as _;
14
use gpui_kit::*;
15
16
use super::rows::{ROW_INSET, caption, control_row, text_button, toggle_row};
17
use crate::app_state::AppState;
18
use crate::i18n::tr;
19
use crate::theme::{self, ElevatedSurface as _};
20
use crate::views::widgets::icon;
21
22
const COPY_ICON_SIZE: f32 = 14.;
23
const PREVIEW_LIMIT: usize = 256 * 1024;
24
const PREVIEW_RADIUS: f32 = 10.;
25
const PREVIEW_PADDING: f32 = 12.;
26
27
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
28
enum PreviewKind {
29
Markdown,
30
Text,
31
}
32
33
struct FilePreview {
34
name: String,
35
text: String,
36
kind: PreviewKind,
37
truncated: bool,
38
}
39
40
pub struct HelpView {
41
app: Entity<AppState>,
42
bundles: Vec<SupportBundleEntry>,
43
expanded: Option<PathBuf>,
44
expanded_files: Vec<BundleFileEntry>,
45
preview: Option<FilePreview>,
46
}
47
48
impl HelpView {
49
pub fn new(app: Entity<AppState>, cx: &mut Context<Self>) -> Self {
50
let mut view = HelpView {
51
app,
52
bundles: Vec::new(),
53
expanded: None,
54
expanded_files: Vec::new(),
55
preview: None,
56
};
57
view.reload_bundles();
58
let _ = cx;
59
view
60
}
61
62
pub(crate) fn is_previewing(&self) -> bool {
63
self.preview.is_some()
64
}
65
66
pub(crate) fn reload_bundles(&mut self) {
67
let Some(root) = support::support_bundles_dir() else {
68
self.bundles.clear();
69
self.expanded = None;
70
self.expanded_files.clear();
71
return;
72
};
73
self.bundles = list_support_bundles(&root).unwrap_or_default();
74
if let Some(expanded) = self.expanded.clone() {
75
if self.bundles.iter().any(|entry| entry.directory == expanded) {
76
self.expanded_files = list_bundle_files(&expanded).unwrap_or_default();
77
} else {
78
self.expanded = None;
79
self.expanded_files.clear();
80
}
81
}
82
}
83
84
fn toggle_expand(&mut self, directory: PathBuf, cx: &mut Context<Self>) {
85
if self.expanded.as_ref() == Some(&directory) {
86
self.expanded = None;
87
self.expanded_files.clear();
88
} else {
89
self.expanded_files = list_bundle_files(&directory).unwrap_or_default();
90
self.expanded = Some(directory);
91
}
92
cx.notify();
93
}
94
95
fn delete_bundle(&mut self, directory: PathBuf, cx: &mut Context<Self>) {
96
let parent = support::support_bundles_dir();
97
if let Err(error) = support::delete_support_bundle(&directory, parent.as_deref()) {
98
app_base::diagnostics::record(format!("support delete: {error}"));
99
return;
100
}
101
if self.expanded.as_ref() == Some(&directory) {
102
self.expanded = None;
103
self.expanded_files.clear();
104
}
105
self.preview = None;
106
self.reload_bundles();
107
cx.notify();
108
}
109
110
fn reveal_path(path: &Path) {
111
let _ = ensure_dir(path);
112
reveal_in_file_manager(path);
113
}
114
115
fn open_preview(&mut self, path: PathBuf, cx: &mut Context<Self>) {
116
let name = path
117
.file_name()
118
.map(|value| value.to_string_lossy().into_owned())
119
.unwrap_or_else(|| path.display().to_string());
120
let kind = if name.ends_with(".md") {
121
PreviewKind::Markdown
122
} else {
123
PreviewKind::Text
124
};
125
match read_preview_text(&path) {
126
Ok(ReadPreview {
127
text,
128
truncated,
129
binary,
130
}) => {
131
self.preview = Some(FilePreview {
132
name,
133
text: if binary {
134
tr("settings.help.preview_binary")
135
} else {
136
text
137
},
138
kind: if binary { PreviewKind::Text } else { kind },
139
truncated: truncated && !binary,
140
});
141
}
142
Err(error) => {
143
app_base::diagnostics::record(format!("support preview: {error}"));
144
self.preview = Some(FilePreview {
145
name,
146
text: tr("settings.help.preview_error"),
147
kind: PreviewKind::Text,
148
truncated: false,
149
});
150
}
151
}
152
cx.notify();
153
}
154
155
fn close_preview(&mut self, cx: &mut Context<Self>) {
156
self.preview = None;
157
cx.notify();
158
}
159
160
fn copy_path_button(id: &'static str, path: String) -> Stateful<Div> {
161
div()
162
.id(id)
163
.cursor_pointer()
164
.p(px(4.))
165
.rounded(px(6.))
166
.hover(|button| button.bg(theme::row_hover()))
167
.tooltip(|window, cx| {
168
Tooltip::new(tr("settings.help.copy_path_tooltip")).build(window, cx)
169
})
170
.on_click(move |_, _, cx| {
171
cx.stop_propagation();
172
cx.write_to_clipboard(ClipboardItem::new_string(path.clone()));
173
})
174
.child(icon(IconName::Copy, COPY_ICON_SIZE, theme::text_muted()))
175
}
176
177
fn path_row(
178
&self,
179
title: impl Into<SharedString>,
180
path: String,
181
copy_id: &'static str,
182
open_id: &'static str,
183
cx: &App,
184
) -> Div {
185
let title = title.into();
186
let open_path = PathBuf::from(path.clone());
187
v_flex()
188
.w_full()
189
.px(px(ROW_INSET))
190
.py(px(12.))
191
.gap(px(8.))
192
.rounded(px(8.))
193
.child(
194
h_flex()
195
.w_full()
196
.gap(px(8.))
197
.items_center()
198
.child(
199
div()
200
.flex_1()
201
.min_w(px(0.))
202
.text_size(px(14.))
203
.line_height(px(20.))
204
.font_weight(FontWeight::SEMIBOLD)
205
.text_color(theme::text())
206
.child(title),
207
)
208
.child(Self::copy_path_button(copy_id, path.clone()))
209
.child(text_button(open_id, tr("common.open")).on_click(move |_, _, _| {
210
Self::reveal_path(&open_path);
211
})),
212
)
213
.child(
214
div()
215
.w_full()
216
.min_w(px(0.))
217
.font_family(cx.theme().mono_font_family.clone())
218
.text_size(px(12.))
219
.line_height(px(18.))
220
.text_color(theme::text_muted())
221
.whitespace_normal()
222
.child(path),
223
)
224
}
225
226
fn bundle_row(&self, entry: &SupportBundleEntry, cx: &mut Context<Self>) -> Div {
227
let directory = entry.directory.clone();
228
let toggle_dir = directory.clone();
229
let delete_dir = directory.clone();
230
let expanded = self.expanded.as_ref() == Some(&directory);
231
v_flex()
232
.w_full()
233
.child(
234
h_flex()
235
.w_full()
236
.px(px(ROW_INSET))
237
.py(px(10.))
238
.gap(px(12.))
239
.items_center()
240
.rounded(px(8.))
241
.when(expanded, |row| row.bg(theme::popup_hover()))
242
.child(
243
h_flex()
244
.id(SharedString::from(format!(
245
"settings-help-bundle-{}",
246
entry.name
247
)))
248
.flex_1()
249
.min_w(px(0.))
250
.gap(px(8.))
251
.items_center()
252
.cursor_pointer()
253
.hover(|row| row.bg(theme::popup_hover()))
254
.on_click(cx.listener(move |this, _, _, cx| {
255
this.toggle_expand(toggle_dir.clone(), cx);
256
}))
257
.child(
258
div()
259
.flex_1()
260
.min_w(px(0.))
261
.text_size(px(14.))
262
.font_weight(FontWeight::SEMIBOLD)
263
.text_color(theme::text())
264
.child(entry.name.clone()),
265
),
266
)
267
.child(
268
text_button(
269
SharedString::from(format!("settings-help-delete-{}", entry.name)),
270
tr("common.delete"),
271
)
272
.on_click(cx.listener(move |this, _, _, cx| {
273
this.delete_bundle(delete_dir.clone(), cx);
274
})),
275
),
276
)
277
.when(expanded, |column| column.child(self.expanded_panel(cx)))
278
}
279
280
fn expanded_panel(&self, cx: &mut Context<Self>) -> Div {
281
v_flex()
282
.w_full()
283
.px(px(ROW_INSET + 8.))
284
.pb(px(8.))
285
.gap(px(4.))
286
.children(self.expanded_files.iter().map(|file| {
287
let path = file.path.clone();
288
let label = format!("{} · {}", file.name, format_bytes(file.size_bytes));
289
div()
290
.id(SharedString::from(format!(
291
"settings-help-file-{}",
292
file.name
293
)))
294
.w_full()
295
.px(px(8.))
296
.py(px(6.))
297
.rounded(px(6.))
298
.cursor_pointer()
299
.hover(|row| row.bg(theme::popup_hover()))
300
.on_click(cx.listener(move |this, _, _, cx| {
301
this.open_preview(path.clone(), cx);
302
}))
303
.child(
304
div()
305
.text_size(px(12.))
306
.text_color(theme::text_muted())
307
.child(label),
308
)
309
}))
310
}
311
312
fn packages_section(&self, cx: &mut Context<Self>) -> Div {
313
v_flex()
314
.w_full()
315
.child(caption(tr("settings.help.caption_packages")))
316
.when(self.bundles.is_empty(), |section| {
317
section.child(
318
div()
319
.px(px(ROW_INSET))
320
.py(px(8.))
321
.text_size(px(13.))
322
.text_color(theme::text_muted())
323
.child(tr("settings.help.packages_empty")),
324
)
325
})
326
.children(
327
self.bundles
328
.iter()
329
.map(|entry| self.bundle_row(entry, cx))
330
.collect::<Vec<_>>(),
331
)
332
}
333
334
fn preview_body(&self, preview: &FilePreview, cx: &App) -> AnyElement {
335
match preview.kind {
336
PreviewKind::Markdown => {
337
// Full document markdown (headings, tables, lists) — not the light chat dialect.
338
let html = teams_core::Draft::from_markdown(&preview.text).to_html();
339
let blocks =
340
strip_image_placeholders(layout_blocks(&teams_core::html_to_spans(&html)));
341
div()
342
.w_full()
343
.min_w(px(0.))
344
.text_size(px(13.))
345
.text_color(theme::text())
346
.whitespace_normal()
347
.child(render_blocks(&blocks, "settings-help-preview", false, cx))
348
.into_any_element()
349
}
350
PreviewKind::Text => div()
351
.w_full()
352
.min_w(px(0.))
353
.font_family(cx.theme().mono_font_family.clone())
354
.text_size(px(12.))
355
.line_height(px(18.))
356
.text_color(theme::text_muted())
357
.whitespace_normal()
358
.child(preview.text.clone())
359
.into_any_element(),
360
}
361
}
362
363
fn preview_panel(&self, cx: &mut Context<Self>) -> Div {
364
let preview = self.preview.as_ref().expect("preview open");
365
v_flex()
366
.w_full()
367
.h_full()
368
.min_h_0()
369
.gap(px(8.))
370
.px(px(ROW_INSET))
371
.pb(px(ROW_INSET))
372
.child(
373
h_flex()
374
.w_full()
375
.flex_none()
376
.gap(px(8.))
377
.items_center()
378
.child(
379
text_button("settings-help-preview-back", tr("common.close")).on_click(
380
cx.listener(|this, _, _, cx| this.close_preview(cx)),
381
),
382
)
383
.child(
384
div()
385
.flex_1()
386
.min_w(px(0.))
387
.text_size(px(14.))
388
.font_weight(FontWeight::SEMIBOLD)
389
.text_color(theme::text())
390
.child(preview.name.clone()),
391
),
392
)
393
.when(preview.truncated, |column| {
394
column.child(
395
div()
396
.flex_none()
397
.text_size(px(12.))
398
.text_color(theme::text_muted())
399
.child(tr("settings.help.preview_truncated")),
400
)
401
})
402
.child(
403
div()
404
.id("settings-help-preview-scroll")
405
.w_full()
406
.flex_1()
407
.min_h_0()
408
.p(px(PREVIEW_PADDING))
409
.rounded(px(PREVIEW_RADIUS))
410
.dialog_surface()
411
.overflow_y_scrollbar()
412
.child(self.preview_body(preview, cx)),
413
)
414
}
415
416
fn help_home(&self, cx: &mut Context<Self>) -> Div {
417
let info = self.app.read(cx).client_info();
418
let summary = info.markdown();
419
let copy_summary = summary.clone();
420
let logs_path = info.logs_root.clone();
421
let bundles_path = info.support_bundles_root.clone();
422
let create_app = self.app.clone();
423
let issue_app = self.app.clone();
424
v_flex()
425
.w_full()
426
.gap(px(4.))
427
.child(caption(tr("settings.help.caption_client")))
428
.child(control_row(
429
tr("settings.help.version"),
430
format!("{} ({})", info.version, info.build),
431
div(),
432
))
433
.child(control_row(
434
tr("settings.help.platform"),
435
format!("{} / {} / {}", info.os, info.arch, info.session),
436
div(),
437
))
438
.child(control_row(
439
tr("settings.help.locale"),
440
format!("{} · {}", info.ui_locale, info.timezone),
441
div(),
442
))
443
.child(control_row(
444
tr("settings.help.signed_in"),
445
if info.signed_in {
446
tr("settings.help.yes")
447
} else {
448
tr("settings.help.no")
449
},
450
div(),
451
))
452
.child({
453
let debug_on = self.app.read(cx).diagnostics_enabled();
454
let toggle_app = self.app.clone();
455
toggle_row(
456
"settings-help-debug-log",
457
tr("settings.help.debug_logging"),
458
if debug_on {
459
tr("settings.help.debug_logging_on_detail")
460
} else {
461
tr("settings.help.debug_logging_off_detail")
462
},
463
theme::text_muted(),
464
debug_on,
465
)
466
.on_click(cx.listener(move |_, _, _, cx| {
467
toggle_app.update(cx, |state, cx| {
468
state.set_diagnostics_enabled(!debug_on, cx);
469
});
470
cx.notify();
471
}))
472
})
473
.child({
474
let clear_app = self.app.clone();
475
control_row(
476
tr("settings.help.clear_logs"),
477
tr("settings.help.clear_logs_detail"),
478
text_button("settings-help-clear-logs", tr("settings.help.clear_logs_button"))
479
.on_click(cx.listener(move |_, _, _, cx| {
480
clear_app.update(cx, |state, cx| state.clear_diagnostic_logs(cx));
481
cx.notify();
482
})),
483
)
484
})
485
.child(caption(tr("settings.help.caption_paths")))
486
.child(self.path_row(
487
tr("settings.help.logs_path"),
488
logs_path,
489
"settings-help-copy-logs",
490
"settings-help-open-logs-root",
491
cx,
492
))
493
.child(self.path_row(
494
tr("settings.help.bundles_path"),
495
bundles_path,
496
"settings-help-copy-bundles",
497
"settings-help-open-bundles-root",
498
cx,
499
))
500
.child(self.packages_section(cx))
501
.child(caption(tr("settings.help.caption_actions")))
502
.child(
503
div()
504
.text_size(px(13.))
505
.text_color(theme::text_muted())
506
.pb(px(8.))
507
.px(px(ROW_INSET))
508
.child(tr("settings.help.detail")),
509
)
510
.child(control_row(
511
tr("settings.help.create_bundle"),
512
tr("settings.help.create_bundle_detail"),
513
text_button("settings-help-bundle", tr("settings.help.create_bundle_button"))
514
.on_click(cx.listener(move |this, _, _, cx| {
515
create_app.update(cx, |state, _| {
516
match state.create_support_bundle() {
517
Ok(bundle) => AppState::reveal_support_bundle(&bundle),
518
Err(error) => app_base::diagnostics::record(format!(
519
"support bundle: {error}"
520
)),
521
}
522
});
523
this.reload_bundles();
524
cx.notify();
525
})),
526
))
527
.child(control_row(
528
tr("settings.help.open_issue"),
529
tr("settings.help.open_issue_detail"),
530
text_button("settings-help-issue", tr("settings.help.open_issue_button")).on_click(
531
cx.listener(move |this, _, _, cx| {
532
issue_app.update(cx, |state, cx| {
533
if let Err(error) = state.open_github_issue_with_bundle(cx) {
534
app_base::diagnostics::record(format!("support issue: {error}"));
535
}
536
});
537
this.reload_bundles();
538
cx.notify();
539
}),
540
),
541
))
542
.child(control_row(
543
tr("settings.help.copy_summary"),
544
tr("settings.help.copy_summary_detail"),
545
text_button("settings-help-copy", tr("settings.help.copy_button")).on_click(
546
move |_, _, cx| {
547
cx.write_to_clipboard(ClipboardItem::new_string(copy_summary.clone()));
548
},
549
),
550
))
551
.child(control_row(
552
tr("settings.help.open_logs"),
553
tr("settings.help.open_logs_detail"),
554
text_button("settings-help-logs", tr("common.open")).on_click(move |_, _, _| {
555
AppState::reveal_logs_folder();
556
}),
557
))
558
}
559
}
560
561
struct ReadPreview {
562
text: String,
563
truncated: bool,
564
binary: bool,
565
}
566
567
fn read_preview_text(path: &Path) -> std::io::Result<ReadPreview> {
568
use std::io::Read as _;
569
let mut file = std::fs::File::open(path)?;
570
let mut buf = vec![0u8; PREVIEW_LIMIT + 1];
571
let read = file.read(&mut buf)?;
572
let truncated = read > PREVIEW_LIMIT;
573
let slice = &buf[..read.min(PREVIEW_LIMIT)];
574
match std::str::from_utf8(slice) {
575
Ok(text) => Ok(ReadPreview {
576
text: text.to_owned(),
577
truncated,
578
binary: false,
579
}),
580
Err(_) => Ok(ReadPreview {
581
text: String::new(),
582
truncated: false,
583
binary: true,
584
}),
585
}
586
}
587
588
impl Render for HelpView {
589
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
590
let previewing = self.preview.is_some();
591
v_flex()
592
.w_full()
593
.when(previewing, |root| root.h_full().min_h_0())
594
.debug_selector(|| "settings/help".into())
595
.child(if previewing {
596
self.preview_panel(cx)
597
} else {
598
self.help_home(cx)
599
})
600
}
601
}
@@ -0,0 +1,601 @@1
use std::path::{Path, PathBuf};2
3
use app_base::downloads::reveal_in_file_manager;4
use app_base::support::{5
self, BundleFileEntry, SupportBundleEntry, ensure_dir, format_bytes, list_bundle_files,6
list_support_bundles,7
};8
use app_ui_kit::render::{layout_blocks, render_blocks, strip_image_placeholders};9
use gpui_kit::assets::IconName;10
use gpui_kit::component::scroll::ScrollableElement as _;11
use gpui_kit::component::tooltip::Tooltip;12
use gpui_kit::component::{ActiveTheme as _, h_flex, v_flex};13
use gpui_kit::prelude::FluentBuilder as _;14
use gpui_kit::*;15
16
use super::rows::{ROW_INSET, caption, control_row, text_button, toggle_row};17
use crate::app_state::AppState;18
use crate::i18n::tr;19
use crate::theme::{self, ElevatedSurface as _};20
use crate::views::widgets::icon;21
22
const COPY_ICON_SIZE: f32 = 14.;23
const PREVIEW_LIMIT: usize = 256 * 1024;24
const PREVIEW_RADIUS: f32 = 10.;25
const PREVIEW_PADDING: f32 = 12.;26
27
#[derive(Debug, Clone, Copy, PartialEq, Eq)]28
enum PreviewKind {29
Markdown,30
Text,31
}32
33
struct FilePreview {34
name: String,35
text: String,36
kind: PreviewKind,37
truncated: bool,38
}39
40
pub struct HelpView {41
app: Entity<AppState>,42
bundles: Vec<SupportBundleEntry>,43
expanded: Option<PathBuf>,44
expanded_files: Vec<BundleFileEntry>,45
preview: Option<FilePreview>,46
}47
48
impl HelpView {49
pub fn new(app: Entity<AppState>, cx: &mut Context<Self>) -> Self {50
let mut view = HelpView {51
app,52
bundles: Vec::new(),53
expanded: None,54
expanded_files: Vec::new(),55
preview: None,56
};57
view.reload_bundles();58
let _ = cx;59
view60
}61
62
pub(crate) fn is_previewing(&self) -> bool {63
self.preview.is_some()64
}65
66
pub(crate) fn reload_bundles(&mut self) {67
let Some(root) = support::support_bundles_dir() else {68
self.bundles.clear();69
self.expanded = None;70
self.expanded_files.clear();71
return;72
};73
self.bundles = list_support_bundles(&root).unwrap_or_default();74
if let Some(expanded) = self.expanded.clone() {75
if self.bundles.iter().any(|entry| entry.directory == expanded) {76
self.expanded_files = list_bundle_files(&expanded).unwrap_or_default();77
} else {78
self.expanded = None;79
self.expanded_files.clear();80
}81
}82
}83
84
fn toggle_expand(&mut self, directory: PathBuf, cx: &mut Context<Self>) {85
if self.expanded.as_ref() == Some(&directory) {86
self.expanded = None;87
self.expanded_files.clear();88
} else {89
self.expanded_files = list_bundle_files(&directory).unwrap_or_default();90
self.expanded = Some(directory);91
}92
cx.notify();93
}94
95
fn delete_bundle(&mut self, directory: PathBuf, cx: &mut Context<Self>) {96
let parent = support::support_bundles_dir();97
if let Err(error) = support::delete_support_bundle(&directory, parent.as_deref()) {98
app_base::diagnostics::record(format!("support delete: {error}"));99
return;100
}101
if self.expanded.as_ref() == Some(&directory) {102
self.expanded = None;103
self.expanded_files.clear();104
}105
self.preview = None;106
self.reload_bundles();107
cx.notify();108
}109
110
fn reveal_path(path: &Path) {111
let _ = ensure_dir(path);112
reveal_in_file_manager(path);113
}114
115
fn open_preview(&mut self, path: PathBuf, cx: &mut Context<Self>) {116
let name = path117
.file_name()118
.map(|value| value.to_string_lossy().into_owned())119
.unwrap_or_else(|| path.display().to_string());120
let kind = if name.ends_with(".md") {121
PreviewKind::Markdown122
} else {123
PreviewKind::Text124
};125
match read_preview_text(&path) {126
Ok(ReadPreview {127
text,128
truncated,129
binary,130
}) => {131
self.preview = Some(FilePreview {132
name,133
text: if binary {134
tr("settings.help.preview_binary")135
} else {136
text137
},138
kind: if binary { PreviewKind::Text } else { kind },139
truncated: truncated && !binary,140
});141
}142
Err(error) => {143
app_base::diagnostics::record(format!("support preview: {error}"));144
self.preview = Some(FilePreview {145
name,146
text: tr("settings.help.preview_error"),147
kind: PreviewKind::Text,148
truncated: false,149
});150
}151
}152
cx.notify();153
}154
155
fn close_preview(&mut self, cx: &mut Context<Self>) {156
self.preview = None;157
cx.notify();158
}159
160
fn copy_path_button(id: &'static str, path: String) -> Stateful<Div> {161
div()162
.id(id)163
.cursor_pointer()164
.p(px(4.))165
.rounded(px(6.))166
.hover(|button| button.bg(theme::row_hover()))167
.tooltip(|window, cx| {168
Tooltip::new(tr("settings.help.copy_path_tooltip")).build(window, cx)169
})170
.on_click(move |_, _, cx| {171
cx.stop_propagation();172
cx.write_to_clipboard(ClipboardItem::new_string(path.clone()));173
})174
.child(icon(IconName::Copy, COPY_ICON_SIZE, theme::text_muted()))175
}176
177
fn path_row(178
&self,179
title: impl Into<SharedString>,180
path: String,181
copy_id: &'static str,182
open_id: &'static str,183
cx: &App,184
) -> Div {185
let title = title.into();186
let open_path = PathBuf::from(path.clone());187
v_flex()188
.w_full()189
.px(px(ROW_INSET))190
.py(px(12.))191
.gap(px(8.))192
.rounded(px(8.))193
.child(194
h_flex()195
.w_full()196
.gap(px(8.))197
.items_center()198
.child(199
div()200
.flex_1()201
.min_w(px(0.))202
.text_size(px(14.))203
.line_height(px(20.))204
.font_weight(FontWeight::SEMIBOLD)205
.text_color(theme::text())206
.child(title),207
)208
.child(Self::copy_path_button(copy_id, path.clone()))209
.child(text_button(open_id, tr("common.open")).on_click(move |_, _, _| {210
Self::reveal_path(&open_path);211
})),212
)213
.child(214
div()215
.w_full()216
.min_w(px(0.))217
.font_family(cx.theme().mono_font_family.clone())218
.text_size(px(12.))219
.line_height(px(18.))220
.text_color(theme::text_muted())221
.whitespace_normal()222
.child(path),223
)224
}225
226
fn bundle_row(&self, entry: &SupportBundleEntry, cx: &mut Context<Self>) -> Div {227
let directory = entry.directory.clone();228
let toggle_dir = directory.clone();229
let delete_dir = directory.clone();230
let expanded = self.expanded.as_ref() == Some(&directory);231
v_flex()232
.w_full()233
.child(234
h_flex()235
.w_full()236
.px(px(ROW_INSET))237
.py(px(10.))238
.gap(px(12.))239
.items_center()240
.rounded(px(8.))241
.when(expanded, |row| row.bg(theme::popup_hover()))242
.child(243
h_flex()244
.id(SharedString::from(format!(245
"settings-help-bundle-{}",246
entry.name247
)))248
.flex_1()249
.min_w(px(0.))250
.gap(px(8.))251
.items_center()252
.cursor_pointer()253
.hover(|row| row.bg(theme::popup_hover()))254
.on_click(cx.listener(move |this, _, _, cx| {255
this.toggle_expand(toggle_dir.clone(), cx);256
}))257
.child(258
div()259
.flex_1()260
.min_w(px(0.))261
.text_size(px(14.))262
.font_weight(FontWeight::SEMIBOLD)263
.text_color(theme::text())264
.child(entry.name.clone()),265
),266
)267
.child(268
text_button(269
SharedString::from(format!("settings-help-delete-{}", entry.name)),270
tr("common.delete"),271
)272
.on_click(cx.listener(move |this, _, _, cx| {273
this.delete_bundle(delete_dir.clone(), cx);274
})),275
),276
)277
.when(expanded, |column| column.child(self.expanded_panel(cx)))278
}279
280
fn expanded_panel(&self, cx: &mut Context<Self>) -> Div {281
v_flex()282
.w_full()283
.px(px(ROW_INSET + 8.))284
.pb(px(8.))285
.gap(px(4.))286
.children(self.expanded_files.iter().map(|file| {287
let path = file.path.clone();288
let label = format!("{} · {}", file.name, format_bytes(file.size_bytes));289
div()290
.id(SharedString::from(format!(291
"settings-help-file-{}",292
file.name293
)))294
.w_full()295
.px(px(8.))296
.py(px(6.))297
.rounded(px(6.))298
.cursor_pointer()299
.hover(|row| row.bg(theme::popup_hover()))300
.on_click(cx.listener(move |this, _, _, cx| {301
this.open_preview(path.clone(), cx);302
}))303
.child(304
div()305
.text_size(px(12.))306
.text_color(theme::text_muted())307
.child(label),308
)309
}))310
}311
312
fn packages_section(&self, cx: &mut Context<Self>) -> Div {313
v_flex()314
.w_full()315
.child(caption(tr("settings.help.caption_packages")))316
.when(self.bundles.is_empty(), |section| {317
section.child(318
div()319
.px(px(ROW_INSET))320
.py(px(8.))321
.text_size(px(13.))322
.text_color(theme::text_muted())323
.child(tr("settings.help.packages_empty")),324
)325
})326
.children(327
self.bundles328
.iter()329
.map(|entry| self.bundle_row(entry, cx))330
.collect::<Vec<_>>(),331
)332
}333
334
fn preview_body(&self, preview: &FilePreview, cx: &App) -> AnyElement {335
match preview.kind {336
PreviewKind::Markdown => {337
// Full document markdown (headings, tables, lists) — not the light chat dialect.338
let html = teams_core::Draft::from_markdown(&preview.text).to_html();339
let blocks =340
strip_image_placeholders(layout_blocks(&teams_core::html_to_spans(&html)));341
div()342
.w_full()343
.min_w(px(0.))344
.text_size(px(13.))345
.text_color(theme::text())346
.whitespace_normal()347
.child(render_blocks(&blocks, "settings-help-preview", false, cx))348
.into_any_element()349
}350
PreviewKind::Text => div()351
.w_full()352
.min_w(px(0.))353
.font_family(cx.theme().mono_font_family.clone())354
.text_size(px(12.))355
.line_height(px(18.))356
.text_color(theme::text_muted())357
.whitespace_normal()358
.child(preview.text.clone())359
.into_any_element(),360
}361
}362
363
fn preview_panel(&self, cx: &mut Context<Self>) -> Div {364
let preview = self.preview.as_ref().expect("preview open");365
v_flex()366
.w_full()367
.h_full()368
.min_h_0()369
.gap(px(8.))370
.px(px(ROW_INSET))371
.pb(px(ROW_INSET))372
.child(373
h_flex()374
.w_full()375
.flex_none()376
.gap(px(8.))377
.items_center()378
.child(379
text_button("settings-help-preview-back", tr("common.close")).on_click(380
cx.listener(|this, _, _, cx| this.close_preview(cx)),381
),382
)383
.child(384
div()385
.flex_1()386
.min_w(px(0.))387
.text_size(px(14.))388
.font_weight(FontWeight::SEMIBOLD)389
.text_color(theme::text())390
.child(preview.name.clone()),391
),392
)393
.when(preview.truncated, |column| {394
column.child(395
div()396
.flex_none()397
.text_size(px(12.))398
.text_color(theme::text_muted())399
.child(tr("settings.help.preview_truncated")),400
)401
})402
.child(403
div()404
.id("settings-help-preview-scroll")405
.w_full()406
.flex_1()407
.min_h_0()408
.p(px(PREVIEW_PADDING))409
.rounded(px(PREVIEW_RADIUS))410
.dialog_surface()411
.overflow_y_scrollbar()412
.child(self.preview_body(preview, cx)),413
)414
}415
416
fn help_home(&self, cx: &mut Context<Self>) -> Div {417
let info = self.app.read(cx).client_info();418
let summary = info.markdown();419
let copy_summary = summary.clone();420
let logs_path = info.logs_root.clone();421
let bundles_path = info.support_bundles_root.clone();422
let create_app = self.app.clone();423
let issue_app = self.app.clone();424
v_flex()425
.w_full()426
.gap(px(4.))427
.child(caption(tr("settings.help.caption_client")))428
.child(control_row(429
tr("settings.help.version"),430
format!("{} ({})", info.version, info.build),431
div(),432
))433
.child(control_row(434
tr("settings.help.platform"),435
format!("{} / {} / {}", info.os, info.arch, info.session),436
div(),437
))438
.child(control_row(439
tr("settings.help.locale"),440
format!("{} · {}", info.ui_locale, info.timezone),441
div(),442
))443
.child(control_row(444
tr("settings.help.signed_in"),445
if info.signed_in {446
tr("settings.help.yes")447
} else {448
tr("settings.help.no")449
},450
div(),451
))452
.child({453
let debug_on = self.app.read(cx).diagnostics_enabled();454
let toggle_app = self.app.clone();455
toggle_row(456
"settings-help-debug-log",457
tr("settings.help.debug_logging"),458
if debug_on {459
tr("settings.help.debug_logging_on_detail")460
} else {461
tr("settings.help.debug_logging_off_detail")462
},463
theme::text_muted(),464
debug_on,465
)466
.on_click(cx.listener(move |_, _, _, cx| {467
toggle_app.update(cx, |state, cx| {468
state.set_diagnostics_enabled(!debug_on, cx);469
});470
cx.notify();471
}))472
})473
.child({474
let clear_app = self.app.clone();475
control_row(476
tr("settings.help.clear_logs"),477
tr("settings.help.clear_logs_detail"),478
text_button("settings-help-clear-logs", tr("settings.help.clear_logs_button"))479
.on_click(cx.listener(move |_, _, _, cx| {480
clear_app.update(cx, |state, cx| state.clear_diagnostic_logs(cx));481
cx.notify();482
})),483
)484
})485
.child(caption(tr("settings.help.caption_paths")))486
.child(self.path_row(487
tr("settings.help.logs_path"),488
logs_path,489
"settings-help-copy-logs",490
"settings-help-open-logs-root",491
cx,492
))493
.child(self.path_row(494
tr("settings.help.bundles_path"),495
bundles_path,496
"settings-help-copy-bundles",497
"settings-help-open-bundles-root",498
cx,499
))500
.child(self.packages_section(cx))501
.child(caption(tr("settings.help.caption_actions")))502
.child(503
div()504
.text_size(px(13.))505
.text_color(theme::text_muted())506
.pb(px(8.))507
.px(px(ROW_INSET))508
.child(tr("settings.help.detail")),509
)510
.child(control_row(511
tr("settings.help.create_bundle"),512
tr("settings.help.create_bundle_detail"),513
text_button("settings-help-bundle", tr("settings.help.create_bundle_button"))514
.on_click(cx.listener(move |this, _, _, cx| {515
create_app.update(cx, |state, _| {516
match state.create_support_bundle() {517
Ok(bundle) => AppState::reveal_support_bundle(&bundle),518
Err(error) => app_base::diagnostics::record(format!(519
"support bundle: {error}"520
)),521
}522
});523
this.reload_bundles();524
cx.notify();525
})),526
))527
.child(control_row(528
tr("settings.help.open_issue"),529
tr("settings.help.open_issue_detail"),530
text_button("settings-help-issue", tr("settings.help.open_issue_button")).on_click(531
cx.listener(move |this, _, _, cx| {532
issue_app.update(cx, |state, cx| {533
if let Err(error) = state.open_github_issue_with_bundle(cx) {534
app_base::diagnostics::record(format!("support issue: {error}"));535
}536
});537
this.reload_bundles();538
cx.notify();539
}),540
),541
))542
.child(control_row(543
tr("settings.help.copy_summary"),544
tr("settings.help.copy_summary_detail"),545
text_button("settings-help-copy", tr("settings.help.copy_button")).on_click(546
move |_, _, cx| {547
cx.write_to_clipboard(ClipboardItem::new_string(copy_summary.clone()));548
},549
),550
))551
.child(control_row(552
tr("settings.help.open_logs"),553
tr("settings.help.open_logs_detail"),554
text_button("settings-help-logs", tr("common.open")).on_click(move |_, _, _| {555
AppState::reveal_logs_folder();556
}),557
))558
}559
}560
561
struct ReadPreview {562
text: String,563
truncated: bool,564
binary: bool,565
}566
567
fn read_preview_text(path: &Path) -> std::io::Result<ReadPreview> {568
use std::io::Read as _;569
let mut file = std::fs::File::open(path)?;570
let mut buf = vec![0u8; PREVIEW_LIMIT + 1];571
let read = file.read(&mut buf)?;572
let truncated = read > PREVIEW_LIMIT;573
let slice = &buf[..read.min(PREVIEW_LIMIT)];574
match std::str::from_utf8(slice) {575
Ok(text) => Ok(ReadPreview {576
text: text.to_owned(),577
truncated,578
binary: false,579
}),580
Err(_) => Ok(ReadPreview {581
text: String::new(),582
truncated: false,583
binary: true,584
}),585
}586
}587
588
impl Render for HelpView {589
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {590
let previewing = self.preview.is_some();591
v_flex()592
.w_full()593
.when(previewing, |root| root.h_full().min_h_0())594
.debug_selector(|| "settings/help".into())595
.child(if previewing {596
self.preview_panel(cx)597
} else {598
self.help_home(cx)599
})600
}601
}@@ -7,6 +7,7 @@ mod chats;
7
7
mod devices;
8
8
mod dialog;
9
9
mod general;
10
mod help;
10
11
mod mcp;
11
12
mod nav;
12
13
mod notifications;
@@ -7,6 +7,7 @@ mod chats;7
mod devices;7
mod devices;8
mod dialog;8
mod dialog;9
mod general;9
mod general;10
mod help;10
mod mcp;11
mod mcp;11
mod nav;12
mod nav;12
mod notifications;13
mod notifications;@@ -1,5 +1,5 @@
1
1
---
2
status: proposed
2
status: accepted
3
3
date: 2026-11-13
4
4
---
5
5
@@ -1,5 +1,5 @@1
---1
---2
status: proposed2
status: accepted3
date: 2026-11-133
date: 2026-11-134
---4
---5
5
@@ -1,5 +1,5 @@
1
1
---
2
status: proposed
2
status: accepted
3
3
date: 2026-11-14
4
4
---
5
5
@@ -1,5 +1,5 @@1
---1
---2
status: proposed2
status: accepted3
date: 2026-11-143
date: 2026-11-144
---4
---5
5
@@ -0,0 +1,24 @@
1
---
2
status: accepted
3
date: 2026-11-14
4
---
5
6
# ADR 0013: Local diagnostic data layout and upstream issues
7
8
## Context
9
10
Users need a place for logs and support packages that works the same way on Linux, macOS, and Windows. Paths were split across call sites with no OS table in the product specs. User-facing bug reports must point at the public upstream tracker, not at a private or Issues-disabled mirror. Opening a bug report also used to pop the file manager beside the browser, which was noisy.
11
12
Options on the table: rename the data directory away from `ms-teams-linux`, put diagnostics under roaming `data_dir` on Windows, or keep the local root name and send issues to upstream `danieldaeschle/rusty-teams`.
13
14
## Decision
15
16
Diagnostic and support artifacts live under `ProjectDirs` **local** data for the product directory name `ms-teams-linux` (legacy name kept on every OS). Layout under that root: `diagnostics.log` (+ `.1` / `.2` ring), `crash.log` (+ `.1`), `call-dumps/`, `call-reports/`, `support-bundles/support-<UTC>/`. **Debug file logging is off by default** and is toggled from Help (store key `diagnostics_enabled`) or forced with `--debug-log` / `RUSTY_TEAMS_DEBUG_LOG=1`; `crash.log` still records panics when they happen. Help shows those absolute paths. Bug reports and support README text open or name only upstream `danieldaeschle/rusty-teams`; the app does not upload and does not open the file manager by itself when filing (a notice may offer Open folder). Store/Roaming migration is not part of this decision.
17
18
## Consequences
19
20
- Developers and users can find logs and bundles from Help without guessing OS conventions.
21
- Everyday installs do not grow `diagnostics.log` until the user opts in.
22
- Existing installs keep working; no rename of `ms-teams-linux`.
23
- End-user copy never points at a fork or mirror for issues — only upstream.
24
- The SQLite store may still use a different root on Windows until a later change.
@@ -0,0 +1,24 @@1
---2
status: accepted3
date: 2026-11-144
---5
6
# ADR 0013: Local diagnostic data layout and upstream issues7
8
## Context9
10
Users need a place for logs and support packages that works the same way on Linux, macOS, and Windows. Paths were split across call sites with no OS table in the product specs. User-facing bug reports must point at the public upstream tracker, not at a private or Issues-disabled mirror. Opening a bug report also used to pop the file manager beside the browser, which was noisy.11
12
Options on the table: rename the data directory away from `ms-teams-linux`, put diagnostics under roaming `data_dir` on Windows, or keep the local root name and send issues to upstream `danieldaeschle/rusty-teams`.13
14
## Decision15
16
Diagnostic and support artifacts live under `ProjectDirs` **local** data for the product directory name `ms-teams-linux` (legacy name kept on every OS). Layout under that root: `diagnostics.log` (+ `.1` / `.2` ring), `crash.log` (+ `.1`), `call-dumps/`, `call-reports/`, `support-bundles/support-<UTC>/`. **Debug file logging is off by default** and is toggled from Help (store key `diagnostics_enabled`) or forced with `--debug-log` / `RUSTY_TEAMS_DEBUG_LOG=1`; `crash.log` still records panics when they happen. Help shows those absolute paths. Bug reports and support README text open or name only upstream `danieldaeschle/rusty-teams`; the app does not upload and does not open the file manager by itself when filing (a notice may offer Open folder). Store/Roaming migration is not part of this decision.17
18
## Consequences19
20
- Developers and users can find logs and bundles from Help without guessing OS conventions.21
- Everyday installs do not grow `diagnostics.log` until the user opts in.22
- Existing installs keep working; no rename of `ms-teams-linux`.23
- End-user copy never points at a fork or mirror for issues — only upstream.24
- The SQLite store may still use a different root on Windows until a later change.@@ -1,5 +1,5 @@
1
1
---
2
status: proposed
2
status: accepted
3
3
date: 2026-11-14
4
4
---
5
5
@@ -1,5 +1,5 @@1
---1
---2
status: proposed2
status: accepted3
date: 2026-11-143
date: 2026-11-144
---4
---5
5
@@ -28,6 +28,7 @@ Statuses: `proposed`, `accepted`, `superseded`.
28
28
| [0010](0010-preferred-external-browser.md) | Preferred browser for links and Google OAuth |
29
29
| [0011](0011-calendar-event-peek.md) | Calendar events open as a Teams-like peek |
30
30
| [0012](0012-linux-close-to-tray-closes-the-window.md) | On Linux, close to tray closes the main window |
31
| [0013](0013-local-diagnostic-data-and-upstream-issues.md) | Local diagnostic data layout and upstream issues |
31
32
| [0014](0014-linux-installs-and-updates-itself.md) | The Linux binary installs and updates itself |
32
33
33
Records `0001` to `0010` are the decisions already shipped. `0011` stays `proposed` until the calendar-peek pull request merges, `0012` to `0014` until the Linux tray and install pull request merges. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.
34
Records `0001` to `0014` are the decisions already shipped. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.
@@ -28,6 +28,7 @@ Statuses: `proposed`, `accepted`, `superseded`.28
| [0010](0010-preferred-external-browser.md) | Preferred browser for links and Google OAuth |28
| [0010](0010-preferred-external-browser.md) | Preferred browser for links and Google OAuth |29
| [0011](0011-calendar-event-peek.md) | Calendar events open as a Teams-like peek |29
| [0011](0011-calendar-event-peek.md) | Calendar events open as a Teams-like peek |30
| [0012](0012-linux-close-to-tray-closes-the-window.md) | On Linux, close to tray closes the main window |30
| [0012](0012-linux-close-to-tray-closes-the-window.md) | On Linux, close to tray closes the main window |31
| [0013](0013-local-diagnostic-data-and-upstream-issues.md) | Local diagnostic data layout and upstream issues |31
| [0014](0014-linux-installs-and-updates-itself.md) | The Linux binary installs and updates itself |32
| [0014](0014-linux-installs-and-updates-itself.md) | The Linux binary installs and updates itself |32
33
33
Records `0001` to `0010` are the decisions already shipped. `0011` stays `proposed` until the calendar-peek pull request merges, `0012` to `0014` until the Linux tray and install pull request merges. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.34
Records `0001` to `0014` are the decisions already shipped. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.