Skip to content

feat: add OpenAI Codex segment#7582

Open
Nick2bad4u wants to merge 5 commits into
JanDeDobbeleer:mainfrom
Nick2bad4u:feat/codex-segment-clean
Open

feat: add OpenAI Codex segment#7582
Nick2bad4u wants to merge 5 commits into
JanDeDobbeleer:mainfrom
Nick2bad4u:feat/codex-segment-clean

Conversation

@Nick2bad4u

Copy link
Copy Markdown

Summary

This replaces #7567 with a clean single-commit branch. The old branch accidentally picked up unrelated workflow changes from one of my local scripts, so I opened this fresh PR with only the Codex segment work.

This adds an OpenAI Codex segment and statusline command that can read Codex usage from local session transcripts. The segment supports normal Oh My Posh rendering, cache settings, templates, color/background templates, and configurable display options for model, reasoning, context, tokens, and rate-limit windows.

Validation

  • go test ./segments -run TestCodex
  • go test ./...
  • npm run build from website/
  • go run . codex
  • go run . print primary --config <temp codex config> --plain

Copilot AI review requested due to automatic review settings June 15, 2026 06:44
@Nick2bad4u Nick2bad4u mentioned this pull request Jun 15, 2026
4 tasks

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new OpenAI Codex statusline segment + CLI command, including documentation and schema support.

Changes:

  • Introduces codex segment implementation with local-session discovery and formatting utilities.
  • Adds oh-my-posh codex command that can read from stdin or discover local Codex sessions.
  • Updates docs, sidebar navigation, and JSON schema to expose the new segment/options.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
website/sidebars.js Adds Codex page to CLI segment docs navigation.
website/docs/segments/cli/codex.mdx New documentation for the Codex segment, payload, and options.
website/docs/installation/prompt.mdx Adds Codex instructions to the “Change your prompt” tab set.
themes/schema.json Registers codex type and its segment options in the config schema.
src/shell/constants.go Adds CODEX shell constant for statusline init.
src/segments/codex.go Implements Codex segment, cache keying, parsing, and formatting.
src/segments/codex_status.go Implements local JSONL session discovery and payload enrichment.
src/segments/ai.go Centralizes shared AI helpers (token formatting + gauge option keys).
src/segments/claude.go Removes duplicated helpers now shared in ai.go.
src/segments/codex_test.go Adds unit tests for Codex parsing/formatting and enabled logic.
src/segments/codex_status_test.go Adds unit tests for local session discovery behavior and errors.
src/config/segment_types.go Registers the new segment type and gob types.
src/config/default.go Adds default statusline config for Codex.
src/cli/statusline.go Extends statusline runner to allow a fallback data source when stdin is empty.
src/cli/codex.go Adds new oh-my-posh codex CLI command + discovery flags.
src/cli/codex_status.go Implements Codex local discovery data source for the CLI command.
src/cache/cache.go Adds a dedicated session cache key for Codex data.

Comment thread src/segments/codex_status.go
Comment thread src/segments/codex_status.go Outdated
Comment thread src/segments/codex.go Outdated
Comment thread src/segments/codex.go
Comment thread src/segments/codex.go Outdated
@Nick2bad4u Nick2bad4u force-pushed the feat/codex-segment-clean branch from 9cbfad4 to b988f15 Compare June 15, 2026 06:51
@Nick2bad4u Nick2bad4u force-pushed the feat/codex-segment-clean branch from b988f15 to 3dabf5e Compare June 16, 2026 04:31
Copilot AI review requested due to automatic review settings June 16, 2026 04:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Comment thread src/segments/codex_status_test.go Outdated
Comment thread src/segments/codex_status_test.go Outdated
Comment thread src/cli/statusline.go
Comment thread src/segments/codex_status.go
Comment thread src/segments/codex_status.go
Copilot AI review requested due to automatic review settings June 16, 2026 04:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Comment thread src/segments/codex_status_test.go Outdated
Comment thread src/segments/codex_status_test.go Outdated
Comment thread src/segments/codex.go
Copilot AI review requested due to automatic review settings June 16, 2026 05:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Comment on lines +19 to +23
## Sample Configuration

import Config from "@site/src/components/Config.js";

<Config
Comment thread src/cli/statusline.go
Comment on lines +52 to +57
if len(bytes.TrimSpace(stdinData)) == 0 && dataSource != nil {
stdinData, err = dataSource(cmd)
if err != nil {
log.Error(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants