mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Add hostname to the configurable TUI status line (#39795)
## What changed - Add `hostname` as a selectable status-line item and show it in setup previews. - Read the normalized operating-system hostname without triggering DNS resolution, and omit the item when no hostname is available. ## Testing - Cover hostname normalization, status-line rendering, and setup and surface previews. GitOrigin-RevId: c5e4e0ee1dba6e4bfdf942562a6b037835ff9e69
This commit is contained in:
1 parent
bfb8986f7f
commit
d9fd91edab
9 files changed
+116
-3
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
---
|
||||
source: tui/src/bottom_pane/status_line_setup.rs
|
||||
expression: "render_lines(&view,\n100).lines().map(str::trim_end).collect::<Vec<_>>().join(\"\\n\")"
|
||||
---
|
||||
|
||||
Configure Status Line
|
||||
Select which items to display in the status line.
|
||||
|
||||
Type to search
|
||||
>
|
||||
› [x] Use theme colors Apply colors from the active /theme
|
||||
───────────────────────
|
||||
[x] hostname Current machine hostname (omitted when unavailable)
|
||||
[x] current-dir Current working directory
|
||||
[ ] model Current model name
|
||||
[ ] model-with-reasoning Current model name with reasoning level
|
||||
[ ] reasoning Current reasoning level
|
||||
[ ] project-name Project name (omitted when unavailable)
|
||||
|
||||
ssh-build-01.example.com · ~/codex-rs
|
||||
Press space to toggle; ←/→ to move; enter to confirm and close; esc to close
|
||||
@@ -11,6 +11,7 @@
|
||||
//!
|
||||
//! - Model information (name, reasoning level)
|
||||
//! - Directory paths (current dir, project root)
|
||||
//! - Machine hostname
|
||||
//! - Git information (branch name)
|
||||
//! - Permissions profile
|
||||
//! - Approval mode
|
||||
@@ -74,6 +75,9 @@ pub(crate) enum StatusLineItem {
|
||||
)]
|
||||
ProjectRoot,
|
||||
|
||||
/// Hostname of the machine running Codex.
|
||||
Hostname,
|
||||
|
||||
/// Current git branch name (if in a repository).
|
||||
GitBranch,
|
||||
|
||||
@@ -159,6 +163,7 @@ impl StatusLineItem {
|
||||
StatusLineItem::Reasoning => "Current reasoning level",
|
||||
StatusLineItem::CurrentDir => "Current working directory",
|
||||
StatusLineItem::ProjectRoot => "Project name (omitted when unavailable)",
|
||||
StatusLineItem::Hostname => "Current machine hostname (omitted when unavailable)",
|
||||
StatusLineItem::GitBranch => "Current Git branch (omitted when unavailable)",
|
||||
StatusLineItem::PullRequestNumber => {
|
||||
"Open pull request number for the current branch (omitted when unavailable)"
|
||||
@@ -216,6 +221,7 @@ impl StatusLineItem {
|
||||
StatusLineItem::Reasoning => StatusSurfacePreviewItem::Reasoning,
|
||||
StatusLineItem::CurrentDir => StatusSurfacePreviewItem::CurrentDir,
|
||||
StatusLineItem::ProjectRoot => StatusSurfacePreviewItem::ProjectRoot,
|
||||
StatusLineItem::Hostname => StatusSurfacePreviewItem::Hostname,
|
||||
StatusLineItem::GitBranch => StatusSurfacePreviewItem::GitBranch,
|
||||
StatusLineItem::PullRequestNumber => StatusSurfacePreviewItem::PullRequestNumber,
|
||||
StatusLineItem::BranchChanges => StatusSurfacePreviewItem::BranchChanges,
|
||||
@@ -726,6 +732,38 @@ mod tests {
|
||||
assert_snapshot!(render_lines(&view, /*width*/ 100));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn setup_view_snapshot_includes_hostname() {
|
||||
let (tx_raw, _rx) = unbounded_channel::<AppEvent>();
|
||||
let view = StatusLineSetupView::new(
|
||||
Some(&[
|
||||
StatusLineItem::Hostname.to_string(),
|
||||
StatusLineItem::CurrentDir.to_string(),
|
||||
]),
|
||||
/*use_theme_colors*/ true,
|
||||
StatusSurfacePreviewData::from_iter([
|
||||
(
|
||||
StatusLineItem::Hostname.preview_item(),
|
||||
"ssh-build-01.example.com".to_string(),
|
||||
),
|
||||
(
|
||||
StatusLineItem::CurrentDir.preview_item(),
|
||||
"~/codex-rs".to_string(),
|
||||
),
|
||||
]),
|
||||
AppEventSender::new(tx_raw),
|
||||
crate::keymap::RuntimeKeymap::defaults().list,
|
||||
);
|
||||
|
||||
assert_snapshot!(
|
||||
render_lines(&view, /*width*/ 100)
|
||||
.lines()
|
||||
.map(str::trim_end)
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
fn render_lines(view: &StatusLineSetupView, width: u16) -> String {
|
||||
let height = view.desired_height(width);
|
||||
let area = Rect::new(0, 0, width, height);
|
||||
|
||||
@@ -47,7 +47,9 @@ impl StatusLineAccent {
|
||||
| StatusLineItem::ThreadCredits
|
||||
| StatusLineItem::EstimatedThreadCost => Self::Usage,
|
||||
StatusLineItem::FiveHourLimit | StatusLineItem::WeeklyLimit => Self::Limit,
|
||||
StatusLineItem::CodexVersion | StatusLineItem::SessionId => Self::Metadata,
|
||||
StatusLineItem::CodexVersion | StatusLineItem::Hostname | StatusLineItem::SessionId => {
|
||||
Self::Metadata
|
||||
}
|
||||
StatusLineItem::FastMode | StatusLineItem::RawOutput => Self::Mode,
|
||||
StatusLineItem::Permissions => Self::Mode,
|
||||
StatusLineItem::ApprovalMode => Self::Mode,
|
||||
|
||||
@@ -11,6 +11,7 @@ pub(crate) enum StatusSurfacePreviewItem {
|
||||
ProjectName,
|
||||
ProjectRoot,
|
||||
CurrentDir,
|
||||
Hostname,
|
||||
Status,
|
||||
ThreadTitle,
|
||||
GitBranch,
|
||||
@@ -46,6 +47,7 @@ impl StatusSurfacePreviewItem {
|
||||
StatusSurfacePreviewItem::ProjectName => "my-project",
|
||||
StatusSurfacePreviewItem::ProjectRoot => "my-project",
|
||||
StatusSurfacePreviewItem::CurrentDir => "~/my-project/subdir",
|
||||
StatusSurfacePreviewItem::Hostname => "my-host",
|
||||
StatusSurfacePreviewItem::Status => "Working",
|
||||
StatusSurfacePreviewItem::ThreadTitle => "thread title",
|
||||
StatusSurfacePreviewItem::GitBranch => "feat/awesome-feature",
|
||||
@@ -81,6 +83,7 @@ impl StatusSurfacePreviewItem {
|
||||
Self::ProjectName,
|
||||
Self::ProjectRoot,
|
||||
Self::CurrentDir,
|
||||
Self::Hostname,
|
||||
Self::Status,
|
||||
Self::ThreadTitle,
|
||||
Self::GitBranch,
|
||||
|
||||
Reference in new issue
Block a user