pi-one-ui 0.3.1 → 0.5.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.
@@ -2,13 +2,7 @@ import { basename, isAbsolute, relative, sep } from "node:path";
2
2
  import type { Theme } from "@earendil-works/pi-coding-agent";
3
3
  import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
4
4
  import type { ZentuiConfig } from "../../app/config/shell.ts";
5
- import {
6
- buildContextGauge,
7
- contextColorTier,
8
- formatCount,
9
- formatCwdLabel,
10
- formatElapsedDuration,
11
- } from "../../shared/format.ts";
5
+ import { formatCwdLabel, formatElapsedDuration } from "../../shared/format.ts";
12
6
  import { sanitizeEditorMetadataText } from "./editor-metadata-format.ts";
13
7
 
14
8
  export { formatElapsedDuration } from "../../shared/format.ts";
@@ -16,6 +10,7 @@ export { formatElapsedDuration } from "../../shared/format.ts";
16
10
  import {
17
11
  EDITOR_ACCENT_FALLBACK,
18
12
  EDITOR_BORDER_FALLBACK,
13
+ renderSourceColor,
19
14
  renderStyleForSource,
20
15
  renderStyleForSourceOrFallback,
21
16
  safeThemeFg,
@@ -53,8 +48,6 @@ export type MinimalistEditorMetadata = {
53
48
  costLabel?: string;
54
49
  modelLabel?: string;
55
50
  thinkingLevel?: string;
56
- contextPercent?: number;
57
- contextWindow?: number;
58
51
  sessionName?: string;
59
52
  agentDurationMs?: number;
60
53
  agentActive?: boolean;
@@ -201,7 +194,6 @@ function renderTopRight(
201
194
  metadata: MinimalistEditorMetadata,
202
195
  uiTheme: Theme,
203
196
  config: ZentuiConfig,
204
- availableWidth: number,
205
197
  renderBorder: (text: string) => string,
206
198
  renderThinking: (text: string) => string,
207
199
  ): string {
@@ -222,11 +214,12 @@ function renderTopRight(
222
214
  const model = sanitizeEditorMetadataText(metadata.modelLabel ?? "");
223
215
  if (model) {
224
216
  parts.push(
225
- renderStyleForSourceOrFallback(
217
+ renderSourceColor(
226
218
  uiTheme,
227
219
  source,
228
220
  config.colors.editorModel,
229
- MINIMALIST_MODEL_FALLBACK,
221
+ "editorModel",
222
+ MINIMALIST_MODEL_FALLBACK.theme,
230
223
  model,
231
224
  ),
232
225
  );
@@ -235,46 +228,6 @@ function renderTopRight(
235
228
  if (thinking && thinking.toLowerCase() !== "off") {
236
229
  parts.push(renderThinking(thinking));
237
230
  }
238
- if (
239
- metadata.contextPercent !== undefined &&
240
- Number.isFinite(metadata.contextPercent)
241
- ) {
242
- const percent = Math.round(
243
- Math.max(0, Math.min(999, metadata.contextPercent)),
244
- );
245
- const tier = contextColorTier(
246
- percent,
247
- config.components.editor.styles.minimalist.contextThresholds,
248
- );
249
- const style =
250
- tier === "error"
251
- ? config.colors.contextError
252
- : tier === "warning"
253
- ? config.colors.contextWarning
254
- : config.colors.contextNormal;
255
- const total =
256
- config.components.editor.styles.minimalist.contextFormat ===
257
- "percent-total" &&
258
- metadata.contextWindow !== undefined &&
259
- Number.isFinite(metadata.contextWindow) &&
260
- metadata.contextWindow > 0
261
- ? `/${formatCount(metadata.contextWindow)}`
262
- : "";
263
- const text = `${percent}%${total}`;
264
- let context = renderStyleForSource(uiTheme, source, style, text);
265
- if (config.components.editor.styles.minimalist.contextGauge) {
266
- for (const gaugeWidth of [5, 3]) {
267
- const gauge = `[${buildContextGauge(percent, gaugeWidth, config.icons.mode === "ascii")}] ${text}`;
268
- const styledGauge = renderStyleForSource(uiTheme, source, style, gauge);
269
- const candidate = joinParts([...parts, styledGauge]);
270
- if (visibleWidth(candidate) <= availableWidth) {
271
- context = styledGauge;
272
- break;
273
- }
274
- }
275
- }
276
- parts.push(context);
277
- }
278
231
  return joinParts(parts);
279
232
  }
280
233
 
@@ -342,10 +295,12 @@ function renderBottomRight(
342
295
  ): string {
343
296
  const cwd = sanitizeEditorMetadataText(minimalistCwdLabel(metadata, config));
344
297
  return cwd
345
- ? renderStyleForSource(
298
+ ? renderSourceColor(
346
299
  uiTheme,
347
300
  config.components.editor.colorSource,
348
301
  config.colors.cwd,
302
+ "cwd",
303
+ "bold cyan",
349
304
  cwd,
350
305
  )
351
306
  : "";
@@ -435,11 +390,12 @@ export function renderMinimalistFrame({
435
390
  const activeThinking =
436
391
  thinking && thinking.toLowerCase() !== "off" ? thinking : "";
437
392
  const renderStaticBorder = (text: string) =>
438
- renderStyleForSourceOrFallback(
393
+ renderSourceColor(
439
394
  uiTheme,
440
395
  source,
441
396
  config.colors.editorBorder,
442
- EDITOR_BORDER_FALLBACK,
397
+ "editorBorder",
398
+ EDITOR_BORDER_FALLBACK.theme,
443
399
  text,
444
400
  );
445
401
  const terminalAdaptiveThinkingStyle = activeThinking
@@ -500,7 +456,6 @@ export function renderMinimalistFrame({
500
456
  );
501
457
  const topViewport = viewportLabel("above", viewport?.above);
502
458
  const topLeft = joinStyled([topViewport, topMetadata], separator);
503
- const topRightBudget = Math.max(0, width - 8 - visibleWidth(topLeft));
504
459
  const topFallbacks = [
505
460
  joinStyled([topViewport, topOperational], separator),
506
461
  topOperational,
@@ -516,7 +471,6 @@ export function renderMinimalistFrame({
516
471
  metadata,
517
472
  uiTheme,
518
473
  config,
519
- topRightBudget,
520
474
  renderBorder,
521
475
  renderThinking,
522
476
  ),