cxstatusline 0.3.0 → 0.4.0

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/README.md CHANGED
@@ -101,11 +101,67 @@ cxstatusline
101
101
  The bare command opens the configuration TUI in an interactive terminal. Choose widgets, colors
102
102
  and themes, preview, then save explicitly or press Ctrl+S. Settings live at
103
103
  `~/.config/cxstatusline/settings.json` (or your XDG config location).
104
- Custom command/weather widgets and unsupported Claude-only widgets are not included.
104
+ Claude-only widgets without a Codex data source are not included; see the widget inventory in the
105
+ project notes for the full list and reasons.
105
106
 
106
107
  For scripts, `cxstatusline render` reads a versioned JSON payload on stdin and prints ANSI rows;
107
108
  it never opens the TUI.
108
109
 
110
+ ## Custom widgets
111
+
112
+ Three widgets show your own content, with the same settings fields as ccstatusline so presets import unchanged:
113
+
114
+ | Widget | Field | Shows |
115
+ |---|---|---|
116
+ | Custom Text | `customText` | A fixed label such as `[PROD]` |
117
+ | Custom Symbol | `customSymbol` | One glyph or emoji such as `⚡` |
118
+ | Custom Command | `commandPath` | The first line a shell command prints |
119
+
120
+ ### Custom Command execution and caching
121
+
122
+ Custom Command runs `commandPath` through your shell (`/bin/sh -c`) with Codex's environment, in
123
+ the session's working directory. It receives the Codex status payload as JSON on stdin plus `terminal_width`.
124
+ Only the first non-empty line is shown; stderr is discarded. Set `preserveColors` (key `p`) to keep
125
+ the command's own colour codes; other escape sequences and control characters are always removed. Configured
126
+ background colours apply in both render modes and survive resets within the command output. `maxWidth`
127
+ (key `w`) truncates with an ellipsis. The TUI preview never runs commands. Imported presets list their
128
+ commands before you confirm.
129
+
130
+ #### Synchronous execution (default)
131
+
132
+ When `refreshMs` is unset (or `0`), commands run synchronously on **every footer redraw** (up to five
133
+ times a second while Codex streams).
134
+
135
+ Codex kills the whole statusline renderer after one second and keeps the previous frame, so
136
+ cxstatusline caps each synchronous command at **300 ms by default, 600 ms maximum** (`timeout`, editor key
137
+ `t`), and all commands on a render share a 600 ms budget. Over budget shows `[Budget]`; a slow
138
+ command shows `[Timeout]`, a failing one `[Exit: N]` or `[Cmd not found]`. Commands terminated by
139
+ external signals before the deadline report `[Signal: <name>]` rather than `[Timeout]`. Keep synchronous
140
+ commands cheap and local: `git status -s | wc -l` and `date +%H:%M` are good fits; network calls are not.
141
+
142
+ #### Background caching (`refreshMs`)
143
+
144
+ For commands that take longer or should not run on every redraw, configure `refreshMs` (key `f`).
145
+
146
+ - **Background refresh:** When `refreshMs` is set, rendering reads the latest result from disk and never
147
+ blocks the statusline or consumes renderer timeout budget. When an entry is due for an update,
148
+ cxstatusline spawns a detached background process to refresh it; the refresh outlives the render.
149
+ - **Cold start:** On the very first render before the initial background run completes, the widget shows
150
+ `[Loading]`.
151
+ - **Failures and timeouts:** A failing background command caches its exit code or error token; if a
152
+ background refresh stays outstanding or fails beyond 60 seconds, the widget settles on `[Error]` and
153
+ keeps showing `[Error]` across subsequent renders until a refresh succeeds.
154
+ - **Cache location:** Cached documents live under `~/.cache/cxstatusline/commands/` (or
155
+ `$XDG_CACHE_HOME/cxstatusline/commands/`). Deleting this cache directory at any time is completely
156
+ safe; entries are re-created automatically.
157
+ - **Eviction:** Cache entries and temporary files expire and are automatically evicted after 7 days.
158
+ - **Session sharing constraint:** The cache key is derived from `(command, cwd)`, so every Codex
159
+ session running in the same working directory shares one cache entry and one payload (the payload
160
+ written by whichever session triggered the refresh). `refreshMs` is intended for commands whose
161
+ output does not depend on specific session payload details.
162
+ - **Pipeline processes:** As with synchronous mode, `shell: true` terminates `/bin/sh` on timeout,
163
+ so child processes spawned inside a shell pipeline can outlive the cap. Avoid long-running pipelines.
164
+
109
165
  ## Update
110
166
 
111
167
  ```sh