Expose instruction sources (AGENTS.md) via app server (#17506)

Addresses #17498

Problem: The TUI derived /status instruction source paths from the local
client environment, which could show stale <none> output or incorrect
paths when connected to a remote app server.

Solution: Add an app-server v2 instructionSources snapshot to thread
start/resume/fork responses, default it to an empty list when older
servers omit it, and render TUI /status from that server-provided
session data.

Additional context: The app-server field is intentionally named
instructionSources rather than AGENTS.md-specific terminology because
the loaded instruction sources can include global instructions, project
AGENTS.md files, AGENTS.override.md, user-defined instruction files, and
future dynamic sources.
This commit is contained in:
Eric Traut authored and GitHub committed 2026-04-12 15:50:12 -07:00
1 parent 470510174b
commit 46ab9974dc
23 files changed
+302 -69

No files matched your search

+7 -15
View File
@@ -942,6 +942,8 @@ pub(crate) struct ChatWidget {
current_rollout_path: Option<PathBuf>,
// Current working directory (if known)
current_cwd: Option<PathBuf>,
// Instruction source files loaded for the current session, supplied by app-server.
instruction_source_paths: Vec<PathBuf>,
// Runtime network proxy bind addresses from SessionConfigured.
session_network_proxy: Option<codex_protocol::protocol::SessionNetworkProxyRuntime>,
// Shared latch so we only warn once about invalid status-line item IDs.
@@ -2071,6 +2073,7 @@ impl ChatWidget {
}
pub(crate) fn handle_thread_session(&mut self, session: ThreadSessionState) {
self.instruction_source_paths = session.instruction_source_paths.clone();
self.on_session_configured(thread_session_state_to_legacy_event(session));
}
@@ -4865,6 +4868,7 @@ impl ChatWidget {
feedback,
current_rollout_path: None,
current_cwd,
instruction_source_paths: Vec::new(),
session_network_proxy: None,
status_line_invalid_items_warned,
terminal_title_invalid_items_warned,
@@ -7071,8 +7075,8 @@ impl ChatWidget {
.values()
.cloned()
.collect();
let config = self.config.clone();
let frame_requester = self.frame_requester.clone();
let agents_summary =
crate::status::compose_agents_summary(&self.config, &self.instruction_source_paths);
let (cell, handle) = crate::status::new_status_output_with_rate_limits_handle(
&self.config,
self.status_account_display.as_ref(),
@@ -7087,21 +7091,9 @@ impl ChatWidget {
self.model_display_name(),
collaboration_mode,
reasoning_effort_override,
"<none>".to_string(),
agents_summary,
refreshing_rate_limits,
);
let agents_summary_handle = handle.clone();
tokio::spawn(async move {
let agents_summary = match crate::status::discover_agents_summary(&config).await {
Ok(summary) => summary,
Err(err) => {
tracing::warn!(error = %err, "failed to discover project docs for /status");
"<none>".to_string()
}
};
agents_summary_handle.finish_agents_summary_discovery(agents_summary);
frame_requester.schedule_frame();
});
if let Some(request_id) = request_id {
self.refreshing_status_outputs.push((request_id, handle));
}