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
+4 -12
View File
@@ -4,6 +4,7 @@
//! limits, add-credit nudges, and feedback uploads. Results are routed back through `AppEvent` so
//! the main event loop remains single-threaded.
use super::feedback_upload::fetch_feedback_upload;
use super::plugin_mentions::fetch_plugin_mentions;
use super::*;
use crate::app_event::ConnectorsSnapshot;
@@ -604,8 +605,10 @@ impl App {
turn_id,
include_logs,
);
let codex_home = app_server.codex_home_path(&self.config.codex_home);
let feedback = self.feedback.clone();
tokio::spawn(async move {
let result = fetch_feedback_upload(request_handle, params)
let result = fetch_feedback_upload(request_handle, codex_home, params, feedback)
.await
.map(|response| response.thread_id)
.map_err(|err| err.to_string());
@@ -1278,17 +1281,6 @@ pub(super) fn build_feedback_upload_params(
}
}
pub(super) async fn fetch_feedback_upload(
request_handle: AppServerRequestHandle,
params: FeedbackUploadParams,
) -> Result<FeedbackUploadResponse> {
let request_id = RequestId::String(format!("feedback-upload-{}", Uuid::new_v4()));
request_handle
.request_typed(ClientRequest::FeedbackUpload { request_id, params })
.await
.wrap_err("feedback/upload failed in TUI")
}
/// Convert flat `McpServerStatus` responses into the per-server maps used by the
/// in-process MCP subsystem (tools keyed as `mcp__{server}__{tool}`, plus
/// per-server resource/template/auth maps). Test-only because the TUI