cxstatusline 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE +17 -0
- package/README.md +169 -0
- package/THIRD_PARTY_NOTICES.md +62 -0
- package/dist/THIRD_PARTY_LICENSES.txt +888 -0
- package/dist/cxstatusline.js +65110 -0
- package/package.json +51 -0
- package/patches/codex-0.152.1.patch +1482 -0
- package/patches/codex-0.153.0.patch +1482 -0
- package/patches/codex-0.153.4.patch +1482 -0
- package/patches/ink@6.2.0.patch +17 -0
- package/patches/manifest.json +10 -0
|
@@ -0,0 +1,1482 @@
|
|
|
1
|
+
diff --git a/codex-rs/tui/src/app/background_requests.rs b/codex-rs/tui/src/app/background_requests.rs
|
|
2
|
+
index c39f5c6375..d3dca48255 100644
|
|
3
|
+
--- a/codex-rs/tui/src/app/background_requests.rs
|
|
4
|
+
+++ b/codex-rs/tui/src/app/background_requests.rs
|
|
5
|
+
@@ -100,7 +100,8 @@ impl App {
|
|
6
|
+
let result = match origin {
|
|
7
|
+
RateLimitRefreshOrigin::Recovery
|
|
8
|
+
| RateLimitRefreshOrigin::ResetConsume { .. }
|
|
9
|
+
- | RateLimitRefreshOrigin::ResetPicker { .. } => {
|
|
10
|
+
+ | RateLimitRefreshOrigin::ResetPicker { .. }
|
|
11
|
+
+ | RateLimitRefreshOrigin::CxStatusLine => {
|
|
12
|
+
tokio::time::timeout(RATE_LIMIT_RESET_REQUEST_TIMEOUT, request)
|
|
13
|
+
.await
|
|
14
|
+
.map_err(|_| "account/rateLimits/read timed out in TUI".to_string())
|
|
15
|
+
@@ -1351,7 +1352,75 @@ mod tests {
|
|
16
|
+
use codex_config::types::AuthCredentialsStoreMode;
|
|
17
|
+
use codex_protocol::mcp::Tool;
|
|
18
|
+
use codex_utils_absolute_path::AbsolutePathBuf;
|
|
19
|
+
+ use codex_utils_absolute_path::test_support::PathExt;
|
|
20
|
+
use pretty_assertions::assert_eq;
|
|
21
|
+
+ use tempfile::tempdir;
|
|
22
|
+
+ use wiremock::Mock;
|
|
23
|
+
+ use wiremock::MockServer;
|
|
24
|
+
+ use wiremock::ResponseTemplate;
|
|
25
|
+
+ use wiremock::matchers::method;
|
|
26
|
+
+ use wiremock::matchers::path;
|
|
27
|
+
+
|
|
28
|
+
+ #[tokio::test(flavor = "current_thread")]
|
|
29
|
+
+ async fn cxstatusline_rate_limit_request_times_out() -> Result<()> {
|
|
30
|
+
+ let mut app = make_test_app().await;
|
|
31
|
+
+ let server = MockServer::start().await;
|
|
32
|
+
+ let home = tempdir()?;
|
|
33
|
+
+ app.config.codex_home = home.path().to_path_buf().abs();
|
|
34
|
+
+ app.config.chatgpt_base_url = server.uri();
|
|
35
|
+
+ app.config.cli_auth_credentials_store_mode = AuthCredentialsStoreMode::File;
|
|
36
|
+
+ app.config.sqlite = codex_state::SqliteConfig::new_for_testing(home.path().abs());
|
|
37
|
+
+ write_chatgpt_auth(
|
|
38
|
+
+ home.path(),
|
|
39
|
+
+ ChatGptAuthFixture::new("chatgpt-token").account_id("account-123"),
|
|
40
|
+
+ AuthCredentialsStoreMode::File,
|
|
41
|
+
+ )
|
|
42
|
+
+ .expect("write ChatGPT authentication");
|
|
43
|
+
+ Mock::given(method("GET"))
|
|
44
|
+
+ .and(path("/api/codex/usage"))
|
|
45
|
+
+ .respond_with(ResponseTemplate::new(/*status_code*/ 200).set_delay(
|
|
46
|
+
+ RATE_LIMIT_RESET_REQUEST_TIMEOUT + std::time::Duration::from_secs(/*secs*/ 1),
|
|
47
|
+
+ ))
|
|
48
|
+
+ .expect(/*requests*/ 1)
|
|
49
|
+
+ .mount(&server)
|
|
50
|
+
+ .await;
|
|
51
|
+
+ let app_server = crate::start_embedded_app_server_for_picker(&app.config).await?;
|
|
52
|
+
+ let (app_event_tx, mut app_events) = tokio::sync::mpsc::unbounded_channel();
|
|
53
|
+
+ app.app_event_tx = AppEventSender::new(app_event_tx);
|
|
54
|
+
+
|
|
55
|
+
+ app.refresh_rate_limits(&app_server, RateLimitRefreshOrigin::CxStatusLine);
|
|
56
|
+
+ tokio::time::timeout(std::time::Duration::from_secs(/*secs*/ 5), async {
|
|
57
|
+
+ loop {
|
|
58
|
+
+ if server.received_requests().await.is_some_and(|requests| {
|
|
59
|
+
+ requests
|
|
60
|
+
+ .iter()
|
|
61
|
+
+ .any(|request| request.url.path() == "/api/codex/usage")
|
|
62
|
+
+ }) {
|
|
63
|
+
+ return;
|
|
64
|
+
+ }
|
|
65
|
+
+ tokio::time::sleep(std::time::Duration::from_millis(/*millis*/ 10)).await;
|
|
66
|
+
+ }
|
|
67
|
+
+ })
|
|
68
|
+
+ .await
|
|
69
|
+
+ .expect("cxstatusline request reaches the usage endpoint");
|
|
70
|
+
+
|
|
71
|
+
+ tokio::time::pause();
|
|
72
|
+
+ tokio::time::advance(RATE_LIMIT_RESET_REQUEST_TIMEOUT).await;
|
|
73
|
+
+ tokio::task::yield_now().await;
|
|
74
|
+
+
|
|
75
|
+
+ assert!(matches!(
|
|
76
|
+
+ app_events.try_recv(),
|
|
77
|
+
+ Ok(AppEvent::RateLimitsLoaded {
|
|
78
|
+
+ origin: RateLimitRefreshOrigin::CxStatusLine,
|
|
79
|
+
+ result: Err(ref error),
|
|
80
|
+
+ ..
|
|
81
|
+
+ }) if error == "account/rateLimits/read timed out in TUI"
|
|
82
|
+
+ ));
|
|
83
|
+
+
|
|
84
|
+
+ app_server.shutdown().await?;
|
|
85
|
+
+ server.verify().await;
|
|
86
|
+
+ Ok(())
|
|
87
|
+
+ }
|
|
88
|
+
|
|
89
|
+
#[tokio::test]
|
|
90
|
+
async fn fetch_thread_usage_uses_app_server_auth_after_persisted_account_changes() {
|
|
91
|
+
diff --git a/codex-rs/tui/src/app/event_dispatch.rs b/codex-rs/tui/src/app/event_dispatch.rs
|
|
92
|
+
index 055612ef0b..597ee79b32 100644
|
|
93
|
+
--- a/codex-rs/tui/src/app/event_dispatch.rs
|
|
94
|
+
+++ b/codex-rs/tui/src/app/event_dispatch.rs
|
|
95
|
+
@@ -1338,6 +1338,13 @@ impl App {
|
|
96
|
+
}),
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
+ RateLimitRefreshOrigin::CxStatusLine => {
|
|
100
|
+
+ self.chat_widget.finish_cxstatusline_rate_limit_refresh();
|
|
101
|
+
+ for snapshot in snapshots {
|
|
102
|
+
+ self.chat_widget.on_rate_limit_snapshot(Some(snapshot));
|
|
103
|
+
+ }
|
|
104
|
+
+ tui.frame_requester().schedule_frame();
|
|
105
|
+
+ }
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
Err(err) => {
|
|
109
|
+
@@ -1379,6 +1386,10 @@ impl App {
|
|
110
|
+
Err(err),
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
+ RateLimitRefreshOrigin::CxStatusLine => {
|
|
114
|
+
+ self.chat_widget.finish_cxstatusline_rate_limit_refresh();
|
|
115
|
+
+ tui.frame_requester().schedule_frame();
|
|
116
|
+
+ }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
diff --git a/codex-rs/tui/src/app/tests/rate_limits.rs b/codex-rs/tui/src/app/tests/rate_limits.rs
|
|
121
|
+
index 171c6d9eef..76069c9827 100644
|
|
122
|
+
--- a/codex-rs/tui/src/app/tests/rate_limits.rs
|
|
123
|
+
+++ b/codex-rs/tui/src/app/tests/rate_limits.rs
|
|
124
|
+
@@ -214,6 +214,7 @@ async fn stale_rate_limit_reads_preserve_newer_workspace_hard_stop_for_every_ori
|
|
125
|
+
"usage",
|
|
126
|
+
"reset-picker",
|
|
127
|
+
"reset-consume",
|
|
128
|
+
+ "cxstatusline",
|
|
129
|
+
] {
|
|
130
|
+
let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
|
|
131
|
+
set_chatgpt_auth(&mut app.chat_widget);
|
|
132
|
+
@@ -262,6 +263,7 @@ async fn stale_rate_limit_reads_preserve_newer_workspace_hard_stop_for_every_ori
|
|
133
|
+
"reset-consume" => RateLimitRefreshOrigin::ResetConsume {
|
|
134
|
+
request_id: app.chat_widget.show_rate_limit_reset_consuming_popup(),
|
|
135
|
+
},
|
|
136
|
+
+ "cxstatusline" => RateLimitRefreshOrigin::CxStatusLine,
|
|
137
|
+
_ => unreachable!("unknown refresh origin"),
|
|
138
|
+
};
|
|
139
|
+
let read_generation = app.rate_limit_hard_stop_generation;
|
|
140
|
+
@@ -302,7 +304,7 @@ async fn stale_rate_limit_reads_preserve_newer_workspace_hard_stop_for_every_ori
|
|
141
|
+
"reset-consume" => {
|
|
142
|
+
assert!(popup.contains("Usage reset. You have 0 usage limit resets left."));
|
|
143
|
+
}
|
|
144
|
+
- "startup" | "status" => {}
|
|
145
|
+
+ "startup" | "status" | "cxstatusline" => {}
|
|
146
|
+
_ => unreachable!("unknown refresh origin"),
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@@ -478,6 +480,97 @@ async fn failed_rate_limit_read_preserves_visible_backend_banner() -> Result<()>
|
|
150
|
+
Ok(())
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
+#[tokio::test]
|
|
154
|
+
+async fn cxstatusline_rate_limit_refresh_updates_snapshots_without_status_card() -> Result<()> {
|
|
155
|
+
+ let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
|
|
156
|
+
+ set_chatgpt_auth(&mut app.chat_widget);
|
|
157
|
+
+ let mut tui = crate::tui::test_support::make_test_tui()?;
|
|
158
|
+
+ let mut app_server = Box::pin(crate::start_embedded_app_server_for_picker(
|
|
159
|
+
+ app.chat_widget.config_ref(),
|
|
160
|
+
+ ))
|
|
161
|
+
+ .await?;
|
|
162
|
+
+ let (request_id, hard_stop_generation) = app
|
|
163
|
+
+ .rate_limit_refresh_state
|
|
164
|
+
+ .start(
|
|
165
|
+
+ RateLimitRefreshOrigin::CxStatusLine,
|
|
166
|
+
+ &mut app.rate_limit_hard_stop_generation,
|
|
167
|
+
+ )
|
|
168
|
+
+ .expect("cxstatusline refresh starts");
|
|
169
|
+
+
|
|
170
|
+
+ app.handle_event(
|
|
171
|
+
+ &mut tui,
|
|
172
|
+
+ &mut app_server,
|
|
173
|
+
+ AppEvent::RateLimitsLoaded {
|
|
174
|
+
+ request_id,
|
|
175
|
+
+ origin: RateLimitRefreshOrigin::CxStatusLine,
|
|
176
|
+
+ hard_stop_generation,
|
|
177
|
+
+ result: Ok(account_rate_limits_response(rate_limit_snapshot(
|
|
178
|
+
+ /*used_percent*/ 89, /*rate_limit_reached_type*/ None,
|
|
179
|
+
+ /*spend_control_reached*/ None,
|
|
180
|
+
+ ))),
|
|
181
|
+
+ },
|
|
182
|
+
+ )
|
|
183
|
+
+ .await?;
|
|
184
|
+
+
|
|
185
|
+
+ assert!(
|
|
186
|
+
+ !std::iter::from_fn(|| app_event_rx.try_recv().ok())
|
|
187
|
+
+ .any(|event| matches!(event, AppEvent::InsertHistoryCell(_))),
|
|
188
|
+
+ "cxstatusline refresh must not create a status card"
|
|
189
|
+
+ );
|
|
190
|
+
+ let status = render_status_output(&mut app, &mut app_event_rx);
|
|
191
|
+
+ assert!(
|
|
192
|
+
+ status.contains("11% left"),
|
|
193
|
+
+ "expected cxstatusline refresh to update cached limits, got: {status}"
|
|
194
|
+
+ );
|
|
195
|
+
+
|
|
196
|
+
+ app_server.shutdown().await?;
|
|
197
|
+
+ Ok(())
|
|
198
|
+
+}
|
|
199
|
+
+
|
|
200
|
+
+#[tokio::test]
|
|
201
|
+
+async fn cxstatusline_rate_limit_refresh_failure_preserves_last_snapshot() -> Result<()> {
|
|
202
|
+
+ let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
|
|
203
|
+
+ set_chatgpt_auth(&mut app.chat_widget);
|
|
204
|
+
+ app.chat_widget
|
|
205
|
+
+ .on_rate_limit_snapshot(Some(rate_limit_snapshot(
|
|
206
|
+
+ /*used_percent*/ 89, /*rate_limit_reached_type*/ None,
|
|
207
|
+
+ /*spend_control_reached*/ None,
|
|
208
|
+
+ )));
|
|
209
|
+
+ let mut tui = crate::tui::test_support::make_test_tui()?;
|
|
210
|
+
+ let mut app_server = Box::pin(crate::start_embedded_app_server_for_picker(
|
|
211
|
+
+ app.chat_widget.config_ref(),
|
|
212
|
+
+ ))
|
|
213
|
+
+ .await?;
|
|
214
|
+
+ let (request_id, hard_stop_generation) = app
|
|
215
|
+
+ .rate_limit_refresh_state
|
|
216
|
+
+ .start(
|
|
217
|
+
+ RateLimitRefreshOrigin::CxStatusLine,
|
|
218
|
+
+ &mut app.rate_limit_hard_stop_generation,
|
|
219
|
+
+ )
|
|
220
|
+
+ .expect("cxstatusline refresh starts");
|
|
221
|
+
+
|
|
222
|
+
+ app.handle_event(
|
|
223
|
+
+ &mut tui,
|
|
224
|
+
+ &mut app_server,
|
|
225
|
+
+ AppEvent::RateLimitsLoaded {
|
|
226
|
+
+ request_id,
|
|
227
|
+
+ origin: RateLimitRefreshOrigin::CxStatusLine,
|
|
228
|
+
+ hard_stop_generation,
|
|
229
|
+
+ result: Err("offline".to_string()),
|
|
230
|
+
+ },
|
|
231
|
+
+ )
|
|
232
|
+
+ .await?;
|
|
233
|
+
+
|
|
234
|
+
+ let status = render_status_output(&mut app, &mut app_event_rx);
|
|
235
|
+
+ assert!(
|
|
236
|
+
+ status.contains("11% left"),
|
|
237
|
+
+ "expected failed cxstatusline refresh to preserve cached limits, got: {status}"
|
|
238
|
+
+ );
|
|
239
|
+
+
|
|
240
|
+
+ app_server.shutdown().await?;
|
|
241
|
+
+ Ok(())
|
|
242
|
+
+}
|
|
243
|
+
+
|
|
244
|
+
#[tokio::test]
|
|
245
|
+
async fn backend_banner_reads_ignore_older_completions() -> Result<()> {
|
|
246
|
+
let (mut app, _events, _ops) = make_test_app_with_channels().await;
|
|
247
|
+
diff --git a/codex-rs/tui/src/app_event.rs b/codex-rs/tui/src/app_event.rs
|
|
248
|
+
index bb5b57aa3d..e80016a6e7 100644
|
|
249
|
+
--- a/codex-rs/tui/src/app_event.rs
|
|
250
|
+
+++ b/codex-rs/tui/src/app_event.rs
|
|
251
|
+
@@ -160,6 +160,8 @@ pub(crate) struct PluginRemoteSectionError {
|
|
252
|
+
/// zero reset count so the disabled menu entry can become available without a
|
|
253
|
+
/// restart. A `ResetPicker` refreshes the rate limits and detailed reset-credit
|
|
254
|
+
/// rows before showing redemption choices.
|
|
255
|
+
+/// A `CxStatusLine` refresh updates the renderer payload without creating a
|
|
256
|
+
+/// status card or changing reset-credit state.
|
|
257
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
258
|
+
pub(crate) enum RateLimitRefreshOrigin {
|
|
259
|
+
/// Eagerly fetched after bootstrap for `/status` data and reset availability.
|
|
260
|
+
@@ -175,6 +177,8 @@ pub(crate) enum RateLimitRefreshOrigin {
|
|
261
|
+
ResetConsume { request_id: u64 },
|
|
262
|
+
/// Refresh backend recovery after an inference limit error.
|
|
263
|
+
Recovery,
|
|
264
|
+
+ /// Periodically refresh the `CXSTATUSLINE_COMMAND` renderer payload.
|
|
265
|
+
+ CxStatusLine,
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
269
|
+
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs
|
|
270
|
+
index e14a52a3a0..06e69c20b0 100644
|
|
271
|
+
--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs
|
|
272
|
+
+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs
|
|
273
|
+
@@ -249,6 +249,7 @@ use super::footer::inset_footer_hint_area;
|
|
274
|
+
use super::footer::max_left_width_for_right;
|
|
275
|
+
use super::footer::passive_footer_status_line;
|
|
276
|
+
use super::footer::render_context_right;
|
|
277
|
+
+use super::footer::render_cxstatusline_block;
|
|
278
|
+
use super::footer::render_footer_from_props;
|
|
279
|
+
use super::footer::render_footer_hint_items;
|
|
280
|
+
use super::footer::render_footer_line;
|
|
281
|
+
@@ -648,6 +649,7 @@ impl ChatComposer {
|
|
282
|
+
status_line_value: None,
|
|
283
|
+
status_line_hyperlink_url: None,
|
|
284
|
+
status_line_enabled: false,
|
|
285
|
+
+ cxstatusline_block: Vec::new(),
|
|
286
|
+
side_conversation_context_label: None,
|
|
287
|
+
active_agent_label: None,
|
|
288
|
+
external_editor_key: default_keymap
|
|
289
|
+
@@ -1006,9 +1008,7 @@ impl ChatComposer {
|
|
290
|
+
textarea_right_reserve: u16,
|
|
291
|
+
) -> [Rect; 4] {
|
|
292
|
+
let footer_props = self.footer_props();
|
|
293
|
+
- let footer_hint_height = self
|
|
294
|
+
- .custom_footer_height()
|
|
295
|
+
- .unwrap_or_else(|| footer_height(&footer_props));
|
|
296
|
+
+ let footer_hint_height = self.footer_hint_height(&footer_props);
|
|
297
|
+
let footer_spacing = Self::footer_spacing(footer_hint_height);
|
|
298
|
+
let footer_total_height = footer_hint_height + footer_spacing;
|
|
299
|
+
let popup_constraint = match &self.popups.active {
|
|
300
|
+
@@ -3839,6 +3839,7 @@ impl ChatComposer {
|
|
301
|
+
is_wsl,
|
|
302
|
+
status_line_value: self.footer.status_line_value.clone(),
|
|
303
|
+
status_line_enabled: self.footer.status_line_enabled,
|
|
304
|
+
+ cxstatusline_block: self.footer.cxstatusline_block.clone(),
|
|
305
|
+
key_hints: FooterKeyHints {
|
|
306
|
+
toggle_shortcuts: self.footer.toggle_shortcuts_key,
|
|
307
|
+
queue: self.footer.queue_key,
|
|
308
|
+
@@ -3898,6 +3899,12 @@ impl ChatComposer {
|
|
309
|
+
.map(|items| if items.is_empty() { 0 } else { 1 })
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
+ fn footer_hint_height(&self, props: &FooterProps) -> u16 {
|
|
313
|
+
+ self.custom_footer_height()
|
|
314
|
+
+ .map(|height| height.saturating_add(props.cxstatusline_block.len() as u16))
|
|
315
|
+
+ .unwrap_or_else(|| footer_height(props))
|
|
316
|
+
+ }
|
|
317
|
+
+
|
|
318
|
+
pub(crate) fn sync_popups(&mut self) {
|
|
319
|
+
self.sync_slash_command_elements();
|
|
320
|
+
if self.history_search.is_some() || self.draft.textarea.vim_query().is_some() {
|
|
321
|
+
@@ -4392,6 +4399,14 @@ impl ChatComposer {
|
|
322
|
+
true
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
+ pub(crate) fn set_cxstatusline_block(&mut self, block: Vec<Line<'static>>) -> bool {
|
|
326
|
+
+ if self.footer.cxstatusline_block == block {
|
|
327
|
+
+ return false;
|
|
328
|
+
+ }
|
|
329
|
+
+ self.footer.cxstatusline_block = block;
|
|
330
|
+
+ true
|
|
331
|
+
+ }
|
|
332
|
+
+
|
|
333
|
+
pub(crate) fn set_side_conversation_context_label(&mut self, label: Option<String>) -> bool {
|
|
334
|
+
if self.footer.side_conversation_context_label == label {
|
|
335
|
+
return false;
|
|
336
|
+
@@ -4560,9 +4575,7 @@ impl ChatComposer {
|
|
337
|
+
textarea_right_reserve: u16,
|
|
338
|
+
) -> u16 {
|
|
339
|
+
let footer_props = self.footer_props();
|
|
340
|
+
- let footer_hint_height = self
|
|
341
|
+
- .custom_footer_height()
|
|
342
|
+
- .unwrap_or_else(|| footer_height(&footer_props));
|
|
343
|
+
+ let footer_hint_height = self.footer_hint_height(&footer_props);
|
|
344
|
+
let footer_spacing = Self::footer_spacing(footer_hint_height);
|
|
345
|
+
let footer_total_height = footer_hint_height + footer_spacing;
|
|
346
|
+
const COLS_WITH_MARGIN: u16 = LIVE_PREFIX_COLS + 1;
|
|
347
|
+
@@ -4638,9 +4651,7 @@ impl ChatComposer {
|
|
348
|
+
| FooterMode::ShortcutOverlay
|
|
349
|
+
| FooterMode::EscHint => false,
|
|
350
|
+
};
|
|
351
|
+
- let custom_height = self.custom_footer_height();
|
|
352
|
+
- let footer_hint_height =
|
|
353
|
+
- custom_height.unwrap_or_else(|| footer_height(&footer_props));
|
|
354
|
+
+ let footer_hint_height = self.footer_hint_height(&footer_props);
|
|
355
|
+
let footer_spacing = Self::footer_spacing(footer_hint_height);
|
|
356
|
+
let hint_rect = if footer_spacing > 0 && footer_hint_height > 0 {
|
|
357
|
+
let [_, hint_rect] = Layout::vertical([
|
|
358
|
+
@@ -4652,6 +4663,26 @@ impl ChatComposer {
|
|
359
|
+
} else {
|
|
360
|
+
popup_rect
|
|
361
|
+
};
|
|
362
|
+
+ let cxstatusline_height =
|
|
363
|
+
+ (footer_props.cxstatusline_block.len() as u16).min(hint_rect.height);
|
|
364
|
+
+ if cxstatusline_height > 0 {
|
|
365
|
+
+ render_cxstatusline_block(
|
|
366
|
+
+ Rect::new(
|
|
367
|
+
+ hint_rect.x,
|
|
368
|
+
+ hint_rect.y,
|
|
369
|
+
+ hint_rect.width,
|
|
370
|
+
+ cxstatusline_height,
|
|
371
|
+
+ ),
|
|
372
|
+
+ buf,
|
|
373
|
+
+ &footer_props.cxstatusline_block,
|
|
374
|
+
+ );
|
|
375
|
+
+ }
|
|
376
|
+
+ let hint_rect = Rect::new(
|
|
377
|
+
+ hint_rect.x,
|
|
378
|
+
+ hint_rect.y.saturating_add(cxstatusline_height),
|
|
379
|
+
+ hint_rect.width,
|
|
380
|
+
+ hint_rect.height.saturating_sub(cxstatusline_height),
|
|
381
|
+
+ );
|
|
382
|
+
if let Some(input) = self.draft.textarea.vim_query() {
|
|
383
|
+
input.render(inset_footer_hint_area(hint_rect), buf);
|
|
384
|
+
} else if let Some(line) = self.history_search_footer_line() {
|
|
385
|
+
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/footer_state.rs b/codex-rs/tui/src/bottom_pane/chat_composer/footer_state.rs
|
|
386
|
+
index 09ceb5fc68..f03c0dc814 100644
|
|
387
|
+
--- a/codex-rs/tui/src/bottom_pane/chat_composer/footer_state.rs
|
|
388
|
+
+++ b/codex-rs/tui/src/bottom_pane/chat_composer/footer_state.rs
|
|
389
|
+
@@ -29,6 +29,7 @@ pub(super) struct FooterState {
|
|
390
|
+
pub(super) status_line_value: Option<Line<'static>>,
|
|
391
|
+
pub(super) status_line_hyperlink_url: Option<String>,
|
|
392
|
+
pub(super) status_line_enabled: bool,
|
|
393
|
+
+ pub(super) cxstatusline_block: Vec<Line<'static>>,
|
|
394
|
+
pub(super) side_conversation_context_label: Option<String>,
|
|
395
|
+
pub(super) active_agent_label: Option<String>,
|
|
396
|
+
pub(super) external_editor_key: Option<ShortcutHint>,
|
|
397
|
+
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/history_search.rs b/codex-rs/tui/src/bottom_pane/chat_composer/history_search.rs
|
|
398
|
+
index a79a10a362..6a3cf11563 100644
|
|
399
|
+
--- a/codex-rs/tui/src/bottom_pane/chat_composer/history_search.rs
|
|
400
|
+
+++ b/codex-rs/tui/src/bottom_pane/chat_composer/history_search.rs
|
|
401
|
+
@@ -33,7 +33,6 @@ use ratatui::text::Span;
|
|
402
|
+
|
|
403
|
+
use super::super::chat_composer_history::HistorySearchDirection;
|
|
404
|
+
use super::super::chat_composer_history::HistorySearchResult;
|
|
405
|
+
-use super::super::footer::footer_height;
|
|
406
|
+
use super::super::footer::reset_mode_after_activity;
|
|
407
|
+
use super::ActivePopup;
|
|
408
|
+
use super::ChatComposer;
|
|
409
|
+
@@ -452,9 +451,7 @@ impl ChatComposer {
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
let footer_props = self.footer_props();
|
|
413
|
+
- let footer_hint_height = self
|
|
414
|
+
- .custom_footer_height()
|
|
415
|
+
- .unwrap_or_else(|| footer_height(&footer_props));
|
|
416
|
+
+ let footer_hint_height = self.footer_hint_height(&footer_props);
|
|
417
|
+
let footer_spacing = Self::footer_spacing(footer_hint_height);
|
|
418
|
+
let hint_rect = if footer_spacing > 0 && footer_hint_height > 0 {
|
|
419
|
+
let [_, hint_rect] = Layout::vertical([
|
|
420
|
+
@@ -466,6 +463,16 @@ impl ChatComposer {
|
|
421
|
+
} else {
|
|
422
|
+
popup_rect
|
|
423
|
+
};
|
|
424
|
+
+ let hint_rect = Rect::new(
|
|
425
|
+
+ hint_rect.x,
|
|
426
|
+
+ hint_rect
|
|
427
|
+
+ .y
|
|
428
|
+
+ .saturating_add(footer_props.cxstatusline_block.len() as u16),
|
|
429
|
+
+ hint_rect.width,
|
|
430
|
+
+ hint_rect
|
|
431
|
+
+ .height
|
|
432
|
+
+ .saturating_sub(footer_props.cxstatusline_block.len() as u16),
|
|
433
|
+
+ );
|
|
434
|
+
if hint_rect.is_empty() {
|
|
435
|
+
return None;
|
|
436
|
+
}
|
|
437
|
+
diff --git a/codex-rs/tui/src/bottom_pane/footer.rs b/codex-rs/tui/src/bottom_pane/footer.rs
|
|
438
|
+
index 06eda95148..003fcc5cff 100644
|
|
439
|
+
--- a/codex-rs/tui/src/bottom_pane/footer.rs
|
|
440
|
+
+++ b/codex-rs/tui/src/bottom_pane/footer.rs
|
|
441
|
+
@@ -78,6 +78,9 @@ pub(crate) struct FooterProps {
|
|
442
|
+
pub(crate) quit_shortcut_key: KeyBinding,
|
|
443
|
+
pub(crate) status_line_value: Option<Line<'static>>,
|
|
444
|
+
pub(crate) status_line_enabled: bool,
|
|
445
|
+
+ /// Complete renderer-owned rows kept separate from Codex's contextual status line so native
|
|
446
|
+
+ /// instructions (Esc, quit, safety) remain visible below them.
|
|
447
|
+
+ pub(crate) cxstatusline_block: Vec<Line<'static>>,
|
|
448
|
+
pub(crate) key_hints: FooterKeyHints,
|
|
449
|
+
/// Active thread label shown when the footer is rendering contextual information instead of an
|
|
450
|
+
/// instructional hint.
|
|
451
|
+
@@ -235,14 +238,15 @@ pub(crate) fn footer_height(props: &FooterProps) -> u16 {
|
|
452
|
+
| FooterMode::ShortcutOverlay
|
|
453
|
+
| FooterMode::EscHint => false,
|
|
454
|
+
};
|
|
455
|
+
- footer_from_props_lines(
|
|
456
|
+
- props,
|
|
457
|
+
- /*collaboration_mode_indicator*/ None,
|
|
458
|
+
- /*show_cycle_hint*/ false,
|
|
459
|
+
- show_shortcuts_hint,
|
|
460
|
+
- show_queue_hint,
|
|
461
|
+
- )
|
|
462
|
+
- .len() as u16
|
|
463
|
+
+ props.cxstatusline_block.len() as u16
|
|
464
|
+
+ + footer_from_props_lines(
|
|
465
|
+
+ props,
|
|
466
|
+
+ /*collaboration_mode_indicator*/ None,
|
|
467
|
+
+ /*show_cycle_hint*/ false,
|
|
468
|
+
+ show_shortcuts_hint,
|
|
469
|
+
+ show_queue_hint,
|
|
470
|
+
+ )
|
|
471
|
+
+ .len() as u16
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/// Render a single precomputed footer line.
|
|
475
|
+
@@ -255,6 +259,16 @@ pub(crate) fn render_footer_line(area: Rect, buf: &mut Buffer, line: Line<'stati
|
|
476
|
+
.render(area, buf);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
+/// Render renderer-owned rows above the native footer content.
|
|
480
|
+
+pub(crate) fn render_cxstatusline_block(area: Rect, buf: &mut Buffer, block: &[Line<'static>]) {
|
|
481
|
+
+ Paragraph::new(prefix_lines(
|
|
482
|
+
+ block.to_vec(),
|
|
483
|
+
+ " ".repeat(FOOTER_INDENT_COLS).into(),
|
|
484
|
+
+ " ".repeat(FOOTER_INDENT_COLS).into(),
|
|
485
|
+
+ ))
|
|
486
|
+
+ .render(area, buf);
|
|
487
|
+
+}
|
|
488
|
+
+
|
|
489
|
+
/// Render footer content directly from `FooterProps`.
|
|
490
|
+
///
|
|
491
|
+
/// This is intentionally not part of the width-based collapse/fallback logic.
|
|
492
|
+
@@ -1279,12 +1293,50 @@ mod tests {
|
|
493
|
+
use ratatui::backend::Backend;
|
|
494
|
+
use ratatui::backend::TestBackend;
|
|
495
|
+
|
|
496
|
+
+ fn props_with_status_block(rows: usize, mode: FooterMode) -> FooterProps {
|
|
497
|
+
+ FooterProps {
|
|
498
|
+
+ mode,
|
|
499
|
+
+ esc_backtrack_hint: false,
|
|
500
|
+
+ use_shift_enter_hint: false,
|
|
501
|
+
+ is_task_running: false,
|
|
502
|
+
+ queue_submissions: false,
|
|
503
|
+
+ collaboration_modes_enabled: false,
|
|
504
|
+
+ is_wsl: false,
|
|
505
|
+
+ quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
506
|
+
+ status_line_value: None,
|
|
507
|
+
+ status_line_enabled: false,
|
|
508
|
+
+ cxstatusline_block: (0..rows)
|
|
509
|
+
+ .map(|row| Line::from(format!("status-{row}")))
|
|
510
|
+
+ .collect(),
|
|
511
|
+
+ key_hints: FooterKeyHints::default_bindings(),
|
|
512
|
+
+ active_agent_label: None,
|
|
513
|
+
+ }
|
|
514
|
+
+ }
|
|
515
|
+
+
|
|
516
|
+
fn snapshot_footer(name: &str, props: FooterProps) {
|
|
517
|
+
snapshot_footer_with_mode_indicator(
|
|
518
|
+
name, /*width*/ 80, &props, /*collaboration_mode_indicator*/ None,
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
+ #[test]
|
|
523
|
+
+ fn cxstatusline_block_adds_rows_without_hiding_instruction_footer() {
|
|
524
|
+
+ let props = props_with_status_block(3, FooterMode::EscHint);
|
|
525
|
+
+ assert_eq!(footer_height(&props), 4);
|
|
526
|
+
+
|
|
527
|
+
+ let screen = render_footer_with_mode_indicator_and_context(
|
|
528
|
+
+ /*width*/ 80,
|
|
529
|
+
+ &props,
|
|
530
|
+
+ /*collaboration_mode_indicator*/ None,
|
|
531
|
+
+ context_window_line(/*percent*/ None, /*used_tokens*/ None),
|
|
532
|
+
+ );
|
|
533
|
+
+ let lines = screen.lines().map(str::trim).collect::<Vec<_>>();
|
|
534
|
+
+ assert_eq!(&lines[..3], ["status-0", "status-1", "status-2"]);
|
|
535
|
+
+ assert!(lines[3].contains("esc"));
|
|
536
|
+
+
|
|
537
|
+
+ snapshot_footer("cxstatusline_block_preserves_instruction_footer", props);
|
|
538
|
+
+ }
|
|
539
|
+
+
|
|
540
|
+
fn snapshot_footer_with_context(
|
|
541
|
+
name: &str,
|
|
542
|
+
props: FooterProps,
|
|
543
|
+
@@ -1311,6 +1363,26 @@ mod tests {
|
|
544
|
+
terminal
|
|
545
|
+
.draw(|f| {
|
|
546
|
+
let area = Rect::new(0, 0, f.area().width, height);
|
|
547
|
+
+ let cxstatusline_height = props.cxstatusline_block.len() as u16;
|
|
548
|
+
+ if cxstatusline_height > 0 {
|
|
549
|
+
+ let cxstatusline_area = Rect::new(
|
|
550
|
+
+ area.x,
|
|
551
|
+
+ area.y,
|
|
552
|
+
+ area.width,
|
|
553
|
+
+ cxstatusline_height.min(area.height),
|
|
554
|
+
+ );
|
|
555
|
+
+ render_cxstatusline_block(
|
|
556
|
+
+ cxstatusline_area,
|
|
557
|
+
+ f.buffer_mut(),
|
|
558
|
+
+ &props.cxstatusline_block,
|
|
559
|
+
+ );
|
|
560
|
+
+ }
|
|
561
|
+
+ let area = Rect::new(
|
|
562
|
+
+ area.x,
|
|
563
|
+
+ area.y.saturating_add(cxstatusline_height),
|
|
564
|
+
+ area.width,
|
|
565
|
+
+ area.height.saturating_sub(cxstatusline_height),
|
|
566
|
+
+ );
|
|
567
|
+
let show_cycle_hint = !props.is_task_running;
|
|
568
|
+
let show_shortcuts_hint = match props.mode {
|
|
569
|
+
FooterMode::ComposerEmpty => true,
|
|
570
|
+
@@ -1560,6 +1632,7 @@ mod tests {
|
|
571
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
572
|
+
status_line_value: None,
|
|
573
|
+
status_line_enabled: false,
|
|
574
|
+
+ cxstatusline_block: Vec::new(),
|
|
575
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
576
|
+
active_agent_label: None,
|
|
577
|
+
},
|
|
578
|
+
@@ -1578,6 +1651,7 @@ mod tests {
|
|
579
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
580
|
+
status_line_value: None,
|
|
581
|
+
status_line_enabled: false,
|
|
582
|
+
+ cxstatusline_block: Vec::new(),
|
|
583
|
+
key_hints: FooterKeyHints {
|
|
584
|
+
insert_newline: Some(key_hint::shift(KeyCode::Enter).into()),
|
|
585
|
+
..FooterKeyHints::default_bindings()
|
|
586
|
+
@@ -1599,6 +1673,7 @@ mod tests {
|
|
587
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
588
|
+
status_line_value: None,
|
|
589
|
+
status_line_enabled: false,
|
|
590
|
+
+ cxstatusline_block: Vec::new(),
|
|
591
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
592
|
+
active_agent_label: None,
|
|
593
|
+
},
|
|
594
|
+
@@ -1617,6 +1692,7 @@ mod tests {
|
|
595
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
596
|
+
status_line_value: None,
|
|
597
|
+
status_line_enabled: false,
|
|
598
|
+
+ cxstatusline_block: Vec::new(),
|
|
599
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
600
|
+
active_agent_label: None,
|
|
601
|
+
},
|
|
602
|
+
@@ -1635,6 +1711,7 @@ mod tests {
|
|
603
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
604
|
+
status_line_value: None,
|
|
605
|
+
status_line_enabled: false,
|
|
606
|
+
+ cxstatusline_block: Vec::new(),
|
|
607
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
608
|
+
active_agent_label: None,
|
|
609
|
+
},
|
|
610
|
+
@@ -1653,6 +1730,7 @@ mod tests {
|
|
611
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
612
|
+
status_line_value: None,
|
|
613
|
+
status_line_enabled: false,
|
|
614
|
+
+ cxstatusline_block: Vec::new(),
|
|
615
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
616
|
+
active_agent_label: None,
|
|
617
|
+
},
|
|
618
|
+
@@ -1671,6 +1749,7 @@ mod tests {
|
|
619
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
620
|
+
status_line_value: None,
|
|
621
|
+
status_line_enabled: false,
|
|
622
|
+
+ cxstatusline_block: Vec::new(),
|
|
623
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
624
|
+
active_agent_label: None,
|
|
625
|
+
},
|
|
626
|
+
@@ -1689,6 +1768,7 @@ mod tests {
|
|
627
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
628
|
+
status_line_value: None,
|
|
629
|
+
status_line_enabled: false,
|
|
630
|
+
+ cxstatusline_block: Vec::new(),
|
|
631
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
632
|
+
active_agent_label: None,
|
|
633
|
+
},
|
|
634
|
+
@@ -1707,6 +1787,7 @@ mod tests {
|
|
635
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
636
|
+
status_line_value: None,
|
|
637
|
+
status_line_enabled: false,
|
|
638
|
+
+ cxstatusline_block: Vec::new(),
|
|
639
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
640
|
+
active_agent_label: None,
|
|
641
|
+
},
|
|
642
|
+
@@ -1727,6 +1808,7 @@ mod tests {
|
|
643
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
644
|
+
status_line_value: None,
|
|
645
|
+
status_line_enabled: false,
|
|
646
|
+
+ cxstatusline_block: Vec::new(),
|
|
647
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
648
|
+
active_agent_label: None,
|
|
649
|
+
},
|
|
650
|
+
@@ -1747,6 +1829,7 @@ mod tests {
|
|
651
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
652
|
+
status_line_value: None,
|
|
653
|
+
status_line_enabled: false,
|
|
654
|
+
+ cxstatusline_block: Vec::new(),
|
|
655
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
656
|
+
active_agent_label: None,
|
|
657
|
+
},
|
|
658
|
+
@@ -1763,6 +1846,7 @@ mod tests {
|
|
659
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
660
|
+
status_line_value: None,
|
|
661
|
+
status_line_enabled: false,
|
|
662
|
+
+ cxstatusline_block: Vec::new(),
|
|
663
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
664
|
+
active_agent_label: None,
|
|
665
|
+
};
|
|
666
|
+
@@ -1792,6 +1876,7 @@ mod tests {
|
|
667
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
668
|
+
status_line_value: None,
|
|
669
|
+
status_line_enabled: false,
|
|
670
|
+
+ cxstatusline_block: Vec::new(),
|
|
671
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
672
|
+
active_agent_label: None,
|
|
673
|
+
};
|
|
674
|
+
@@ -1814,6 +1899,7 @@ mod tests {
|
|
675
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
676
|
+
status_line_value: Some(Line::from("Status line content".to_string())),
|
|
677
|
+
status_line_enabled: true,
|
|
678
|
+
+ cxstatusline_block: Vec::new(),
|
|
679
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
680
|
+
active_agent_label: None,
|
|
681
|
+
};
|
|
682
|
+
@@ -1831,6 +1917,7 @@ mod tests {
|
|
683
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
684
|
+
status_line_value: Some(Line::from("Status line content".to_string())),
|
|
685
|
+
status_line_enabled: true,
|
|
686
|
+
+ cxstatusline_block: Vec::new(),
|
|
687
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
688
|
+
active_agent_label: None,
|
|
689
|
+
};
|
|
690
|
+
@@ -1848,6 +1935,7 @@ mod tests {
|
|
691
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
692
|
+
status_line_value: Some(Line::from("Status line content".to_string())),
|
|
693
|
+
status_line_enabled: true,
|
|
694
|
+
+ cxstatusline_block: Vec::new(),
|
|
695
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
696
|
+
active_agent_label: None,
|
|
697
|
+
};
|
|
698
|
+
@@ -1865,6 +1953,7 @@ mod tests {
|
|
699
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
700
|
+
status_line_value: None, // command timed out / empty
|
|
701
|
+
status_line_enabled: true,
|
|
702
|
+
+ cxstatusline_block: Vec::new(),
|
|
703
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
704
|
+
active_agent_label: None,
|
|
705
|
+
};
|
|
706
|
+
@@ -1896,6 +1985,7 @@ mod tests {
|
|
707
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
708
|
+
status_line_value: None,
|
|
709
|
+
status_line_enabled: false,
|
|
710
|
+
+ cxstatusline_block: Vec::new(),
|
|
711
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
712
|
+
active_agent_label: None,
|
|
713
|
+
};
|
|
714
|
+
@@ -1919,6 +2009,7 @@ mod tests {
|
|
715
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
716
|
+
status_line_value: None,
|
|
717
|
+
status_line_enabled: true,
|
|
718
|
+
+ cxstatusline_block: Vec::new(),
|
|
719
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
720
|
+
active_agent_label: None,
|
|
721
|
+
};
|
|
722
|
+
@@ -1945,6 +2036,7 @@ mod tests {
|
|
723
|
+
"Status line content that should truncate before the mode indicator".to_string(),
|
|
724
|
+
)),
|
|
725
|
+
status_line_enabled: true,
|
|
726
|
+
+ cxstatusline_block: Vec::new(),
|
|
727
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
728
|
+
active_agent_label: None,
|
|
729
|
+
};
|
|
730
|
+
@@ -1968,6 +2060,7 @@ mod tests {
|
|
731
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
732
|
+
status_line_value: None,
|
|
733
|
+
status_line_enabled: false,
|
|
734
|
+
+ cxstatusline_block: Vec::new(),
|
|
735
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
736
|
+
active_agent_label: Some("Robie [explorer]".to_string()),
|
|
737
|
+
};
|
|
738
|
+
@@ -1985,6 +2078,7 @@ mod tests {
|
|
739
|
+
quit_shortcut_key: key_hint::ctrl(KeyCode::Char('c')),
|
|
740
|
+
status_line_value: Some(Line::from("Status line content".to_string())),
|
|
741
|
+
status_line_enabled: true,
|
|
742
|
+
+ cxstatusline_block: Vec::new(),
|
|
743
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
744
|
+
active_agent_label: Some("Robie [explorer]".to_string()),
|
|
745
|
+
};
|
|
746
|
+
@@ -2008,6 +2102,7 @@ mod tests {
|
|
747
|
+
.to_string(),
|
|
748
|
+
)),
|
|
749
|
+
status_line_enabled: true,
|
|
750
|
+
+ cxstatusline_block: Vec::new(),
|
|
751
|
+
key_hints: FooterKeyHints::default_bindings(),
|
|
752
|
+
active_agent_label: None,
|
|
753
|
+
};
|
|
754
|
+
diff --git a/codex-rs/tui/src/bottom_pane/mod.rs b/codex-rs/tui/src/bottom_pane/mod.rs
|
|
755
|
+
index fd2fd4a104..770bd8f7db 100644
|
|
756
|
+
--- a/codex-rs/tui/src/bottom_pane/mod.rs
|
|
757
|
+
+++ b/codex-rs/tui/src/bottom_pane/mod.rs
|
|
758
|
+
@@ -1912,6 +1912,12 @@ impl BottomPane {
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
+ pub(crate) fn set_cxstatusline_block(&mut self, block: Vec<Line<'static>>) {
|
|
763
|
+
+ if self.composer.set_cxstatusline_block(block) {
|
|
764
|
+
+ self.request_redraw();
|
|
765
|
+
+ }
|
|
766
|
+
+ }
|
|
767
|
+
+
|
|
768
|
+
/// Updates the contextual footer label and requests a redraw only when it changed.
|
|
769
|
+
///
|
|
770
|
+
/// This keeps the footer plumbing cheap during thread transitions where `App` may recompute
|
|
771
|
+
diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__footer__tests__cxstatusline_block_preserves_instruction_footer.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__footer__tests__cxstatusline_block_preserves_instruction_footer.snap
|
|
772
|
+
new file mode 100644
|
|
773
|
+
index 0000000000..abf66c5ec2
|
|
774
|
+
--- /dev/null
|
|
775
|
+
+++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__footer__tests__cxstatusline_block_preserves_instruction_footer.snap
|
|
776
|
+
@@ -0,0 +1,8 @@
|
|
777
|
+
+---
|
|
778
|
+
+source: tui/src/bottom_pane/footer.rs
|
|
779
|
+
+expression: terminal.backend()
|
|
780
|
+
+---
|
|
781
|
+
+" status-0 "
|
|
782
|
+
+" status-1 "
|
|
783
|
+
+" status-2 "
|
|
784
|
+
+" esc esc to edit previous message "
|
|
785
|
+
diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs
|
|
786
|
+
index 4b601e5728..fb210a262e 100644
|
|
787
|
+
--- a/codex-rs/tui/src/chatwidget.rs
|
|
788
|
+
+++ b/codex-rs/tui/src/chatwidget.rs
|
|
789
|
+
@@ -777,6 +777,24 @@ pub(crate) struct ChatWidget {
|
|
790
|
+
status_line_workspace_headline_last_requested_at: Option<Instant>,
|
|
791
|
+
// Set after the backend reports the workspace-message feature gate is disabled.
|
|
792
|
+
status_line_workspace_messages_disabled: bool,
|
|
793
|
+
+ // cxstatusline: argv of the external renderer from `CXSTATUSLINE_COMMAND`, if set.
|
|
794
|
+
+ cxstatusline_command: Option<Vec<String>>,
|
|
795
|
+
+ // cxstatusline: last successfully rendered complete block, shared with the render task.
|
|
796
|
+
+ cxstatusline_output: Arc<std::sync::Mutex<Option<Vec<Line<'static>>>>>,
|
|
797
|
+
+ // cxstatusline: true while a render task is in flight.
|
|
798
|
+
+ cxstatusline_pending: Arc<AtomicBool>,
|
|
799
|
+
+ // cxstatusline: set by the render task when new output landed - draw it, do not re-spawn.
|
|
800
|
+
+ cxstatusline_fresh: Arc<AtomicBool>,
|
|
801
|
+
+ // cxstatusline: a refresh arrived while throttled or pending - re-run once possible.
|
|
802
|
+
+ cxstatusline_dirty: bool,
|
|
803
|
+
+ // cxstatusline: last time a render task was spawned (throttle).
|
|
804
|
+
+ cxstatusline_last_spawn_at: Option<Instant>,
|
|
805
|
+
+ // cxstatusline: true while the periodic account/rateLimits/read is in flight.
|
|
806
|
+
+ cxstatusline_rate_limit_pending: bool,
|
|
807
|
+
+ // cxstatusline: last periodic account/rateLimits/read request time (throttle).
|
|
808
|
+
+ cxstatusline_rate_limit_last_requested_at: Option<Instant>,
|
|
809
|
+
+ // cxstatusline: captured once so renderer speed calculations cover this TUI session.
|
|
810
|
+
+ cxstatusline_started_at: chrono::DateTime<chrono::Utc>,
|
|
811
|
+
// Cached backend-estimated cost and bounded refresh state for the current thread.
|
|
812
|
+
thread_usage: thread_usage::ThreadUsageState,
|
|
813
|
+
// Current thread-goal status shown in the status line when plan mode is inactive.
|
|
814
|
+
@@ -1220,6 +1238,7 @@ impl ChatWidget {
|
|
815
|
+
self.refresh_terminal_title();
|
|
816
|
+
}
|
|
817
|
+
self.refresh_status_line_if_workspace_headline_due();
|
|
818
|
+
+ self.cxstatusline_pre_draw_tick();
|
|
819
|
+
self.refresh_thread_usage_if_settlement_due();
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
diff --git a/codex-rs/tui/src/chatwidget/constructor.rs b/codex-rs/tui/src/chatwidget/constructor.rs
|
|
823
|
+
index a1079ac7c4..7788dc642c 100644
|
|
824
|
+
--- a/codex-rs/tui/src/chatwidget/constructor.rs
|
|
825
|
+
+++ b/codex-rs/tui/src/chatwidget/constructor.rs
|
|
826
|
+
@@ -253,6 +253,19 @@ impl ChatWidget {
|
|
827
|
+
next_status_line_workspace_headline_request_id: 0,
|
|
828
|
+
status_line_workspace_headline_last_requested_at: None,
|
|
829
|
+
status_line_workspace_messages_disabled: false,
|
|
830
|
+
+ cxstatusline_command: std::env::var("CXSTATUSLINE_COMMAND")
|
|
831
|
+
+ .ok()
|
|
832
|
+
+ .filter(|raw| !raw.trim().is_empty())
|
|
833
|
+
+ .and_then(|raw| shlex::split(&raw))
|
|
834
|
+
+ .filter(|argv| !argv.is_empty()),
|
|
835
|
+
+ cxstatusline_output: Arc::new(std::sync::Mutex::new(None)),
|
|
836
|
+
+ cxstatusline_pending: Arc::new(AtomicBool::new(false)),
|
|
837
|
+
+ cxstatusline_fresh: Arc::new(AtomicBool::new(false)),
|
|
838
|
+
+ cxstatusline_dirty: false,
|
|
839
|
+
+ cxstatusline_last_spawn_at: None,
|
|
840
|
+
+ cxstatusline_rate_limit_pending: false,
|
|
841
|
+
+ cxstatusline_rate_limit_last_requested_at: None,
|
|
842
|
+
+ cxstatusline_started_at: chrono::Utc::now(),
|
|
843
|
+
thread_usage: thread_usage::ThreadUsageState::default(),
|
|
844
|
+
current_goal_status_indicator: None,
|
|
845
|
+
current_goal_status: None,
|
|
846
|
+
diff --git a/codex-rs/tui/src/chatwidget/status_surfaces.rs b/codex-rs/tui/src/chatwidget/status_surfaces.rs
|
|
847
|
+
index e79c0d3ca6..053e2332ed 100644
|
|
848
|
+
--- a/codex-rs/tui/src/chatwidget/status_surfaces.rs
|
|
849
|
+
+++ b/codex-rs/tui/src/chatwidget/status_surfaces.rs
|
|
850
|
+
@@ -40,6 +40,16 @@ const TERMINAL_TITLE_ACTION_REQUIRED_INTERVAL: Duration = Duration::from_secs(1)
|
|
851
|
+
const TERMINAL_TITLE_ACTION_REQUIRED_PREFIX: &str = "[ ! ] Action Required";
|
|
852
|
+
const TERMINAL_TITLE_ACTION_REQUIRED_PREFIX_HIDDEN: &str = "[ . ] Action Required";
|
|
853
|
+
|
|
854
|
+
+/// cxstatusline: minimum spacing between renderer spawns. 18 refresh call sites; one process per
|
|
855
|
+
+/// call would be waste. Refreshes inside the window coalesce and run once it closes.
|
|
856
|
+
+const CXSTATUSLINE_MIN_INTERVAL: Duration = Duration::from_millis(200);
|
|
857
|
+
+
|
|
858
|
+
+/// cxstatusline: renderer wall-clock budget. Over budget -> killed, last good line kept.
|
|
859
|
+
+const CXSTATUSLINE_TIMEOUT: Duration = Duration::from_secs(1);
|
|
860
|
+
+
|
|
861
|
+
+/// cxstatusline: bounded account-rate-limit freshness for renderer payloads.
|
|
862
|
+
+const CXSTATUSLINE_RATE_LIMIT_REFRESH_INTERVAL: Duration = Duration::from_secs(/*secs*/ 60);
|
|
863
|
+
+
|
|
864
|
+
#[derive(Debug)]
|
|
865
|
+
/// Parsed status-surface configuration for one refresh pass.
|
|
866
|
+
///
|
|
867
|
+
@@ -157,7 +167,7 @@ impl ChatWidget {
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
fn sync_status_surface_shared_state(&mut self, selections: &StatusSurfaceSelections) {
|
|
871
|
+
- if !selections.uses_git_branch() {
|
|
872
|
+
+ if !selections.uses_git_branch() && self.cxstatusline_command.is_none() {
|
|
873
|
+
self.status_line_branch = None;
|
|
874
|
+
self.status_line_branch_pending = false;
|
|
875
|
+
self.status_line_branch_lookup_complete = false;
|
|
876
|
+
@@ -169,7 +179,7 @@ impl ChatWidget {
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
- if !selections.uses_git_summary() {
|
|
881
|
+
+ if !selections.uses_git_summary() && self.cxstatusline_command.is_none() {
|
|
882
|
+
self.status_line_git_summary = None;
|
|
883
|
+
self.status_line_git_summary_pending = false;
|
|
884
|
+
self.status_line_git_summary_lookup_complete = false;
|
|
885
|
+
@@ -198,6 +208,12 @@ impl ChatWidget {
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
fn refresh_status_line_from_selections(&mut self, selections: &StatusSurfaceSelections) {
|
|
889
|
+
+ if self.cxstatusline_command.is_some() {
|
|
890
|
+
+ self.cxstatusline_request_render();
|
|
891
|
+
+ if self.cxstatusline_draw_shared_cell() {
|
|
892
|
+
+ return;
|
|
893
|
+
+ }
|
|
894
|
+
+ }
|
|
895
|
+
let enabled = !selections.status_line_items.is_empty();
|
|
896
|
+
self.bottom_pane.set_status_line_enabled(enabled);
|
|
897
|
+
if !enabled {
|
|
898
|
+
@@ -397,7 +413,7 @@ impl ChatWidget {
|
|
899
|
+
|
|
900
|
+
pub(super) fn request_status_line_branch_refresh(&mut self) {
|
|
901
|
+
let selections = self.status_surface_selections();
|
|
902
|
+
- if !selections.uses_git_branch() {
|
|
903
|
+
+ if !selections.uses_git_branch() && self.cxstatusline_command.is_none() {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
let cwd = self.status_line_cwd().to_path_buf();
|
|
907
|
+
@@ -407,7 +423,7 @@ impl ChatWidget {
|
|
908
|
+
|
|
909
|
+
pub(super) fn request_status_line_git_summary_refresh(&mut self) {
|
|
910
|
+
let selections = self.status_surface_selections();
|
|
911
|
+
- if !selections.uses_git_summary() {
|
|
912
|
+
+ if !selections.uses_git_summary() && self.cxstatusline_command.is_none() {
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
let cwd = self.status_line_cwd().to_path_buf();
|
|
916
|
+
@@ -550,6 +566,189 @@ impl ChatWidget {
|
|
917
|
+
///
|
|
918
|
+
/// The resulting `StatusLineBranchUpdated` event carries the lookup cwd so callers can reject
|
|
919
|
+
/// stale completions after directory changes.
|
|
920
|
+
+ /// cxstatusline: called from `pre_draw_tick`. Draws fresh renderer output without spawning,
|
|
921
|
+
+ /// and replays one coalesced refresh once the throttle window has closed.
|
|
922
|
+
+ pub(super) fn cxstatusline_pre_draw_tick(&mut self) {
|
|
923
|
+
+ if self.cxstatusline_command.is_none() {
|
|
924
|
+
+ return;
|
|
925
|
+
+ }
|
|
926
|
+
+ self.cxstatusline_rate_limit_tick(Instant::now());
|
|
927
|
+
+ if self.cxstatusline_fresh.swap(false, Ordering::AcqRel) {
|
|
928
|
+
+ self.cxstatusline_draw_shared_cell();
|
|
929
|
+
+ }
|
|
930
|
+
+ if !self.cxstatusline_dirty || self.cxstatusline_pending.load(Ordering::Acquire) {
|
|
931
|
+
+ return;
|
|
932
|
+
+ }
|
|
933
|
+
+ if let Some(remaining) = self.cxstatusline_throttle_remaining(Instant::now()) {
|
|
934
|
+
+ self.frame_requester.schedule_frame_in(remaining);
|
|
935
|
+
+ return;
|
|
936
|
+
+ }
|
|
937
|
+
+ self.cxstatusline_dirty = false;
|
|
938
|
+
+ self.refresh_status_line();
|
|
939
|
+
+ }
|
|
940
|
+
+
|
|
941
|
+
+ /// Requests fresh account limits for renderer payloads at most once per minute.
|
|
942
|
+
+ pub(super) fn cxstatusline_rate_limit_tick(&mut self, now: Instant) {
|
|
943
|
+
+ if self.cxstatusline_command.is_none()
|
|
944
|
+
+ || !self.should_prefetch_rate_limits()
|
|
945
|
+
+ || self.cxstatusline_rate_limit_pending
|
|
946
|
+
+ {
|
|
947
|
+
+ return;
|
|
948
|
+
+ }
|
|
949
|
+
+ if let Some(last_requested_at) = self.cxstatusline_rate_limit_last_requested_at {
|
|
950
|
+
+ let elapsed = now.saturating_duration_since(last_requested_at);
|
|
951
|
+
+ if elapsed < CXSTATUSLINE_RATE_LIMIT_REFRESH_INTERVAL {
|
|
952
|
+
+ self.frame_requester
|
|
953
|
+
+ .schedule_frame_in(CXSTATUSLINE_RATE_LIMIT_REFRESH_INTERVAL - elapsed);
|
|
954
|
+
+ return;
|
|
955
|
+
+ }
|
|
956
|
+
+ }
|
|
957
|
+
+ self.cxstatusline_rate_limit_pending = true;
|
|
958
|
+
+ self.cxstatusline_rate_limit_last_requested_at = Some(now);
|
|
959
|
+
+ self.app_event_tx.send(AppEvent::RefreshRateLimits {
|
|
960
|
+
+ origin: crate::app_event::RateLimitRefreshOrigin::CxStatusLine,
|
|
961
|
+
+ });
|
|
962
|
+
+ self.frame_requester
|
|
963
|
+
+ .schedule_frame_in(CXSTATUSLINE_RATE_LIMIT_REFRESH_INTERVAL);
|
|
964
|
+
+ }
|
|
965
|
+
+
|
|
966
|
+
+ pub(crate) fn finish_cxstatusline_rate_limit_refresh(&mut self) {
|
|
967
|
+
+ self.cxstatusline_rate_limit_pending = false;
|
|
968
|
+
+ // The completed read changed the payload source; schedule one renderer run.
|
|
969
|
+
+ self.cxstatusline_dirty = true;
|
|
970
|
+
+ }
|
|
971
|
+
+
|
|
972
|
+
+ /// cxstatusline: draw the last complete shared block, if any. A poisoned lock leaves the
|
|
973
|
+
+ /// already-rendered block untouched, so callers do not replace it with partial/native output.
|
|
974
|
+
+ fn cxstatusline_draw_shared_cell(&mut self) -> bool {
|
|
975
|
+
+ let rendered = match self.cxstatusline_output.lock() {
|
|
976
|
+
+ Ok(guard) => guard.clone(),
|
|
977
|
+
+ Err(_) => return true,
|
|
978
|
+
+ };
|
|
979
|
+
+ let Some(rendered) = rendered else {
|
|
980
|
+
+ return false;
|
|
981
|
+
+ };
|
|
982
|
+
+ self.bottom_pane.set_cxstatusline_block(rendered);
|
|
983
|
+
+ self.bottom_pane.set_status_line_enabled(/*enabled*/ false);
|
|
984
|
+
+ self.set_status_line(/*status_line*/ None);
|
|
985
|
+
+ self.set_status_line_hyperlink(/*url*/ None);
|
|
986
|
+
+ true
|
|
987
|
+
+ }
|
|
988
|
+
+
|
|
989
|
+
+ fn cxstatusline_throttle_remaining(&self, now: Instant) -> Option<Duration> {
|
|
990
|
+
+ let last = self.cxstatusline_last_spawn_at?;
|
|
991
|
+
+ let elapsed = now.saturating_duration_since(last);
|
|
992
|
+
+ (elapsed < CXSTATUSLINE_MIN_INTERVAL).then(|| CXSTATUSLINE_MIN_INTERVAL - elapsed)
|
|
993
|
+
+ }
|
|
994
|
+
+
|
|
995
|
+
+ /// cxstatusline: spawn the renderer with a payload v1 snapshot, unless one is in flight or the
|
|
996
|
+
+ /// throttle window is open - then remember to run again. Mirrors `request_status_line_branch`.
|
|
997
|
+
+ fn cxstatusline_request_render(&mut self) {
|
|
998
|
+
+ let Some(argv) = self.cxstatusline_command.clone() else {
|
|
999
|
+
+ return;
|
|
1000
|
+
+ };
|
|
1001
|
+
+ let now = Instant::now();
|
|
1002
|
+
+ if self.cxstatusline_pending.load(Ordering::Acquire)
|
|
1003
|
+
+ || self.cxstatusline_throttle_remaining(now).is_some()
|
|
1004
|
+
+ {
|
|
1005
|
+
+ self.cxstatusline_dirty = true;
|
|
1006
|
+
+ self.frame_requester
|
|
1007
|
+
+ .schedule_frame_in(CXSTATUSLINE_MIN_INTERVAL);
|
|
1008
|
+
+ return;
|
|
1009
|
+
+ }
|
|
1010
|
+
+ let payload = self.cxstatusline_payload_v1().to_string();
|
|
1011
|
+
+ self.cxstatusline_pending.store(true, Ordering::Release);
|
|
1012
|
+
+ self.cxstatusline_last_spawn_at = Some(now);
|
|
1013
|
+
+ let output = self.cxstatusline_output.clone();
|
|
1014
|
+
+ let pending = self.cxstatusline_pending.clone();
|
|
1015
|
+
+ let fresh = self.cxstatusline_fresh.clone();
|
|
1016
|
+
+ let frame_requester = self.frame_requester.clone();
|
|
1017
|
+
+ tokio::spawn(async move {
|
|
1018
|
+
+ if let Some(block) = cxstatusline_run(&argv, payload).await
|
|
1019
|
+
+ && let Ok(mut guard) = output.lock()
|
|
1020
|
+
+ {
|
|
1021
|
+
+ *guard = Some(block);
|
|
1022
|
+
+ fresh.store(true, Ordering::Release);
|
|
1023
|
+
+ }
|
|
1024
|
+
+ pending.store(false, Ordering::Release);
|
|
1025
|
+
+ frame_requester.schedule_frame();
|
|
1026
|
+
+ });
|
|
1027
|
+
+ }
|
|
1028
|
+
+
|
|
1029
|
+
+ /// cxstatusline: typed snapshot of the git state behind the native git status-line items.
|
|
1030
|
+
+ fn cxstatusline_git_v1(&self) -> serde_json::Value {
|
|
1031
|
+
+ use serde_json::json;
|
|
1032
|
+
+ let summary = self.status_line_git_summary.as_ref();
|
|
1033
|
+
+ json!({
|
|
1034
|
+
+ "branch": self.status_line_branch.as_deref(),
|
|
1035
|
+
+ "changes": summary
|
|
1036
|
+
+ .and_then(|summary| summary.branch_change_stats.as_ref())
|
|
1037
|
+
+ .map(|stats| json!({ "additions": stats.additions, "deletions": stats.deletions })),
|
|
1038
|
+
+ "pr": summary
|
|
1039
|
+
+ .and_then(|summary| summary.pull_request.as_ref())
|
|
1040
|
+
+ .map(|pull_request| pull_request.number),
|
|
1041
|
+
+ })
|
|
1042
|
+
+ }
|
|
1043
|
+
+
|
|
1044
|
+
+ /// cxstatusline: typed snapshot of the state behind every native status-line item.
|
|
1045
|
+
+ /// `null` means "unavailable right now", same as an absent key. Enum-valued fields carry
|
|
1046
|
+
+ /// Codex's own serde/strum identifiers (`on-request`, `workspace-write`), never display text.
|
|
1047
|
+
+ fn cxstatusline_payload_v1(&self) -> serde_json::Value {
|
|
1048
|
+
+ use serde_json::json;
|
|
1049
|
+
+ let cwd = self.status_line_cwd().to_path_buf();
|
|
1050
|
+
+ let project_root = self.status_line_project_root_for_cwd(&cwd);
|
|
1051
|
+
+ let codex_limits = self.rate_limit_snapshots_by_limit_id.get("codex");
|
|
1052
|
+
+ let window = |w: Option<(&RateLimitWindowDisplay, bool)>| {
|
|
1053
|
+
+ w.map(|(window, _is_secondary)| {
|
|
1054
|
+
+ json!({
|
|
1055
|
+
+ "used": window.used_percent / 100.0,
|
|
1056
|
+
+ "resets_at": window.resets_at_unix.and_then(cxstatusline_iso8601),
|
|
1057
|
+
+ })
|
|
1058
|
+
+ })
|
|
1059
|
+
+ };
|
|
1060
|
+
+ let used_tokens = {
|
|
1061
|
+
+ let total = self.status_line_total_usage().blended_total();
|
|
1062
|
+
+ (total > 0).then_some(total)
|
|
1063
|
+
+ };
|
|
1064
|
+
+ let usage = self.token_info.as_ref().map(|info| &info.total_token_usage);
|
|
1065
|
+
+ let context_tokens = self
|
|
1066
|
+
+ .token_info
|
|
1067
|
+
+ .as_ref()
|
|
1068
|
+
+ .map(|info| info.last_token_usage.tokens_in_context_window());
|
|
1069
|
+
+ json!({
|
|
1070
|
+
+ "payload_version": 1,
|
|
1071
|
+
+ "model": {
|
|
1072
|
+
+ "name": self.model_display_name(),
|
|
1073
|
+
+ "reasoning": self.reasoning_display_name(),
|
|
1074
|
+
+ },
|
|
1075
|
+
+ "git": self.cxstatusline_git_v1(),
|
|
1076
|
+
+ "usage": {
|
|
1077
|
+
+ "context_used": self.status_line_context_used_percent().map(|p| p as f64 / 100.0),
|
|
1078
|
+
+ "context_remaining": self.status_line_context_remaining_percent().map(|p| p as f64 / 100.0),
|
|
1079
|
+
+ "context_tokens": context_tokens,
|
|
1080
|
+
+ "context_window": self.status_line_context_window_size(),
|
|
1081
|
+
+ "used_tokens": used_tokens,
|
|
1082
|
+
+ "input_tokens": usage.map(|usage| usage.input_tokens),
|
|
1083
|
+
+ "output_tokens": usage.map(|usage| usage.output_tokens),
|
|
1084
|
+
+ "cached_input_tokens": usage.map(|usage| usage.cached_input_tokens),
|
|
1085
|
+
+ "five_hour": window(codex_limits.and_then(five_hour_status_window)),
|
|
1086
|
+
+ "weekly": window(codex_limits.and_then(weekly_status_window)),
|
|
1087
|
+
+ },
|
|
1088
|
+
+ "session": {
|
|
1089
|
+
+ "id": self.thread_id.map(|id| id.to_string()),
|
|
1090
|
+
+ "cwd": cwd.to_string_lossy(),
|
|
1091
|
+
+ "project_root": project_root.map(|p| p.to_string_lossy().into_owned()),
|
|
1092
|
+
+ "hostname": os_host_name(),
|
|
1093
|
+
+ "approval_mode": self.config.permissions.approval_policy.value().to_string(),
|
|
1094
|
+
+ "permissions": self.config.legacy_sandbox_policy().to_string(),
|
|
1095
|
+
+ "run_state": self.run_state_status_text().to_lowercase(),
|
|
1096
|
+
+ "codex_version": crate::version::CODEX_CLI_VERSION,
|
|
1097
|
+
+ "started_at": self.cxstatusline_started_at.to_rfc3339_opts(chrono::SecondsFormat::Secs, /*use_z*/ true),
|
|
1098
|
+
+ "thread_title": self.thread_name.clone(),
|
|
1099
|
+
+ },
|
|
1100
|
+
+ })
|
|
1101
|
+
+ }
|
|
1102
|
+
+
|
|
1103
|
+
fn request_status_line_branch(&mut self, cwd: PathBuf) {
|
|
1104
|
+
if self.status_line_branch_pending {
|
|
1105
|
+
return;
|
|
1106
|
+
@@ -1198,3 +1397,48 @@ where
|
|
1107
|
+
}
|
|
1108
|
+
(items, invalid)
|
|
1109
|
+
}
|
|
1110
|
+
+
|
|
1111
|
+
+/// cxstatusline: seconds since the Unix epoch -> RFC 3339 UTC.
|
|
1112
|
+
+fn cxstatusline_iso8601(seconds: i64) -> Option<String> {
|
|
1113
|
+
+ chrono::DateTime::<chrono::Utc>::from_timestamp(seconds, 0)
|
|
1114
|
+
+ .map(|dt| dt.to_rfc3339_opts(chrono::SecondsFormat::Secs, /*use_z*/ true))
|
|
1115
|
+
+}
|
|
1116
|
+
+
|
|
1117
|
+
+/// cxstatusline: run the external renderer once. `None` on spawn failure, non-zero exit, timeout,
|
|
1118
|
+
+/// malformed, blank, or oversized stdout - the caller keeps the previous complete block.
|
|
1119
|
+
+async fn cxstatusline_run(argv: &[String], payload: String) -> Option<Vec<Line<'static>>> {
|
|
1120
|
+
+ use tokio::io::AsyncWriteExt;
|
|
1121
|
+
+ let (program, args) = argv.split_first()?;
|
|
1122
|
+
+ let mut child = tokio::process::Command::new(program)
|
|
1123
|
+
+ .args(args)
|
|
1124
|
+
+ .stdin(std::process::Stdio::piped())
|
|
1125
|
+
+ .stdout(std::process::Stdio::piped())
|
|
1126
|
+
+ .stderr(std::process::Stdio::null())
|
|
1127
|
+
+ .kill_on_drop(true)
|
|
1128
|
+
+ .spawn()
|
|
1129
|
+
+ .ok()?;
|
|
1130
|
+
+ let mut stdin = child.stdin.take()?;
|
|
1131
|
+
+ stdin.write_all(payload.as_bytes()).await.ok()?;
|
|
1132
|
+
+ // Drop closes the pipe so the renderer sees EOF.
|
|
1133
|
+
+ drop(stdin);
|
|
1134
|
+
+ let output = tokio::time::timeout(CXSTATUSLINE_TIMEOUT, child.wait_with_output())
|
|
1135
|
+
+ .await
|
|
1136
|
+
+ .ok()?
|
|
1137
|
+
+ .ok()?;
|
|
1138
|
+
+ if !output.status.success() {
|
|
1139
|
+
+ return None;
|
|
1140
|
+
+ }
|
|
1141
|
+
+ cxstatusline_parse_output(&String::from_utf8_lossy(&output.stdout))
|
|
1142
|
+
+}
|
|
1143
|
+
+
|
|
1144
|
+
+/// Parse all renderer rows before exposing them to the shared block; a malformed block never
|
|
1145
|
+
+/// replaces the last complete render.
|
|
1146
|
+
+pub(super) fn cxstatusline_parse_output(text: &str) -> Option<Vec<Line<'static>>> {
|
|
1147
|
+
+ let text = text.strip_suffix('\n').unwrap_or(text);
|
|
1148
|
+
+ let rows: Vec<_> = text.split('\n').collect();
|
|
1149
|
+
+ ((1..=3).contains(&rows.len()) && rows.iter().all(|line| !line.trim().is_empty())).then(|| {
|
|
1150
|
+
+ rows.into_iter()
|
|
1151
|
+
+ .map(codex_ansi_escape::ansi_escape_line)
|
|
1152
|
+
+ .collect()
|
|
1153
|
+
+ })
|
|
1154
|
+
+}
|
|
1155
|
+
diff --git a/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs b/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs
|
|
1156
|
+
index 6b72898912..1fd5dd1254 100644
|
|
1157
|
+
--- a/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs
|
|
1158
|
+
+++ b/codex-rs/tui/src/chatwidget/tests/status_and_layout.rs
|
|
1159
|
+
@@ -1,4 +1,8 @@
|
|
1160
|
+
+use std::time::Duration;
|
|
1161
|
+
+use std::time::Instant;
|
|
1162
|
+
+
|
|
1163
|
+
use super::*;
|
|
1164
|
+
+use crate::app_event::RateLimitRefreshOrigin;
|
|
1165
|
+
use crate::bottom_pane::goal_status_indicator_line;
|
|
1166
|
+
use crate::chatwidget::ThreadUsageOutcome;
|
|
1167
|
+
use crate::chatwidget::rate_limits::NUDGE_MODEL_SLUG;
|
|
1168
|
+
@@ -9,6 +13,245 @@ use pretty_assertions::assert_eq;
|
|
1169
|
+
use ratatui::backend::TestBackend;
|
|
1170
|
+
use serial_test::serial;
|
|
1171
|
+
|
|
1172
|
+
+struct CxLocalGitRunner;
|
|
1173
|
+
+
|
|
1174
|
+
+impl crate::workspace_command::WorkspaceCommandExecutor for CxLocalGitRunner {
|
|
1175
|
+
+ fn run(
|
|
1176
|
+
+ &self,
|
|
1177
|
+
+ command: crate::workspace_command::WorkspaceCommand,
|
|
1178
|
+
+ ) -> std::pin::Pin<
|
|
1179
|
+
+ Box<
|
|
1180
|
+
+ dyn std::future::Future<
|
|
1181
|
+
+ Output = Result<
|
|
1182
|
+
+ crate::workspace_command::WorkspaceCommandOutput,
|
|
1183
|
+
+ crate::workspace_command::WorkspaceCommandError,
|
|
1184
|
+
+ >,
|
|
1185
|
+
+ > + Send
|
|
1186
|
+
+ + '_,
|
|
1187
|
+
+ >,
|
|
1188
|
+
+ > {
|
|
1189
|
+
+ Box::pin(async move {
|
|
1190
|
+
+ // Only local Git runs: PR probes must never contact the owner's GitHub account.
|
|
1191
|
+
+ if command.argv.first().map(String::as_str) != Some("git") {
|
|
1192
|
+
+ return Ok(crate::workspace_command::WorkspaceCommandOutput {
|
|
1193
|
+
+ exit_code: 1,
|
|
1194
|
+
+ stdout: String::new(),
|
|
1195
|
+
+ stderr: String::new(),
|
|
1196
|
+
+ });
|
|
1197
|
+
+ }
|
|
1198
|
+
+ let mut process = tokio::process::Command::new("git");
|
|
1199
|
+
+ process.args(&command.argv[1..]).kill_on_drop(true);
|
|
1200
|
+
+ if let Some(cwd) = command.cwd {
|
|
1201
|
+
+ process.current_dir(cwd);
|
|
1202
|
+
+ }
|
|
1203
|
+
+ for (key, value) in command.env {
|
|
1204
|
+
+ if let Some(value) = value {
|
|
1205
|
+
+ process.env(key, value);
|
|
1206
|
+
+ } else {
|
|
1207
|
+
+ process.env_remove(key);
|
|
1208
|
+
+ }
|
|
1209
|
+
+ }
|
|
1210
|
+
+ let output = tokio::time::timeout(command.timeout, process.output())
|
|
1211
|
+
+ .await
|
|
1212
|
+
+ .expect("git timeout")
|
|
1213
|
+
+ .expect("git runs");
|
|
1214
|
+
+ Ok(crate::workspace_command::WorkspaceCommandOutput {
|
|
1215
|
+
+ exit_code: output.status.code().unwrap_or(1),
|
|
1216
|
+
+ stdout: String::from_utf8_lossy(&output.stdout).into_owned(),
|
|
1217
|
+
+ stderr: String::from_utf8_lossy(&output.stderr).into_owned(),
|
|
1218
|
+
+ })
|
|
1219
|
+
+ })
|
|
1220
|
+
+ }
|
|
1221
|
+
+}
|
|
1222
|
+
+
|
|
1223
|
+
+#[tokio::test]
|
|
1224
|
+
+async fn cxstatusline_git_values_change_after_a_turn() {
|
|
1225
|
+
+ let repo = tempfile::tempdir().expect("temp repo");
|
|
1226
|
+
+ let git = |args: &[&str]| {
|
|
1227
|
+
+ let output = std::process::Command::new("git")
|
|
1228
|
+
+ .args(args)
|
|
1229
|
+
+ .current_dir(repo.path())
|
|
1230
|
+
+ .output()
|
|
1231
|
+
+ .expect("git runs");
|
|
1232
|
+
+ assert!(
|
|
1233
|
+
+ output.status.success(),
|
|
1234
|
+
+ "{}",
|
|
1235
|
+
+ String::from_utf8_lossy(&output.stderr)
|
|
1236
|
+
+ );
|
|
1237
|
+
+ };
|
|
1238
|
+
+ git(&["init", "-b", "main"]);
|
|
1239
|
+
+ git(&[
|
|
1240
|
+
+ "-c",
|
|
1241
|
+
+ "user.name=Test",
|
|
1242
|
+
+ "-c",
|
|
1243
|
+
+ "user.email=test@example.com",
|
|
1244
|
+
+ "commit",
|
|
1245
|
+
+ "--allow-empty",
|
|
1246
|
+
+ "-m",
|
|
1247
|
+
+ "base",
|
|
1248
|
+
+ ]);
|
|
1249
|
+
+ let (mut chat, mut rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await;
|
|
1250
|
+
+ chat.config.cwd = AbsolutePathBuf::try_from(repo.path().to_path_buf()).expect("absolute cwd");
|
|
1251
|
+
+ chat.current_cwd = Some(repo.path().to_path_buf());
|
|
1252
|
+
+ chat.config.tui_status_line = Some(vec![]);
|
|
1253
|
+
+ chat.config.tui_terminal_title = Some(vec![]);
|
|
1254
|
+
+ chat.cxstatusline_command = Some(vec!["unused-renderer".into()]);
|
|
1255
|
+
+ // Exercise collection without launching a renderer during completion callbacks.
|
|
1256
|
+
+ chat.cxstatusline_pending.store(true, Ordering::Release);
|
|
1257
|
+
+ chat.workspace_command_runner = Some(std::sync::Arc::new(CxLocalGitRunner));
|
|
1258
|
+
+ for (branch, changes) in [("main", "No changes"), ("feature", "+1 -0")] {
|
|
1259
|
+
+ if branch == "feature" {
|
|
1260
|
+
+ git(&["checkout", "-b", "feature"]);
|
|
1261
|
+
+ std::fs::write(repo.path().join("file"), "one line\n").expect("write change");
|
|
1262
|
+
+ git(&["add", "file"]);
|
|
1263
|
+
+ git(&[
|
|
1264
|
+
+ "-c",
|
|
1265
|
+
+ "user.name=Test",
|
|
1266
|
+
+ "-c",
|
|
1267
|
+
+ "user.email=test@example.com",
|
|
1268
|
+
+ "commit",
|
|
1269
|
+
+ "-m",
|
|
1270
|
+
+ "change",
|
|
1271
|
+
+ ]);
|
|
1272
|
+
+ }
|
|
1273
|
+
+ handle_turn_completed(&mut chat, "turn-1", /*duration_ms*/ None);
|
|
1274
|
+
+ assert!(chat.status_line_branch_pending && chat.status_line_git_summary_pending);
|
|
1275
|
+
+ tokio::time::timeout(Duration::from_secs(/*secs*/ 10), async {
|
|
1276
|
+
+ while chat.status_line_branch_pending || chat.status_line_git_summary_pending {
|
|
1277
|
+
+ match rx.recv().await.expect("completion event") {
|
|
1278
|
+
+ AppEvent::StatusLineBranchUpdated { cwd, branch } => {
|
|
1279
|
+
+ chat.set_status_line_branch(cwd, branch)
|
|
1280
|
+
+ }
|
|
1281
|
+
+ AppEvent::StatusLineGitSummaryUpdated { cwd, summary } => {
|
|
1282
|
+
+ chat.set_status_line_git_summary(cwd, summary)
|
|
1283
|
+
+ }
|
|
1284
|
+
+ _ => {}
|
|
1285
|
+
+ }
|
|
1286
|
+
+ }
|
|
1287
|
+
+ })
|
|
1288
|
+
+ .await
|
|
1289
|
+
+ .expect("Git refresh completes");
|
|
1290
|
+
+ assert_eq!(chat.status_line_branch.as_deref(), Some(branch));
|
|
1291
|
+
+ assert_eq!(
|
|
1292
|
+
+ chat.status_line_value_for_item(crate::bottom_pane::StatusLineItem::BranchChanges),
|
|
1293
|
+
+ Some(changes.into())
|
|
1294
|
+
+ );
|
|
1295
|
+
+ }
|
|
1296
|
+
+}
|
|
1297
|
+
+
|
|
1298
|
+
+#[tokio::test]
|
|
1299
|
+
+async fn cxstatusline_git_refresh_does_not_require_native_items() {
|
|
1300
|
+
+ for mode in ["disabled", "cx", "native"] {
|
|
1301
|
+
+ let (mut chat, _rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await;
|
|
1302
|
+
+ install_noop_workspace_command_runner(&mut chat);
|
|
1303
|
+
+ chat.config.tui_status_line = Some(if mode == "native" {
|
|
1304
|
+
+ vec!["git-branch".into(), "branch-changes".into()]
|
|
1305
|
+
+ } else {
|
|
1306
|
+
+ vec![]
|
|
1307
|
+
+ });
|
|
1308
|
+
+ chat.config.tui_terminal_title = Some(vec![]);
|
|
1309
|
+
+ chat.cxstatusline_command = (mode == "cx").then(|| vec!["unused-renderer".into()]);
|
|
1310
|
+
+ let cwd = chat.config.cwd.to_path_buf();
|
|
1311
|
+
+ chat.status_line_branch_cwd = Some(cwd.clone());
|
|
1312
|
+
+ chat.status_line_git_summary_cwd = Some(cwd);
|
|
1313
|
+
+ chat.status_line_branch_lookup_complete = true;
|
|
1314
|
+
+ chat.status_line_git_summary_lookup_complete = true;
|
|
1315
|
+
+ chat.request_status_line_branch_refresh();
|
|
1316
|
+
+ chat.request_status_line_git_summary_refresh();
|
|
1317
|
+
+ assert_eq!(
|
|
1318
|
+
+ (
|
|
1319
|
+
+ chat.status_line_branch_pending,
|
|
1320
|
+
+ chat.status_line_git_summary_pending
|
|
1321
|
+
+ ),
|
|
1322
|
+
+ (mode != "disabled", mode != "disabled"),
|
|
1323
|
+
+ "refresh mode {mode}"
|
|
1324
|
+
+ );
|
|
1325
|
+
+ }
|
|
1326
|
+
+}
|
|
1327
|
+
+
|
|
1328
|
+
+#[test]
|
|
1329
|
+
+fn cxstatusline_accepts_complete_rows_and_rejects_invalid_blocks() {
|
|
1330
|
+
+ assert_eq!(
|
|
1331
|
+
+ super::super::status_surfaces::cxstatusline_parse_output("one\ntwo\nthree\n")
|
|
1332
|
+
+ .expect("three non-blank rows")
|
|
1333
|
+
+ .len(),
|
|
1334
|
+
+ 3
|
|
1335
|
+
+ );
|
|
1336
|
+
+ assert!(super::super::status_surfaces::cxstatusline_parse_output("one\n\nthree\n").is_none());
|
|
1337
|
+
+ assert!(super::super::status_surfaces::cxstatusline_parse_output("one\ntwo\n\n").is_none());
|
|
1338
|
+
+ assert!(
|
|
1339
|
+
+ super::super::status_surfaces::cxstatusline_parse_output("one\ntwo\nthree\nfour\n")
|
|
1340
|
+
+ .is_none()
|
|
1341
|
+
+ );
|
|
1342
|
+
+}
|
|
1343
|
+
+
|
|
1344
|
+
+#[tokio::test]
|
|
1345
|
+
+async fn cxstatusline_rate_limit_tick_requires_command_and_chatgpt_auth() {
|
|
1346
|
+
+ let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
|
1347
|
+
+ let now = Instant::now();
|
|
1348
|
+
+
|
|
1349
|
+
+ chat.cxstatusline_rate_limit_tick(now);
|
|
1350
|
+
+ assert!(matches!(
|
|
1351
|
+
+ rx.try_recv(),
|
|
1352
|
+
+ Err(tokio::sync::mpsc::error::TryRecvError::Empty)
|
|
1353
|
+
+ ));
|
|
1354
|
+
+
|
|
1355
|
+
+ chat.cxstatusline_command = Some(vec!["renderer".to_string()]);
|
|
1356
|
+
+ chat.cxstatusline_rate_limit_tick(now);
|
|
1357
|
+
+ assert!(matches!(
|
|
1358
|
+
+ rx.try_recv(),
|
|
1359
|
+
+ Err(tokio::sync::mpsc::error::TryRecvError::Empty)
|
|
1360
|
+
+ ));
|
|
1361
|
+
+
|
|
1362
|
+
+ set_chatgpt_auth(&mut chat);
|
|
1363
|
+
+ chat.cxstatusline_rate_limit_tick(now);
|
|
1364
|
+
+ assert!(matches!(
|
|
1365
|
+
+ rx.try_recv(),
|
|
1366
|
+
+ Ok(AppEvent::RefreshRateLimits {
|
|
1367
|
+
+ origin: RateLimitRefreshOrigin::CxStatusLine,
|
|
1368
|
+
+ })
|
|
1369
|
+
+ ));
|
|
1370
|
+
+}
|
|
1371
|
+
+
|
|
1372
|
+
+#[tokio::test]
|
|
1373
|
+
+async fn cxstatusline_rate_limit_completion_releases_next_minute_tick() {
|
|
1374
|
+
+ let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
|
1375
|
+
+ chat.cxstatusline_command = Some(vec!["renderer".to_string()]);
|
|
1376
|
+
+ set_chatgpt_auth(&mut chat);
|
|
1377
|
+
+ let now = Instant::now();
|
|
1378
|
+
+
|
|
1379
|
+
+ chat.cxstatusline_rate_limit_tick(now);
|
|
1380
|
+
+ assert!(matches!(
|
|
1381
|
+
+ rx.try_recv(),
|
|
1382
|
+
+ Ok(AppEvent::RefreshRateLimits {
|
|
1383
|
+
+ origin: RateLimitRefreshOrigin::CxStatusLine,
|
|
1384
|
+
+ })
|
|
1385
|
+
+ ));
|
|
1386
|
+
+ assert!(chat.cxstatusline_rate_limit_pending);
|
|
1387
|
+
+
|
|
1388
|
+
+ chat.cxstatusline_rate_limit_tick(now + Duration::from_secs(/*secs*/ 59));
|
|
1389
|
+
+ assert!(matches!(
|
|
1390
|
+
+ rx.try_recv(),
|
|
1391
|
+
+ Err(tokio::sync::mpsc::error::TryRecvError::Empty)
|
|
1392
|
+
+ ));
|
|
1393
|
+
+
|
|
1394
|
+
+ chat.finish_cxstatusline_rate_limit_refresh();
|
|
1395
|
+
+ assert!(!chat.cxstatusline_rate_limit_pending);
|
|
1396
|
+
+ chat.cxstatusline_rate_limit_tick(now + Duration::from_secs(/*secs*/ 59));
|
|
1397
|
+
+ assert!(matches!(
|
|
1398
|
+
+ rx.try_recv(),
|
|
1399
|
+
+ Err(tokio::sync::mpsc::error::TryRecvError::Empty)
|
|
1400
|
+
+ ));
|
|
1401
|
+
+
|
|
1402
|
+
+ chat.cxstatusline_rate_limit_tick(now + Duration::from_secs(/*secs*/ 60));
|
|
1403
|
+
+ assert!(matches!(
|
|
1404
|
+
+ rx.try_recv(),
|
|
1405
|
+
+ Ok(AppEvent::RefreshRateLimits {
|
|
1406
|
+
+ origin: RateLimitRefreshOrigin::CxStatusLine,
|
|
1407
|
+
+ })
|
|
1408
|
+
+ ));
|
|
1409
|
+
+}
|
|
1410
|
+
+
|
|
1411
|
+
fn enable_test_ambient_pet(chat: &mut ChatWidget) {
|
|
1412
|
+
chat.set_pet_image_support_for_tests(crate::pets::PetImageSupport::Supported(
|
|
1413
|
+
crate::pets::ImageProtocol::Kitty,
|
|
1414
|
+
diff --git a/codex-rs/tui/src/status/rate_limits.rs b/codex-rs/tui/src/status/rate_limits.rs
|
|
1415
|
+
index aaf54df448..15b37f85bd 100644
|
|
1416
|
+
--- a/codex-rs/tui/src/status/rate_limits.rs
|
|
1417
|
+
+++ b/codex-rs/tui/src/status/rate_limits.rs
|
|
1418
|
+
@@ -71,6 +71,8 @@ pub(crate) struct RateLimitWindowDisplay {
|
|
1419
|
+
pub used_percent: f64,
|
|
1420
|
+
/// Human-readable local reset time.
|
|
1421
|
+
pub resets_at: Option<String>,
|
|
1422
|
+
+ /// cxstatusline: raw reset time, seconds since the Unix epoch, when the server provided one.
|
|
1423
|
+
+ pub resets_at_unix: Option<i64>,
|
|
1424
|
+
/// Window length in minutes when provided by the server.
|
|
1425
|
+
pub window_minutes: Option<i64>,
|
|
1426
|
+
}
|
|
1427
|
+
@@ -86,6 +88,7 @@ impl RateLimitWindowDisplay {
|
|
1428
|
+
Self {
|
|
1429
|
+
used_percent: f64::from(window.used_percent),
|
|
1430
|
+
resets_at,
|
|
1431
|
+
+ resets_at_unix: window.resets_at,
|
|
1432
|
+
window_minutes: window.window_duration_mins,
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
@@ -429,6 +432,7 @@ mod tests {
|
|
1436
|
+
RateLimitWindowDisplay {
|
|
1437
|
+
used_percent,
|
|
1438
|
+
resets_at: Some("soon".to_string()),
|
|
1439
|
+
+ resets_at_unix: None,
|
|
1440
|
+
window_minutes: Some(300),
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
@@ -488,11 +492,13 @@ mod tests {
|
|
1444
|
+
primary: Some(RateLimitWindowDisplay {
|
|
1445
|
+
used_percent: 20.0,
|
|
1446
|
+
resets_at: Some("soon".to_string()),
|
|
1447
|
+
+ resets_at_unix: None,
|
|
1448
|
+
window_minutes: Some(60),
|
|
1449
|
+
}),
|
|
1450
|
+
secondary: Some(RateLimitWindowDisplay {
|
|
1451
|
+
used_percent: 40.0,
|
|
1452
|
+
resets_at: Some("later".to_string()),
|
|
1453
|
+
+ resets_at_unix: None,
|
|
1454
|
+
window_minutes: Some(2 * 60),
|
|
1455
|
+
}),
|
|
1456
|
+
credits: None,
|
|
1457
|
+
diff --git a/codex-rs/tui/src/status/tests.rs b/codex-rs/tui/src/status/tests.rs
|
|
1458
|
+
index 161bbf4c74..ae69fe4848 100644
|
|
1459
|
+
--- a/codex-rs/tui/src/status/tests.rs
|
|
1460
|
+
+++ b/codex-rs/tui/src/status/tests.rs
|
|
1461
|
+
@@ -68,6 +68,7 @@ fn stale_monthly_limit_marks_fresh_rolling_snapshot_stale() {
|
|
1462
|
+
primary: Some(RateLimitWindowDisplay {
|
|
1463
|
+
used_percent: 20.0,
|
|
1464
|
+
resets_at: Some("soon".to_string()),
|
|
1465
|
+
+ resets_at_unix: None,
|
|
1466
|
+
window_minutes: Some(300),
|
|
1467
|
+
}),
|
|
1468
|
+
secondary: None,
|
|
1469
|
+
@@ -1781,11 +1782,13 @@ async fn transcript_overlay_remeasures_status_after_rate_limit_refresh() {
|
|
1470
|
+
primary: Some(RateLimitWindowDisplay {
|
|
1471
|
+
used_percent: 45.0,
|
|
1472
|
+
resets_at: Some("soon".to_string()),
|
|
1473
|
+
+ resets_at_unix: None,
|
|
1474
|
+
window_minutes: Some(300),
|
|
1475
|
+
}),
|
|
1476
|
+
secondary: Some(RateLimitWindowDisplay {
|
|
1477
|
+
used_percent: 30.0,
|
|
1478
|
+
resets_at: Some("later".to_string()),
|
|
1479
|
+
+ resets_at_unix: None,
|
|
1480
|
+
window_minutes: Some(10_080),
|
|
1481
|
+
}),
|
|
1482
|
+
credits: None,
|