Include TUI client logs in diagnostic uploads (#47889)

## Why

Diagnostic uploads through the app server do not include the TUI client's diagnostic buffer. Attach those diagnostics when users consent to uploading logs.

## What changed

- Stage the most recent 1 MiB of client logs as `client-logs.txt` on the app-server host and append it to `extra_log_files`.
- Skip staging without log consent and list the optional attachment in the consent dialog.
- Continue uploading the report if staging fails, noting the omitted logs in the report reason. Attempt to remove the staging directory after both successful and failed uploads.
- Make app-server filesystem helpers usable by background requests.

## Testing

Extend submission tests to cover log truncation, preservation of existing attachments, consent gating, staging failures, cleanup after upload failure, and error display. Update consent dialog snapshots to include the client log attachment.

GitOrigin-RevId: 9790834d52772c08a147ee7c176cbbc2aa029d5f
This commit is contained in:
Eric Traut
2026-09-24 17:21:45 +00:00
committed by copyberry
parent 3d6428510f
commit b3ea9fa632
13 changed files with 199 additions and 28 deletions
+23 -11
View File
@@ -1,3 +1,5 @@
//! Filesystem RPCs on the app-server host, usable by sessions and background requests.
use super::AppServerSession;
use base64::Engine;
use base64::engine::general_purpose::STANDARD;
@@ -19,12 +21,22 @@ use color_eyre::eyre::Result;
use color_eyre::eyre::WrapErr;
use serde::de::DeserializeOwned;
use serde_json::json;
use uuid::Uuid;
impl AppServerSession {
pub(crate) async fn fs_create_directory_all_path(
&mut self,
path: &AppServerPath,
) -> Result<()> {
pub(crate) fn file_system(&self) -> AppServerFileSystem {
AppServerFileSystem {
request_handle: self.request_handle(),
}
}
}
pub(crate) struct AppServerFileSystem {
pub(crate) request_handle: AppServerRequestHandle,
}
impl AppServerFileSystem {
pub(crate) async fn fs_create_directory_all_path(&self, path: &AppServerPath) -> Result<()> {
self.request_fs_path::<FsCreateDirectoryResponse>(
"fs/createDirectory",
path,
@@ -42,7 +54,7 @@ impl AppServerSession {
}
pub(crate) async fn fs_write_file_path(
&mut self,
&self,
path: &AppServerPath,
bytes: Vec<u8>,
) -> Result<()> {
@@ -63,7 +75,7 @@ impl AppServerSession {
.map(drop)
}
pub(crate) async fn fs_read_file_path(&mut self, path: &AppServerPath) -> Result<Vec<u8>> {
pub(crate) async fn fs_read_file_path(&self, path: &AppServerPath) -> Result<Vec<u8>> {
let response: FsReadFileResponse = self
.request_fs_path(
"fs/readFile",
@@ -80,7 +92,7 @@ impl AppServerSession {
.wrap_err("fs/readFile returned invalid base64 data")
}
pub(crate) async fn fs_remove_path(&mut self, path: &AppServerPath) -> Result<()> {
pub(crate) async fn fs_remove_path(&self, path: &AppServerPath) -> Result<()> {
self.request_fs_path::<FsRemoveResponse>(
"fs/remove",
path,
@@ -99,14 +111,14 @@ impl AppServerSession {
}
async fn request_fs_path<T: DeserializeOwned>(
&mut self,
&self,
method: &str,
path: &AppServerPath,
local_request: impl FnOnce(RequestId, AbsolutePathBuf) -> ClientRequest,
remote_params: impl FnOnce() -> serde_json::Value,
) -> Result<T> {
let request_id = self.next_request_id();
match self.request_handle() {
let request_id = RequestId::String(format!("tui-fs-{}", Uuid::new_v4()));
match &self.request_handle {
AppServerRequestHandle::Remote(handle) => {
let response = handle
.request_json_rpc(JSONRPCRequest {
@@ -125,7 +137,7 @@ impl AppServerSession {
AppServerRequestHandle::InProcess(_) => {
let path = AbsolutePathBuf::from_absolute_path_checked(path.as_str())
.wrap_err_with(|| format!("invalid local app-server fs path {path}"))?;
self.client
self.request_handle
.request_typed(local_request(request_id, path))
.await
.wrap_err_with(|| format!("{method} failed in TUI"))