ccstatusline 2.1.4 → 2.1.5

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.
Files changed (2) hide show
  1. package/dist/ccstatusline.js +395 -632
  2. package/package.json +1 -1
@@ -39365,6 +39365,15 @@ async function getExistingStatusLine() {
39365
39365
  return settings.statusLine?.command ?? null;
39366
39366
  }
39367
39367
 
39368
+ // src/utils/clone-settings.ts
39369
+ function cloneSettings(settings) {
39370
+ const cloneFn = globalThis.structuredClone;
39371
+ if (typeof cloneFn === "function") {
39372
+ return cloneFn(settings);
39373
+ }
39374
+ return JSON.parse(JSON.stringify(settings));
39375
+ }
39376
+
39368
39377
  // src/utils/config.ts
39369
39378
  import * as fs3 from "fs";
39370
39379
  import * as os3 from "os";
@@ -51469,7 +51478,7 @@ import { execSync as execSync3 } from "child_process";
51469
51478
  import * as fs5 from "fs";
51470
51479
  import * as path4 from "path";
51471
51480
  var __dirname = "/Users/sirmalloc/Projects/Personal/ccstatusline/src/utils";
51472
- var PACKAGE_VERSION = "2.1.4";
51481
+ var PACKAGE_VERSION = "2.1.5";
51473
51482
  function getPackageVersion() {
51474
51483
  if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
51475
51484
  return PACKAGE_VERSION;
@@ -51488,7 +51497,7 @@ function getPackageVersion() {
51488
51497
  }
51489
51498
  return "";
51490
51499
  }
51491
- function getTerminalWidth() {
51500
+ function probeTerminalWidth() {
51492
51501
  if (process.platform === "win32") {
51493
51502
  return null;
51494
51503
  }
@@ -51522,38 +51531,11 @@ function getTerminalWidth() {
51522
51531
  } catch {}
51523
51532
  return null;
51524
51533
  }
51534
+ function getTerminalWidth() {
51535
+ return probeTerminalWidth();
51536
+ }
51525
51537
  function canDetectTerminalWidth() {
51526
- if (process.platform === "win32") {
51527
- return false;
51528
- }
51529
- try {
51530
- const tty2 = execSync3("ps -o tty= -p $(ps -o ppid= -p $$)", {
51531
- encoding: "utf8",
51532
- stdio: ["pipe", "pipe", "ignore"],
51533
- shell: "/bin/sh"
51534
- }).trim();
51535
- if (tty2 && tty2 !== "??" && tty2 !== "?") {
51536
- const width = execSync3(`stty size < /dev/${tty2} | awk '{print $2}'`, {
51537
- encoding: "utf8",
51538
- stdio: ["pipe", "pipe", "ignore"],
51539
- shell: "/bin/sh"
51540
- }).trim();
51541
- const parsed = parseInt(width, 10);
51542
- if (!isNaN(parsed) && parsed > 0) {
51543
- return true;
51544
- }
51545
- }
51546
- } catch {}
51547
- try {
51548
- const width = execSync3("tput cols 2>/dev/null", {
51549
- encoding: "utf8",
51550
- stdio: ["pipe", "pipe", "ignore"]
51551
- }).trim();
51552
- const parsed = parseInt(width, 10);
51553
- return !isNaN(parsed) && parsed > 0;
51554
- } catch {
51555
- return false;
51556
- }
51538
+ return probeTerminalWidth() !== null;
51557
51539
  }
51558
51540
 
51559
51541
  // node_modules/ink-select-input/build/Indicator.js
@@ -52433,6 +52415,49 @@ function getGitChangeCounts(context) {
52433
52415
  };
52434
52416
  }
52435
52417
 
52418
+ // src/widgets/shared/editor-display.ts
52419
+ function makeModifierText(modifiers) {
52420
+ return modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined;
52421
+ }
52422
+
52423
+ // src/widgets/shared/metadata.ts
52424
+ function isMetadataFlagEnabled(item, key) {
52425
+ return item.metadata?.[key] === "true";
52426
+ }
52427
+ function toggleMetadataFlag(item, key) {
52428
+ return {
52429
+ ...item,
52430
+ metadata: {
52431
+ ...item.metadata,
52432
+ [key]: (!isMetadataFlagEnabled(item, key)).toString()
52433
+ }
52434
+ };
52435
+ }
52436
+
52437
+ // src/widgets/shared/git-no-git.ts
52438
+ var HIDE_NO_GIT_KEY = "hideNoGit";
52439
+ var TOGGLE_NO_GIT_ACTION = "toggle-nogit";
52440
+ var HIDE_NO_GIT_KEYBIND = {
52441
+ key: "h",
52442
+ label: "(h)ide 'no git' message",
52443
+ action: TOGGLE_NO_GIT_ACTION
52444
+ };
52445
+ function isHideNoGitEnabled(item) {
52446
+ return isMetadataFlagEnabled(item, HIDE_NO_GIT_KEY);
52447
+ }
52448
+ function getHideNoGitModifierText(item) {
52449
+ return makeModifierText(isHideNoGitEnabled(item) ? ["hide 'no git'"] : []);
52450
+ }
52451
+ function handleToggleNoGitAction(action, item) {
52452
+ if (action !== TOGGLE_NO_GIT_ACTION) {
52453
+ return null;
52454
+ }
52455
+ return toggleMetadataFlag(item, HIDE_NO_GIT_KEY);
52456
+ }
52457
+ function getHideNoGitKeybinds() {
52458
+ return [HIDE_NO_GIT_KEYBIND];
52459
+ }
52460
+
52436
52461
  // src/widgets/GitBranch.ts
52437
52462
  class GitBranchWidget {
52438
52463
  getDefaultColor() {
@@ -52448,31 +52473,16 @@ class GitBranchWidget {
52448
52473
  return "Git";
52449
52474
  }
52450
52475
  getEditorDisplay(item) {
52451
- const hideNoGit = item.metadata?.hideNoGit === "true";
52452
- const modifiers = [];
52453
- if (hideNoGit) {
52454
- modifiers.push("hide 'no git'");
52455
- }
52456
52476
  return {
52457
52477
  displayText: this.getDisplayName(),
52458
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
52478
+ modifierText: getHideNoGitModifierText(item)
52459
52479
  };
52460
52480
  }
52461
52481
  handleEditorAction(action, item) {
52462
- if (action === "toggle-nogit") {
52463
- const currentState = item.metadata?.hideNoGit === "true";
52464
- return {
52465
- ...item,
52466
- metadata: {
52467
- ...item.metadata,
52468
- hideNoGit: (!currentState).toString()
52469
- }
52470
- };
52471
- }
52472
- return null;
52482
+ return handleToggleNoGitAction(action, item);
52473
52483
  }
52474
52484
  render(item, context, settings) {
52475
- const hideNoGit = item.metadata?.hideNoGit === "true";
52485
+ const hideNoGit = isHideNoGitEnabled(item);
52476
52486
  if (context.isPreview) {
52477
52487
  return item.rawValue ? "main" : "⎇ main";
52478
52488
  }
@@ -52488,9 +52498,7 @@ class GitBranchWidget {
52488
52498
  return runGit("branch --show-current", context);
52489
52499
  }
52490
52500
  getCustomKeybinds() {
52491
- return [
52492
- { key: "h", label: "(h)ide 'no git' message", action: "toggle-nogit" }
52493
- ];
52501
+ return getHideNoGitKeybinds();
52494
52502
  }
52495
52503
  supportsRawValue() {
52496
52504
  return true;
@@ -52514,31 +52522,16 @@ class GitChangesWidget {
52514
52522
  return "Git";
52515
52523
  }
52516
52524
  getEditorDisplay(item) {
52517
- const hideNoGit = item.metadata?.hideNoGit === "true";
52518
- const modifiers = [];
52519
- if (hideNoGit) {
52520
- modifiers.push("hide 'no git'");
52521
- }
52522
52525
  return {
52523
52526
  displayText: this.getDisplayName(),
52524
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
52527
+ modifierText: getHideNoGitModifierText(item)
52525
52528
  };
52526
52529
  }
52527
52530
  handleEditorAction(action, item) {
52528
- if (action === "toggle-nogit") {
52529
- const currentState = item.metadata?.hideNoGit === "true";
52530
- return {
52531
- ...item,
52532
- metadata: {
52533
- ...item.metadata,
52534
- hideNoGit: (!currentState).toString()
52535
- }
52536
- };
52537
- }
52538
- return null;
52531
+ return handleToggleNoGitAction(action, item);
52539
52532
  }
52540
52533
  render(item, context, _settings) {
52541
- const hideNoGit = item.metadata?.hideNoGit === "true";
52534
+ const hideNoGit = isHideNoGitEnabled(item);
52542
52535
  if (context.isPreview) {
52543
52536
  return "(+42,-10)";
52544
52537
  }
@@ -52549,9 +52542,7 @@ class GitChangesWidget {
52549
52542
  return `(+${changes.insertions},-${changes.deletions})`;
52550
52543
  }
52551
52544
  getCustomKeybinds() {
52552
- return [
52553
- { key: "h", label: "(h)ide 'no git' message", action: "toggle-nogit" }
52554
- ];
52545
+ return getHideNoGitKeybinds();
52555
52546
  }
52556
52547
  supportsRawValue() {
52557
52548
  return false;
@@ -52575,31 +52566,16 @@ class GitInsertionsWidget {
52575
52566
  return "Git";
52576
52567
  }
52577
52568
  getEditorDisplay(item) {
52578
- const hideNoGit = item.metadata?.hideNoGit === "true";
52579
- const modifiers = [];
52580
- if (hideNoGit) {
52581
- modifiers.push("hide 'no git'");
52582
- }
52583
52569
  return {
52584
52570
  displayText: this.getDisplayName(),
52585
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
52571
+ modifierText: getHideNoGitModifierText(item)
52586
52572
  };
52587
52573
  }
52588
52574
  handleEditorAction(action, item) {
52589
- if (action === "toggle-nogit") {
52590
- const currentState = item.metadata?.hideNoGit === "true";
52591
- return {
52592
- ...item,
52593
- metadata: {
52594
- ...item.metadata,
52595
- hideNoGit: (!currentState).toString()
52596
- }
52597
- };
52598
- }
52599
- return null;
52575
+ return handleToggleNoGitAction(action, item);
52600
52576
  }
52601
52577
  render(item, context, _settings) {
52602
- const hideNoGit = item.metadata?.hideNoGit === "true";
52578
+ const hideNoGit = isHideNoGitEnabled(item);
52603
52579
  if (context.isPreview) {
52604
52580
  return "+42";
52605
52581
  }
@@ -52610,9 +52586,7 @@ class GitInsertionsWidget {
52610
52586
  return `+${changes.insertions}`;
52611
52587
  }
52612
52588
  getCustomKeybinds() {
52613
- return [
52614
- { key: "h", label: "(h)ide 'no git' message", action: "toggle-nogit" }
52615
- ];
52589
+ return getHideNoGitKeybinds();
52616
52590
  }
52617
52591
  supportsRawValue() {
52618
52592
  return false;
@@ -52636,31 +52610,16 @@ class GitDeletionsWidget {
52636
52610
  return "Git";
52637
52611
  }
52638
52612
  getEditorDisplay(item) {
52639
- const hideNoGit = item.metadata?.hideNoGit === "true";
52640
- const modifiers = [];
52641
- if (hideNoGit) {
52642
- modifiers.push("hide 'no git'");
52643
- }
52644
52613
  return {
52645
52614
  displayText: this.getDisplayName(),
52646
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
52615
+ modifierText: getHideNoGitModifierText(item)
52647
52616
  };
52648
52617
  }
52649
52618
  handleEditorAction(action, item) {
52650
- if (action === "toggle-nogit") {
52651
- const currentState = item.metadata?.hideNoGit === "true";
52652
- return {
52653
- ...item,
52654
- metadata: {
52655
- ...item.metadata,
52656
- hideNoGit: (!currentState).toString()
52657
- }
52658
- };
52659
- }
52660
- return null;
52619
+ return handleToggleNoGitAction(action, item);
52661
52620
  }
52662
52621
  render(item, context, _settings) {
52663
- const hideNoGit = item.metadata?.hideNoGit === "true";
52622
+ const hideNoGit = isHideNoGitEnabled(item);
52664
52623
  if (context.isPreview) {
52665
52624
  return "-10";
52666
52625
  }
@@ -52671,9 +52630,7 @@ class GitDeletionsWidget {
52671
52630
  return `-${changes.deletions}`;
52672
52631
  }
52673
52632
  getCustomKeybinds() {
52674
- return [
52675
- { key: "h", label: "(h)ide 'no git' message", action: "toggle-nogit" }
52676
- ];
52633
+ return getHideNoGitKeybinds();
52677
52634
  }
52678
52635
  supportsRawValue() {
52679
52636
  return false;
@@ -52697,31 +52654,16 @@ class GitRootDirWidget {
52697
52654
  return "Git";
52698
52655
  }
52699
52656
  getEditorDisplay(item) {
52700
- const hideNoGit = item.metadata?.hideNoGit === "true";
52701
- const modifiers = [];
52702
- if (hideNoGit) {
52703
- modifiers.push("hide 'no git'");
52704
- }
52705
52657
  return {
52706
52658
  displayText: this.getDisplayName(),
52707
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
52659
+ modifierText: getHideNoGitModifierText(item)
52708
52660
  };
52709
52661
  }
52710
52662
  handleEditorAction(action, item) {
52711
- if (action === "toggle-nogit") {
52712
- const currentState = item.metadata?.hideNoGit === "true";
52713
- return {
52714
- ...item,
52715
- metadata: {
52716
- ...item.metadata,
52717
- hideNoGit: (!currentState).toString()
52718
- }
52719
- };
52720
- }
52721
- return null;
52663
+ return handleToggleNoGitAction(action, item);
52722
52664
  }
52723
52665
  render(item, context, _settings) {
52724
- const hideNoGit = item.metadata?.hideNoGit === "true";
52666
+ const hideNoGit = isHideNoGitEnabled(item);
52725
52667
  if (context.isPreview) {
52726
52668
  return "my-repo";
52727
52669
  }
@@ -52745,9 +52687,7 @@ class GitRootDirWidget {
52745
52687
  return lastPart && lastPart.length > 0 ? lastPart : normalizedRootDir;
52746
52688
  }
52747
52689
  getCustomKeybinds() {
52748
- return [
52749
- { key: "h", label: "(h)ide 'no git' message", action: "toggle-nogit" }
52750
- ];
52690
+ return getHideNoGitKeybinds();
52751
52691
  }
52752
52692
  supportsRawValue() {
52753
52693
  return false;
@@ -52771,31 +52711,16 @@ class GitWorktreeWidget {
52771
52711
  return "Git";
52772
52712
  }
52773
52713
  getEditorDisplay(item) {
52774
- const hideNoGit = item.metadata?.hideNoGit === "true";
52775
- const modifiers = [];
52776
- if (hideNoGit) {
52777
- modifiers.push("hide 'no git'");
52778
- }
52779
52714
  return {
52780
52715
  displayText: this.getDisplayName(),
52781
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
52716
+ modifierText: getHideNoGitModifierText(item)
52782
52717
  };
52783
52718
  }
52784
52719
  handleEditorAction(action, item) {
52785
- if (action === "toggle-nogit") {
52786
- const currentState = item.metadata?.hideNoGit === "true";
52787
- return {
52788
- ...item,
52789
- metadata: {
52790
- ...item.metadata,
52791
- hideNoGit: (!currentState).toString()
52792
- }
52793
- };
52794
- }
52795
- return null;
52720
+ return handleToggleNoGitAction(action, item);
52796
52721
  }
52797
52722
  render(item, context) {
52798
- const hideNoGit = item.metadata?.hideNoGit === "true";
52723
+ const hideNoGit = isHideNoGitEnabled(item);
52799
52724
  if (context.isPreview)
52800
52725
  return item.rawValue ? "main" : "\uD81A\uDC30 main";
52801
52726
  if (!isInsideGitWorkTree(context)) {
@@ -52823,9 +52748,7 @@ class GitWorktreeWidget {
52823
52748
  return worktree.length > 0 ? worktree : null;
52824
52749
  }
52825
52750
  getCustomKeybinds() {
52826
- return [
52827
- { key: "h", label: "(h)ide 'no git' message", action: "toggle-nogit" }
52828
- ];
52751
+ return getHideNoGitKeybinds();
52829
52752
  }
52830
52753
  supportsRawValue() {
52831
52754
  return true;
@@ -53161,6 +53084,36 @@ function formatTokens(count) {
53161
53084
  return `${(count / 1000).toFixed(1)}k`;
53162
53085
  return count.toString();
53163
53086
  }
53087
+ function resolveEffectiveTerminalWidth(detectedWidth, settings, context) {
53088
+ if (!detectedWidth) {
53089
+ return null;
53090
+ }
53091
+ const flexMode = settings.flexMode;
53092
+ if (context.isPreview) {
53093
+ if (flexMode === "full") {
53094
+ return detectedWidth - 6;
53095
+ }
53096
+ if (flexMode === "full-minus-40") {
53097
+ return detectedWidth - 40;
53098
+ }
53099
+ if (flexMode === "full-until-compact") {
53100
+ return detectedWidth - 6;
53101
+ }
53102
+ return null;
53103
+ }
53104
+ if (flexMode === "full") {
53105
+ return detectedWidth - 6;
53106
+ }
53107
+ if (flexMode === "full-minus-40") {
53108
+ return detectedWidth - 40;
53109
+ }
53110
+ if (flexMode === "full-until-compact") {
53111
+ const threshold = settings.compactThreshold;
53112
+ const contextPercentage = calculateContextPercentage(context);
53113
+ return contextPercentage >= threshold ? detectedWidth - 40 : detectedWidth - 6;
53114
+ }
53115
+ return null;
53116
+ }
53164
53117
  function renderPowerlineStatusLine(widgets, settings, context, lineIndex = 0, globalSeparatorOffset = 0, preRenderedWidgets, preCalculatedMaxWidths) {
53165
53118
  const powerlineConfig = settings.powerline;
53166
53119
  const config2 = powerlineConfig ?? {};
@@ -53186,33 +53139,7 @@ function renderPowerlineStatusLine(widgets, settings, context, lineIndex = 0, gl
53186
53139
  if (filteredWidgets.length === 0)
53187
53140
  return "";
53188
53141
  const detectedWidth = context.terminalWidth ?? getTerminalWidth();
53189
- let terminalWidth = null;
53190
- if (detectedWidth) {
53191
- const flexMode = settings.flexMode;
53192
- if (context.isPreview) {
53193
- if (flexMode === "full") {
53194
- terminalWidth = detectedWidth - 6;
53195
- } else if (flexMode === "full-minus-40") {
53196
- terminalWidth = detectedWidth - 40;
53197
- } else if (flexMode === "full-until-compact") {
53198
- terminalWidth = detectedWidth - 6;
53199
- }
53200
- } else {
53201
- if (flexMode === "full") {
53202
- terminalWidth = detectedWidth - 6;
53203
- } else if (flexMode === "full-minus-40") {
53204
- terminalWidth = detectedWidth - 40;
53205
- } else if (flexMode === "full-until-compact") {
53206
- const threshold = settings.compactThreshold;
53207
- const contextPercentage = calculateContextPercentage(context);
53208
- if (contextPercentage >= threshold) {
53209
- terminalWidth = detectedWidth - 40;
53210
- } else {
53211
- terminalWidth = detectedWidth - 6;
53212
- }
53213
- }
53214
- }
53215
- }
53142
+ const terminalWidth = resolveEffectiveTerminalWidth(detectedWidth, settings, context);
53216
53143
  const widgetElements = [];
53217
53144
  let widgetColorIndex = 0;
53218
53145
  const preRenderedIndices = [];
@@ -53538,33 +53465,7 @@ function renderStatusLine(widgets, settings, context, preRenderedWidgets, preCal
53538
53465
  return applyColors(text, fgColor, bgColor, shouldBold, colorLevel);
53539
53466
  };
53540
53467
  const detectedWidth = context.terminalWidth ?? getTerminalWidth();
53541
- let terminalWidth = null;
53542
- if (detectedWidth) {
53543
- const flexMode = settings.flexMode;
53544
- if (context.isPreview) {
53545
- if (flexMode === "full") {
53546
- terminalWidth = detectedWidth - 6;
53547
- } else if (flexMode === "full-minus-40") {
53548
- terminalWidth = detectedWidth - 40;
53549
- } else if (flexMode === "full-until-compact") {
53550
- terminalWidth = detectedWidth - 6;
53551
- }
53552
- } else {
53553
- if (flexMode === "full") {
53554
- terminalWidth = detectedWidth - 6;
53555
- } else if (flexMode === "full-minus-40") {
53556
- terminalWidth = detectedWidth - 40;
53557
- } else if (flexMode === "full-until-compact") {
53558
- const threshold = settings.compactThreshold;
53559
- const contextPercentage = calculateContextPercentage(context);
53560
- if (contextPercentage >= threshold) {
53561
- terminalWidth = detectedWidth - 40;
53562
- } else {
53563
- terminalWidth = detectedWidth - 6;
53564
- }
53565
- }
53566
- }
53567
- }
53468
+ const terminalWidth = resolveEffectiveTerminalWidth(detectedWidth, settings, context);
53568
53469
  const elements = [];
53569
53470
  let hasFlexSeparator = false;
53570
53471
  for (let i = 0;i < widgets.length; i++) {
@@ -53746,6 +53647,11 @@ function renderStatusLine(widgets, settings, context, preRenderedWidgets, preCal
53746
53647
  return statusLine;
53747
53648
  }
53748
53649
 
53650
+ // src/widgets/shared/raw-or-labeled.ts
53651
+ function formatRawOrLabeledValue(item, labelPrefix, value) {
53652
+ return item.rawValue ? value : `${labelPrefix}${value}`;
53653
+ }
53654
+
53749
53655
  // src/widgets/TokensInput.ts
53750
53656
  class TokensInputWidget {
53751
53657
  getDefaultColor() {
@@ -53765,14 +53671,14 @@ class TokensInputWidget {
53765
53671
  }
53766
53672
  render(item, context, settings) {
53767
53673
  if (context.isPreview) {
53768
- return item.rawValue ? "15.2k" : "In: 15.2k";
53674
+ return formatRawOrLabeledValue(item, "In: ", "15.2k");
53769
53675
  }
53770
53676
  const inputTotalTokens = getContextWindowInputTotalTokens(context.data);
53771
53677
  if (inputTotalTokens !== null) {
53772
- return item.rawValue ? formatTokens(inputTotalTokens) : `In: ${formatTokens(inputTotalTokens)}`;
53678
+ return formatRawOrLabeledValue(item, "In: ", formatTokens(inputTotalTokens));
53773
53679
  }
53774
53680
  if (context.tokenMetrics) {
53775
- return item.rawValue ? formatTokens(context.tokenMetrics.inputTokens) : `In: ${formatTokens(context.tokenMetrics.inputTokens)}`;
53681
+ return formatRawOrLabeledValue(item, "In: ", formatTokens(context.tokenMetrics.inputTokens));
53776
53682
  }
53777
53683
  return null;
53778
53684
  }
@@ -53802,14 +53708,14 @@ class TokensOutputWidget {
53802
53708
  }
53803
53709
  render(item, context, settings) {
53804
53710
  if (context.isPreview) {
53805
- return item.rawValue ? "3.4k" : "Out: 3.4k";
53711
+ return formatRawOrLabeledValue(item, "Out: ", "3.4k");
53806
53712
  }
53807
53713
  const outputTotalTokens = getContextWindowOutputTotalTokens(context.data);
53808
53714
  if (outputTotalTokens !== null) {
53809
- return item.rawValue ? formatTokens(outputTotalTokens) : `Out: ${formatTokens(outputTotalTokens)}`;
53715
+ return formatRawOrLabeledValue(item, "Out: ", formatTokens(outputTotalTokens));
53810
53716
  }
53811
53717
  if (context.tokenMetrics) {
53812
- return item.rawValue ? formatTokens(context.tokenMetrics.outputTokens) : `Out: ${formatTokens(context.tokenMetrics.outputTokens)}`;
53718
+ return formatRawOrLabeledValue(item, "Out: ", formatTokens(context.tokenMetrics.outputTokens));
53813
53719
  }
53814
53720
  return null;
53815
53721
  }
@@ -53839,10 +53745,10 @@ class TokensCachedWidget {
53839
53745
  }
53840
53746
  render(item, context, settings) {
53841
53747
  if (context.isPreview) {
53842
- return item.rawValue ? "12k" : "Cached: 12k";
53748
+ return formatRawOrLabeledValue(item, "Cached: ", "12k");
53843
53749
  }
53844
53750
  if (context.tokenMetrics) {
53845
- return item.rawValue ? formatTokens(context.tokenMetrics.cachedTokens) : `Cached: ${formatTokens(context.tokenMetrics.cachedTokens)}`;
53751
+ return formatRawOrLabeledValue(item, "Cached: ", formatTokens(context.tokenMetrics.cachedTokens));
53846
53752
  }
53847
53753
  return null;
53848
53754
  }
@@ -53872,10 +53778,10 @@ class TokensTotalWidget {
53872
53778
  }
53873
53779
  render(item, context, settings) {
53874
53780
  if (context.isPreview) {
53875
- return item.rawValue ? "30.6k" : "Total: 30.6k";
53781
+ return formatRawOrLabeledValue(item, "Total: ", "30.6k");
53876
53782
  }
53877
53783
  if (context.tokenMetrics) {
53878
- return item.rawValue ? formatTokens(context.tokenMetrics.totalTokens) : `Total: ${formatTokens(context.tokenMetrics.totalTokens)}`;
53784
+ return formatRawOrLabeledValue(item, "Total: ", formatTokens(context.tokenMetrics.totalTokens));
53879
53785
  }
53880
53786
  return null;
53881
53787
  }
@@ -53923,6 +53829,22 @@ class ContextLengthWidget {
53923
53829
  return true;
53924
53830
  }
53925
53831
  }
53832
+ // src/widgets/shared/context-inverse.ts
53833
+ var INVERSE_KEY = "inverse";
53834
+ var TOGGLE_INVERSE_ACTION = "toggle-inverse";
53835
+ function isContextInverse(item) {
53836
+ return isMetadataFlagEnabled(item, INVERSE_KEY);
53837
+ }
53838
+ function getContextInverseModifierText(item) {
53839
+ return makeModifierText(isContextInverse(item) ? ["remaining"] : []);
53840
+ }
53841
+ function handleContextInverseAction(action, item) {
53842
+ if (action !== TOGGLE_INVERSE_ACTION) {
53843
+ return null;
53844
+ }
53845
+ return toggleMetadataFlag(item, INVERSE_KEY);
53846
+ }
53847
+
53926
53848
  // src/widgets/ContextPercentage.ts
53927
53849
  class ContextPercentageWidget {
53928
53850
  getDefaultColor() {
@@ -53938,39 +53860,24 @@ class ContextPercentageWidget {
53938
53860
  return "Context";
53939
53861
  }
53940
53862
  getEditorDisplay(item) {
53941
- const isInverse = item.metadata?.inverse === "true";
53942
- const modifiers = [];
53943
- if (isInverse) {
53944
- modifiers.push("remaining");
53945
- }
53946
53863
  return {
53947
53864
  displayText: this.getDisplayName(),
53948
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
53865
+ modifierText: getContextInverseModifierText(item)
53949
53866
  };
53950
53867
  }
53951
53868
  handleEditorAction(action, item) {
53952
- if (action === "toggle-inverse") {
53953
- const currentState = item.metadata?.inverse === "true";
53954
- return {
53955
- ...item,
53956
- metadata: {
53957
- ...item.metadata,
53958
- inverse: (!currentState).toString()
53959
- }
53960
- };
53961
- }
53962
- return null;
53869
+ return handleContextInverseAction(action, item);
53963
53870
  }
53964
53871
  render(item, context, settings) {
53965
- const isInverse = item.metadata?.inverse === "true";
53872
+ const isInverse = isContextInverse(item);
53966
53873
  const contextWindowMetrics = getContextWindowMetrics(context.data);
53967
53874
  if (context.isPreview) {
53968
53875
  const previewValue = isInverse ? "90.7%" : "9.3%";
53969
- return item.rawValue ? previewValue : `Ctx: ${previewValue}`;
53876
+ return formatRawOrLabeledValue(item, "Ctx: ", previewValue);
53970
53877
  }
53971
53878
  if (contextWindowMetrics.usedPercentage !== null) {
53972
53879
  const displayPercentage = isInverse ? 100 - contextWindowMetrics.usedPercentage : contextWindowMetrics.usedPercentage;
53973
- return item.rawValue ? `${displayPercentage.toFixed(1)}%` : `Ctx: ${displayPercentage.toFixed(1)}%`;
53880
+ return formatRawOrLabeledValue(item, "Ctx: ", `${displayPercentage.toFixed(1)}%`);
53974
53881
  }
53975
53882
  if (context.tokenMetrics) {
53976
53883
  const model = context.data?.model;
@@ -53978,7 +53885,7 @@ class ContextPercentageWidget {
53978
53885
  const contextConfig = getContextConfig(modelId, contextWindowMetrics.windowSize);
53979
53886
  const usedPercentage = Math.min(100, context.tokenMetrics.contextLength / contextConfig.maxTokens * 100);
53980
53887
  const displayPercentage = isInverse ? 100 - usedPercentage : usedPercentage;
53981
- return item.rawValue ? `${displayPercentage.toFixed(1)}%` : `Ctx: ${displayPercentage.toFixed(1)}%`;
53888
+ return formatRawOrLabeledValue(item, "Ctx: ", `${displayPercentage.toFixed(1)}%`);
53982
53889
  }
53983
53890
  return null;
53984
53891
  }
@@ -54009,48 +53916,33 @@ class ContextPercentageUsableWidget {
54009
53916
  return "Context";
54010
53917
  }
54011
53918
  getEditorDisplay(item) {
54012
- const isInverse = item.metadata?.inverse === "true";
54013
- const modifiers = [];
54014
- if (isInverse) {
54015
- modifiers.push("remaining");
54016
- }
54017
53919
  return {
54018
53920
  displayText: this.getDisplayName(),
54019
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
53921
+ modifierText: getContextInverseModifierText(item)
54020
53922
  };
54021
53923
  }
54022
53924
  handleEditorAction(action, item) {
54023
- if (action === "toggle-inverse") {
54024
- const currentState = item.metadata?.inverse === "true";
54025
- return {
54026
- ...item,
54027
- metadata: {
54028
- ...item.metadata,
54029
- inverse: (!currentState).toString()
54030
- }
54031
- };
54032
- }
54033
- return null;
53925
+ return handleContextInverseAction(action, item);
54034
53926
  }
54035
53927
  render(item, context, settings) {
54036
- const isInverse = item.metadata?.inverse === "true";
53928
+ const isInverse = isContextInverse(item);
54037
53929
  const model = context.data?.model;
54038
53930
  const modelId = typeof model === "string" ? model : model?.id;
54039
53931
  const contextWindowMetrics = getContextWindowMetrics(context.data);
54040
53932
  const contextConfig = getContextConfig(modelId, contextWindowMetrics.windowSize);
54041
53933
  if (context.isPreview) {
54042
53934
  const previewValue = isInverse ? "88.4%" : "11.6%";
54043
- return item.rawValue ? previewValue : `Ctx(u): ${previewValue}`;
53935
+ return formatRawOrLabeledValue(item, "Ctx(u): ", previewValue);
54044
53936
  }
54045
53937
  if (contextWindowMetrics.contextLengthTokens !== null) {
54046
53938
  const usedPercentage = Math.min(100, contextWindowMetrics.contextLengthTokens / contextConfig.usableTokens * 100);
54047
53939
  const displayPercentage = isInverse ? 100 - usedPercentage : usedPercentage;
54048
- return item.rawValue ? `${displayPercentage.toFixed(1)}%` : `Ctx(u): ${displayPercentage.toFixed(1)}%`;
53940
+ return formatRawOrLabeledValue(item, "Ctx(u): ", `${displayPercentage.toFixed(1)}%`);
54049
53941
  }
54050
53942
  if (context.tokenMetrics) {
54051
53943
  const usedPercentage = Math.min(100, context.tokenMetrics.contextLength / contextConfig.usableTokens * 100);
54052
53944
  const displayPercentage = isInverse ? 100 - usedPercentage : usedPercentage;
54053
- return item.rawValue ? `${displayPercentage.toFixed(1)}%` : `Ctx(u): ${displayPercentage.toFixed(1)}%`;
53945
+ return formatRawOrLabeledValue(item, "Ctx(u): ", `${displayPercentage.toFixed(1)}%`);
54054
53946
  }
54055
53947
  return null;
54056
53948
  }
@@ -56069,17 +55961,56 @@ function makeUsageProgressBar(percent, width = 15) {
56069
55961
  return "[" + "█".repeat(filled) + "░".repeat(empty2) + "]";
56070
55962
  }
56071
55963
 
56072
- // src/widgets/BlockTimer.ts
56073
- function getDisplayMode(item) {
55964
+ // src/widgets/shared/usage-display.ts
55965
+ function getUsageDisplayMode(item) {
56074
55966
  const mode = item.metadata?.display;
56075
55967
  if (mode === "progress" || mode === "progress-short") {
56076
55968
  return mode;
56077
55969
  }
56078
55970
  return "time";
56079
55971
  }
56080
- function isInverted(item) {
56081
- return item.metadata?.invert === "true";
55972
+ function isUsageProgressMode(mode) {
55973
+ return mode === "progress" || mode === "progress-short";
55974
+ }
55975
+ function getUsageProgressBarWidth(mode) {
55976
+ return mode === "progress" ? 32 : 16;
55977
+ }
55978
+ function isUsageInverted(item) {
55979
+ return isMetadataFlagEnabled(item, "invert");
56082
55980
  }
55981
+ function getUsageDisplayModifierText(item) {
55982
+ const mode = getUsageDisplayMode(item);
55983
+ const modifiers = [];
55984
+ if (mode === "progress") {
55985
+ modifiers.push("progress bar");
55986
+ } else if (mode === "progress-short") {
55987
+ modifiers.push("short bar");
55988
+ }
55989
+ if (isUsageInverted(item)) {
55990
+ modifiers.push("inverted");
55991
+ }
55992
+ return makeModifierText(modifiers);
55993
+ }
55994
+ function cycleUsageDisplayMode(item) {
55995
+ const currentMode = getUsageDisplayMode(item);
55996
+ const nextMode = currentMode === "time" ? "progress" : currentMode === "progress" ? "progress-short" : "time";
55997
+ const nextMetadata = {
55998
+ ...item.metadata ?? {},
55999
+ display: nextMode
56000
+ };
56001
+ if (nextMode === "time") {
56002
+ delete nextMetadata.invert;
56003
+ }
56004
+ return {
56005
+ ...item,
56006
+ metadata: nextMetadata
56007
+ };
56008
+ }
56009
+ function toggleUsageInverted(item) {
56010
+ return toggleMetadataFlag(item, "invert");
56011
+ }
56012
+
56013
+ // src/widgets/BlockTimer.ts
56083
56014
  function makeTimerProgressBar(percent, width) {
56084
56015
  const clampedPercent = Math.max(0, Math.min(100, percent));
56085
56016
  const filledWidth = Math.floor(clampedPercent / 100 * width);
@@ -56101,90 +56032,51 @@ class BlockTimerWidget {
56101
56032
  return "Usage";
56102
56033
  }
56103
56034
  getEditorDisplay(item) {
56104
- const mode = getDisplayMode(item);
56105
- const modifiers = [];
56106
- if (mode === "progress") {
56107
- modifiers.push("progress bar");
56108
- } else if (mode === "progress-short") {
56109
- modifiers.push("short bar");
56110
- }
56111
- if (isInverted(item)) {
56112
- modifiers.push("inverted");
56113
- }
56114
56035
  return {
56115
56036
  displayText: this.getDisplayName(),
56116
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
56037
+ modifierText: getUsageDisplayModifierText(item)
56117
56038
  };
56118
56039
  }
56119
56040
  handleEditorAction(action, item) {
56120
56041
  if (action === "toggle-progress") {
56121
- const currentMode = getDisplayMode(item);
56122
- let nextMode;
56123
- if (currentMode === "time") {
56124
- nextMode = "progress";
56125
- } else if (currentMode === "progress") {
56126
- nextMode = "progress-short";
56127
- } else {
56128
- nextMode = "time";
56129
- }
56130
- const nextMetadata = {
56131
- ...item.metadata ?? {},
56132
- display: nextMode
56133
- };
56134
- if (nextMode === "time") {
56135
- delete nextMetadata.invert;
56136
- }
56137
- return {
56138
- ...item,
56139
- metadata: nextMetadata
56140
- };
56042
+ return cycleUsageDisplayMode(item);
56141
56043
  }
56142
56044
  if (action === "toggle-invert") {
56143
- return {
56144
- ...item,
56145
- metadata: {
56146
- ...item.metadata,
56147
- invert: (!isInverted(item)).toString()
56148
- }
56149
- };
56045
+ return toggleUsageInverted(item);
56150
56046
  }
56151
56047
  return null;
56152
56048
  }
56153
56049
  render(item, context, settings) {
56154
- const displayMode = getDisplayMode(item);
56155
- const inverted = isInverted(item);
56050
+ const displayMode = getUsageDisplayMode(item);
56051
+ const inverted = isUsageInverted(item);
56156
56052
  if (context.isPreview) {
56157
56053
  const previewPercent = inverted ? 26.1 : 73.9;
56158
- const prefix = item.rawValue ? "" : "Block ";
56159
- if (displayMode === "progress" || displayMode === "progress-short") {
56160
- const barWidth = displayMode === "progress" ? 32 : 16;
56054
+ if (isUsageProgressMode(displayMode)) {
56055
+ const barWidth = getUsageProgressBarWidth(displayMode);
56161
56056
  const progressBar = makeTimerProgressBar(previewPercent, barWidth);
56162
- return `${prefix}[${progressBar}] ${previewPercent.toFixed(1)}%`;
56057
+ return formatRawOrLabeledValue(item, "Block ", `[${progressBar}] ${previewPercent.toFixed(1)}%`);
56163
56058
  }
56164
- return item.rawValue ? "3hr 45m" : "Block: 3hr 45m";
56059
+ return formatRawOrLabeledValue(item, "Block: ", "3hr 45m");
56165
56060
  }
56166
56061
  const usageData = fetchUsageData();
56167
56062
  const window2 = resolveUsageWindowWithFallback(usageData, context.blockMetrics);
56168
56063
  if (!window2) {
56169
- if (displayMode === "progress" || displayMode === "progress-short") {
56170
- const barWidth = displayMode === "progress" ? 32 : 16;
56064
+ if (isUsageProgressMode(displayMode)) {
56065
+ const barWidth = getUsageProgressBarWidth(displayMode);
56171
56066
  const emptyBar = "░".repeat(barWidth);
56172
- return item.rawValue ? `[${emptyBar}] 0.0%` : `Block [${emptyBar}] 0.0%`;
56067
+ return formatRawOrLabeledValue(item, "Block ", `[${emptyBar}] 0.0%`);
56173
56068
  }
56174
- return item.rawValue ? "0hr 0m" : "Block: 0hr 0m";
56069
+ return formatRawOrLabeledValue(item, "Block: ", "0hr 0m");
56175
56070
  }
56176
- if (displayMode === "progress" || displayMode === "progress-short") {
56177
- const barWidth = displayMode === "progress" ? 32 : 16;
56071
+ if (isUsageProgressMode(displayMode)) {
56072
+ const barWidth = getUsageProgressBarWidth(displayMode);
56178
56073
  const percent = inverted ? window2.remainingPercent : window2.elapsedPercent;
56179
56074
  const progressBar = makeTimerProgressBar(percent, barWidth);
56180
56075
  const percentage = percent.toFixed(1);
56181
- if (item.rawValue) {
56182
- return `[${progressBar}] ${percentage}%`;
56183
- }
56184
- return `Block [${progressBar}] ${percentage}%`;
56076
+ return formatRawOrLabeledValue(item, "Block ", `[${progressBar}] ${percentage}%`);
56185
56077
  }
56186
56078
  const elapsedTime = formatUsageDuration(window2.elapsedMs);
56187
- return item.rawValue ? elapsedTime : `Block: ${elapsedTime}`;
56079
+ return formatRawOrLabeledValue(item, "Block: ", elapsedTime);
56188
56080
  }
56189
56081
  getCustomKeybinds() {
56190
56082
  return [
@@ -56619,17 +56511,6 @@ class SessionNameWidget {
56619
56511
  }
56620
56512
  }
56621
56513
  // src/widgets/SessionUsage.ts
56622
- function getDisplayMode2(item) {
56623
- const mode = item.metadata?.display;
56624
- if (mode === "progress" || mode === "progress-short") {
56625
- return mode;
56626
- }
56627
- return "time";
56628
- }
56629
- function isInverted2(item) {
56630
- return item.metadata?.invert === "true";
56631
- }
56632
-
56633
56514
  class SessionUsageWidget {
56634
56515
  getDefaultColor() {
56635
56516
  return "brightBlue";
@@ -56644,67 +56525,32 @@ class SessionUsageWidget {
56644
56525
  return "Usage";
56645
56526
  }
56646
56527
  getEditorDisplay(item) {
56647
- const mode = getDisplayMode2(item);
56648
- const modifiers = [];
56649
- if (mode === "progress") {
56650
- modifiers.push("progress bar");
56651
- } else if (mode === "progress-short") {
56652
- modifiers.push("short bar");
56653
- }
56654
- if (isInverted2(item)) {
56655
- modifiers.push("inverted");
56656
- }
56657
56528
  return {
56658
56529
  displayText: this.getDisplayName(),
56659
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
56530
+ modifierText: getUsageDisplayModifierText(item)
56660
56531
  };
56661
56532
  }
56662
56533
  handleEditorAction(action, item) {
56663
56534
  if (action === "toggle-progress") {
56664
- const currentMode = getDisplayMode2(item);
56665
- let nextMode;
56666
- if (currentMode === "time") {
56667
- nextMode = "progress";
56668
- } else if (currentMode === "progress") {
56669
- nextMode = "progress-short";
56670
- } else {
56671
- nextMode = "time";
56672
- }
56673
- const nextMetadata = {
56674
- ...item.metadata ?? {},
56675
- display: nextMode
56676
- };
56677
- if (nextMode === "time") {
56678
- delete nextMetadata.invert;
56679
- }
56680
- return {
56681
- ...item,
56682
- metadata: nextMetadata
56683
- };
56535
+ return cycleUsageDisplayMode(item);
56684
56536
  }
56685
56537
  if (action === "toggle-invert") {
56686
- return {
56687
- ...item,
56688
- metadata: {
56689
- ...item.metadata,
56690
- invert: (!isInverted2(item)).toString()
56691
- }
56692
- };
56538
+ return toggleUsageInverted(item);
56693
56539
  }
56694
56540
  return null;
56695
56541
  }
56696
56542
  render(item, context, settings) {
56697
- const displayMode = getDisplayMode2(item);
56698
- const inverted = isInverted2(item);
56543
+ const displayMode = getUsageDisplayMode(item);
56544
+ const inverted = isUsageInverted(item);
56699
56545
  if (context.isPreview) {
56700
56546
  const previewPercent = 20;
56701
56547
  const renderedPercent = inverted ? 100 - previewPercent : previewPercent;
56702
- if (displayMode === "progress" || displayMode === "progress-short") {
56703
- const width = displayMode === "progress" ? 32 : 16;
56548
+ if (isUsageProgressMode(displayMode)) {
56549
+ const width = getUsageProgressBarWidth(displayMode);
56704
56550
  const progressDisplay = `${makeUsageProgressBar(renderedPercent, width)} ${renderedPercent.toFixed(1)}%`;
56705
- return item.rawValue ? progressDisplay : `Session: ${progressDisplay}`;
56551
+ return formatRawOrLabeledValue(item, "Session: ", progressDisplay);
56706
56552
  }
56707
- return item.rawValue ? `${previewPercent.toFixed(1)}%` : `Session: ${previewPercent.toFixed(1)}%`;
56553
+ return formatRawOrLabeledValue(item, "Session: ", `${previewPercent.toFixed(1)}%`);
56708
56554
  }
56709
56555
  const data = fetchUsageData();
56710
56556
  if (data.error)
@@ -56712,13 +56558,13 @@ class SessionUsageWidget {
56712
56558
  if (data.sessionUsage === undefined)
56713
56559
  return null;
56714
56560
  const percent = Math.max(0, Math.min(100, data.sessionUsage));
56715
- if (displayMode === "progress" || displayMode === "progress-short") {
56716
- const width = displayMode === "progress" ? 32 : 16;
56561
+ if (isUsageProgressMode(displayMode)) {
56562
+ const width = getUsageProgressBarWidth(displayMode);
56717
56563
  const renderedPercent = inverted ? 100 - percent : percent;
56718
56564
  const progressDisplay = `${makeUsageProgressBar(renderedPercent, width)} ${renderedPercent.toFixed(1)}%`;
56719
- return item.rawValue ? progressDisplay : `Session: ${progressDisplay}`;
56565
+ return formatRawOrLabeledValue(item, "Session: ", progressDisplay);
56720
56566
  }
56721
- return item.rawValue ? `${percent.toFixed(1)}%` : `Session: ${percent.toFixed(1)}%`;
56567
+ return formatRawOrLabeledValue(item, "Session: ", `${percent.toFixed(1)}%`);
56722
56568
  }
56723
56569
  getCustomKeybinds() {
56724
56570
  return [
@@ -56734,17 +56580,6 @@ class SessionUsageWidget {
56734
56580
  }
56735
56581
  }
56736
56582
  // src/widgets/WeeklyUsage.ts
56737
- function getDisplayMode3(item) {
56738
- const mode = item.metadata?.display;
56739
- if (mode === "progress" || mode === "progress-short") {
56740
- return mode;
56741
- }
56742
- return "time";
56743
- }
56744
- function isInverted3(item) {
56745
- return item.metadata?.invert === "true";
56746
- }
56747
-
56748
56583
  class WeeklyUsageWidget {
56749
56584
  getDefaultColor() {
56750
56585
  return "brightBlue";
@@ -56759,67 +56594,32 @@ class WeeklyUsageWidget {
56759
56594
  return "Usage";
56760
56595
  }
56761
56596
  getEditorDisplay(item) {
56762
- const mode = getDisplayMode3(item);
56763
- const modifiers = [];
56764
- if (mode === "progress") {
56765
- modifiers.push("progress bar");
56766
- } else if (mode === "progress-short") {
56767
- modifiers.push("short bar");
56768
- }
56769
- if (isInverted3(item)) {
56770
- modifiers.push("inverted");
56771
- }
56772
56597
  return {
56773
56598
  displayText: this.getDisplayName(),
56774
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
56599
+ modifierText: getUsageDisplayModifierText(item)
56775
56600
  };
56776
56601
  }
56777
56602
  handleEditorAction(action, item) {
56778
56603
  if (action === "toggle-progress") {
56779
- const currentMode = getDisplayMode3(item);
56780
- let nextMode;
56781
- if (currentMode === "time") {
56782
- nextMode = "progress";
56783
- } else if (currentMode === "progress") {
56784
- nextMode = "progress-short";
56785
- } else {
56786
- nextMode = "time";
56787
- }
56788
- const nextMetadata = {
56789
- ...item.metadata ?? {},
56790
- display: nextMode
56791
- };
56792
- if (nextMode === "time") {
56793
- delete nextMetadata.invert;
56794
- }
56795
- return {
56796
- ...item,
56797
- metadata: nextMetadata
56798
- };
56604
+ return cycleUsageDisplayMode(item);
56799
56605
  }
56800
56606
  if (action === "toggle-invert") {
56801
- return {
56802
- ...item,
56803
- metadata: {
56804
- ...item.metadata,
56805
- invert: (!isInverted3(item)).toString()
56806
- }
56807
- };
56607
+ return toggleUsageInverted(item);
56808
56608
  }
56809
56609
  return null;
56810
56610
  }
56811
56611
  render(item, context, settings) {
56812
- const displayMode = getDisplayMode3(item);
56813
- const inverted = isInverted3(item);
56612
+ const displayMode = getUsageDisplayMode(item);
56613
+ const inverted = isUsageInverted(item);
56814
56614
  if (context.isPreview) {
56815
56615
  const previewPercent = 12;
56816
56616
  const renderedPercent = inverted ? 100 - previewPercent : previewPercent;
56817
- if (displayMode === "progress" || displayMode === "progress-short") {
56818
- const width = displayMode === "progress" ? 32 : 16;
56617
+ if (isUsageProgressMode(displayMode)) {
56618
+ const width = getUsageProgressBarWidth(displayMode);
56819
56619
  const progressDisplay = `${makeUsageProgressBar(renderedPercent, width)} ${renderedPercent.toFixed(1)}%`;
56820
- return item.rawValue ? progressDisplay : `Weekly: ${progressDisplay}`;
56620
+ return formatRawOrLabeledValue(item, "Weekly: ", progressDisplay);
56821
56621
  }
56822
- return item.rawValue ? `${previewPercent.toFixed(1)}%` : `Weekly: ${previewPercent.toFixed(1)}%`;
56622
+ return formatRawOrLabeledValue(item, "Weekly: ", `${previewPercent.toFixed(1)}%`);
56823
56623
  }
56824
56624
  const data = fetchUsageData();
56825
56625
  if (data.error)
@@ -56827,13 +56627,13 @@ class WeeklyUsageWidget {
56827
56627
  if (data.weeklyUsage === undefined)
56828
56628
  return null;
56829
56629
  const percent = Math.max(0, Math.min(100, data.weeklyUsage));
56830
- if (displayMode === "progress" || displayMode === "progress-short") {
56831
- const width = displayMode === "progress" ? 32 : 16;
56630
+ if (isUsageProgressMode(displayMode)) {
56631
+ const width = getUsageProgressBarWidth(displayMode);
56832
56632
  const renderedPercent = inverted ? 100 - percent : percent;
56833
56633
  const progressDisplay = `${makeUsageProgressBar(renderedPercent, width)} ${renderedPercent.toFixed(1)}%`;
56834
- return item.rawValue ? progressDisplay : `Weekly: ${progressDisplay}`;
56634
+ return formatRawOrLabeledValue(item, "Weekly: ", progressDisplay);
56835
56635
  }
56836
- return item.rawValue ? `${percent.toFixed(1)}%` : `Weekly: ${percent.toFixed(1)}%`;
56636
+ return formatRawOrLabeledValue(item, "Weekly: ", `${percent.toFixed(1)}%`);
56837
56637
  }
56838
56638
  getCustomKeybinds() {
56839
56639
  return [
@@ -56849,16 +56649,6 @@ class WeeklyUsageWidget {
56849
56649
  }
56850
56650
  }
56851
56651
  // src/widgets/ResetTimer.ts
56852
- function getDisplayMode4(item) {
56853
- const mode = item.metadata?.display;
56854
- if (mode === "progress" || mode === "progress-short") {
56855
- return mode;
56856
- }
56857
- return "time";
56858
- }
56859
- function isInverted4(item) {
56860
- return item.metadata?.invert === "true";
56861
- }
56862
56652
  function makeTimerProgressBar2(percent, width) {
56863
56653
  const clampedPercent = Math.max(0, Math.min(100, percent));
56864
56654
  const filledWidth = Math.floor(clampedPercent / 100 * width);
@@ -56880,67 +56670,31 @@ class ResetTimerWidget {
56880
56670
  return "Usage";
56881
56671
  }
56882
56672
  getEditorDisplay(item) {
56883
- const mode = getDisplayMode4(item);
56884
- const modifiers = [];
56885
- if (mode === "progress") {
56886
- modifiers.push("progress bar");
56887
- } else if (mode === "progress-short") {
56888
- modifiers.push("short bar");
56889
- }
56890
- if (isInverted4(item)) {
56891
- modifiers.push("inverted");
56892
- }
56893
56673
  return {
56894
56674
  displayText: this.getDisplayName(),
56895
- modifierText: modifiers.length > 0 ? `(${modifiers.join(", ")})` : undefined
56675
+ modifierText: getUsageDisplayModifierText(item)
56896
56676
  };
56897
56677
  }
56898
56678
  handleEditorAction(action, item) {
56899
56679
  if (action === "toggle-progress") {
56900
- const currentMode = getDisplayMode4(item);
56901
- let nextMode;
56902
- if (currentMode === "time") {
56903
- nextMode = "progress";
56904
- } else if (currentMode === "progress") {
56905
- nextMode = "progress-short";
56906
- } else {
56907
- nextMode = "time";
56908
- }
56909
- const nextMetadata = {
56910
- ...item.metadata ?? {},
56911
- display: nextMode
56912
- };
56913
- if (nextMode === "time") {
56914
- delete nextMetadata.invert;
56915
- }
56916
- return {
56917
- ...item,
56918
- metadata: nextMetadata
56919
- };
56680
+ return cycleUsageDisplayMode(item);
56920
56681
  }
56921
56682
  if (action === "toggle-invert") {
56922
- return {
56923
- ...item,
56924
- metadata: {
56925
- ...item.metadata,
56926
- invert: (!isInverted4(item)).toString()
56927
- }
56928
- };
56683
+ return toggleUsageInverted(item);
56929
56684
  }
56930
56685
  return null;
56931
56686
  }
56932
56687
  render(item, context, settings) {
56933
- const displayMode = getDisplayMode4(item);
56934
- const inverted = isInverted4(item);
56688
+ const displayMode = getUsageDisplayMode(item);
56689
+ const inverted = isUsageInverted(item);
56935
56690
  if (context.isPreview) {
56936
56691
  const previewPercent = inverted ? 90 : 10;
56937
- const prefix = item.rawValue ? "" : "Reset ";
56938
- if (displayMode === "progress" || displayMode === "progress-short") {
56939
- const barWidth = displayMode === "progress" ? 32 : 16;
56692
+ if (isUsageProgressMode(displayMode)) {
56693
+ const barWidth = getUsageProgressBarWidth(displayMode);
56940
56694
  const progressBar = makeTimerProgressBar2(previewPercent, barWidth);
56941
- return `${prefix}[${progressBar}] ${previewPercent.toFixed(1)}%`;
56695
+ return formatRawOrLabeledValue(item, "Reset ", `[${progressBar}] ${previewPercent.toFixed(1)}%`);
56942
56696
  }
56943
- return item.rawValue ? "4hr 30m" : "Reset: 4hr 30m";
56697
+ return formatRawOrLabeledValue(item, "Reset: ", "4hr 30m");
56944
56698
  }
56945
56699
  const usageData = fetchUsageData();
56946
56700
  const window2 = resolveUsageWindowWithFallback(usageData, context.blockMetrics);
@@ -56950,18 +56704,15 @@ class ResetTimerWidget {
56950
56704
  }
56951
56705
  return null;
56952
56706
  }
56953
- if (displayMode === "progress" || displayMode === "progress-short") {
56954
- const barWidth = displayMode === "progress" ? 32 : 16;
56707
+ if (isUsageProgressMode(displayMode)) {
56708
+ const barWidth = getUsageProgressBarWidth(displayMode);
56955
56709
  const percent = inverted ? window2.remainingPercent : window2.elapsedPercent;
56956
56710
  const progressBar = makeTimerProgressBar2(percent, barWidth);
56957
56711
  const percentage = percent.toFixed(1);
56958
- if (item.rawValue) {
56959
- return `[${progressBar}] ${percentage}%`;
56960
- }
56961
- return `Reset [${progressBar}] ${percentage}%`;
56712
+ return formatRawOrLabeledValue(item, "Reset ", `[${progressBar}] ${percentage}%`);
56962
56713
  }
56963
56714
  const remainingTime = formatUsageDuration(window2.remainingMs);
56964
- return item.rawValue ? remainingTime : `Reset: ${remainingTime}`;
56715
+ return formatRawOrLabeledValue(item, "Reset: ", remainingTime);
56965
56716
  }
56966
56717
  getCustomKeybinds() {
56967
56718
  return [
@@ -56977,7 +56728,7 @@ class ResetTimerWidget {
56977
56728
  }
56978
56729
  }
56979
56730
  // src/widgets/ContextBar.ts
56980
- function getDisplayMode5(item) {
56731
+ function getDisplayMode(item) {
56981
56732
  return item.metadata?.display === "progress" ? "progress" : "progress-short";
56982
56733
  }
56983
56734
 
@@ -56995,7 +56746,7 @@ class ContextBarWidget {
56995
56746
  return "Context";
56996
56747
  }
56997
56748
  getEditorDisplay(item) {
56998
- const mode = getDisplayMode5(item);
56749
+ const mode = getDisplayMode(item);
56999
56750
  const modifiers = [];
57000
56751
  if (mode === "progress-short") {
57001
56752
  modifiers.push("short bar");
@@ -57009,7 +56760,7 @@ class ContextBarWidget {
57009
56760
  if (action !== "toggle-progress") {
57010
56761
  return null;
57011
56762
  }
57012
- const currentMode = getDisplayMode5(item);
56763
+ const currentMode = getDisplayMode(item);
57013
56764
  const nextMode = currentMode === "progress-short" ? "progress" : "progress-short";
57014
56765
  return {
57015
56766
  ...item,
@@ -57020,7 +56771,7 @@ class ContextBarWidget {
57020
56771
  };
57021
56772
  }
57022
56773
  render(item, context, settings) {
57023
- const displayMode = getDisplayMode5(item);
56774
+ const displayMode = getDisplayMode(item);
57024
56775
  const barWidth = displayMode === "progress" ? 32 : 16;
57025
56776
  if (context.isPreview) {
57026
56777
  const previewDisplay = `${makeUsageProgressBar(25, barWidth)} 50k/200k (25%)`;
@@ -59659,6 +59410,30 @@ var MainMenu = ({ onSelect, isClaudeInstalled, hasChanges, initialSelection = 0,
59659
59410
  var import_react42 = __toESM(require_react(), 1);
59660
59411
  import * as os10 from "os";
59661
59412
 
59413
+ // src/utils/powerline-settings.ts
59414
+ function resolveEnabledPowerlineTheme(theme) {
59415
+ if (!theme || theme === "custom") {
59416
+ return getDefaultPowerlineTheme();
59417
+ }
59418
+ return theme;
59419
+ }
59420
+ function buildEnabledPowerlineSettings(settings, removeManualSeparators) {
59421
+ const powerlineConfig = settings.powerline;
59422
+ const lines = removeManualSeparators ? settings.lines.map((line) => line.filter((item) => item.type !== "separator" && item.type !== "flex-separator")) : settings.lines;
59423
+ return {
59424
+ ...settings,
59425
+ powerline: {
59426
+ ...powerlineConfig,
59427
+ enabled: true,
59428
+ theme: resolveEnabledPowerlineTheme(powerlineConfig.theme),
59429
+ separators: powerlineConfig.separators,
59430
+ separatorInvertBackground: powerlineConfig.separatorInvertBackground
59431
+ },
59432
+ defaultPadding: " ",
59433
+ lines
59434
+ };
59435
+ }
59436
+
59662
59437
  // src/tui/components/PowerlineSeparatorEditor.tsx
59663
59438
  var import_react40 = __toESM(require_react(), 1);
59664
59439
  var jsx_dev_runtime12 = __toESM(require_jsx_dev_runtime(), 1);
@@ -60271,19 +60046,7 @@ var PowerlineSetup = ({
60271
60046
  if (hasSeparatorItems) {
60272
60047
  setConfirmingEnable(true);
60273
60048
  } else {
60274
- const theme = !powerlineConfig.theme || powerlineConfig.theme === "custom" ? getDefaultPowerlineTheme() : powerlineConfig.theme;
60275
- const updatedSettings = {
60276
- ...settings,
60277
- powerline: {
60278
- ...powerlineConfig,
60279
- enabled: true,
60280
- theme,
60281
- separators: powerlineConfig.separators,
60282
- separatorInvertBackground: powerlineConfig.separatorInvertBackground
60283
- },
60284
- defaultPadding: " "
60285
- };
60286
- onUpdate(updatedSettings);
60049
+ onUpdate(buildEnabledPowerlineSettings(settings, false));
60287
60050
  }
60288
60051
  } else {
60289
60052
  const newConfig = { ...powerlineConfig, enabled: false };
@@ -60513,20 +60276,7 @@ var PowerlineSetup = ({
60513
60276
  children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(ConfirmDialog, {
60514
60277
  inline: true,
60515
60278
  onConfirm: () => {
60516
- const theme = !powerlineConfig.theme || powerlineConfig.theme === "custom" ? getDefaultPowerlineTheme() : powerlineConfig.theme;
60517
- const updatedSettings = {
60518
- ...settings,
60519
- powerline: {
60520
- ...powerlineConfig,
60521
- enabled: true,
60522
- theme,
60523
- separators: powerlineConfig.separators,
60524
- separatorInvertBackground: powerlineConfig.separatorInvertBackground
60525
- },
60526
- defaultPadding: " ",
60527
- lines: settings.lines.map((line) => line.filter((item) => item.type !== "separator" && item.type !== "flex-separator"))
60528
- };
60529
- onUpdate(updatedSettings);
60279
+ onUpdate(buildEnabledPowerlineSettings(settings, true));
60530
60280
  setConfirmingEnable(false);
60531
60281
  },
60532
60282
  onCancel: () => {
@@ -60695,8 +60445,19 @@ var PowerlineSetup = ({
60695
60445
  };
60696
60446
  // src/tui/components/StatusLinePreview.tsx
60697
60447
  var import_react43 = __toESM(require_react(), 1);
60448
+
60449
+ // src/utils/separator-index.ts
60450
+ function countSeparatorSlots(widgets) {
60451
+ const nonMergedWidgets = widgets.filter((_, idx) => idx === widgets.length - 1 || !widgets[idx]?.merge);
60452
+ return Math.max(0, nonMergedWidgets.length - 1);
60453
+ }
60454
+ function advanceGlobalSeparatorIndex(currentIndex, widgets) {
60455
+ return currentIndex + countSeparatorSlots(widgets);
60456
+ }
60457
+
60458
+ // src/tui/components/StatusLinePreview.tsx
60698
60459
  var jsx_dev_runtime15 = __toESM(require_jsx_dev_runtime(), 1);
60699
- var renderSingleLine = (widgets, terminalWidth, widthDetectionAvailable, settings, lineIndex, globalSeparatorIndex, preRenderedWidgets, preCalculatedMaxWidths) => {
60460
+ var renderSingleLine = (widgets, terminalWidth, settings, lineIndex, globalSeparatorIndex, preRenderedWidgets, preCalculatedMaxWidths) => {
60700
60461
  const context = {
60701
60462
  terminalWidth,
60702
60463
  isPreview: true,
@@ -60706,7 +60467,6 @@ var renderSingleLine = (widgets, terminalWidth, widthDetectionAvailable, setting
60706
60467
  return renderStatusLineWithInfo(widgets, settings, context, preRenderedWidgets, preCalculatedMaxWidths);
60707
60468
  };
60708
60469
  var StatusLinePreview = ({ lines, terminalWidth, settings, onTruncationChange }) => {
60709
- const widthDetectionAvailable = import_react43.default.useMemo(() => canDetectTerminalWidth(), []);
60710
60470
  const { renderedLines, anyTruncated } = import_react43.default.useMemo(() => {
60711
60471
  if (!settings)
60712
60472
  return { renderedLines: [], anyTruncated: false };
@@ -60719,19 +60479,16 @@ var StatusLinePreview = ({ lines, terminalWidth, settings, onTruncationChange })
60719
60479
  const lineItems = lines[i];
60720
60480
  if (lineItems && lineItems.length > 0) {
60721
60481
  const preRenderedWidgets = preRenderedLines[i] ?? [];
60722
- const renderResult = renderSingleLine(lineItems, terminalWidth, widthDetectionAvailable, settings, i, globalSeparatorIndex, preRenderedWidgets, preCalculatedMaxWidths);
60482
+ const renderResult = renderSingleLine(lineItems, terminalWidth, settings, i, globalSeparatorIndex, preRenderedWidgets, preCalculatedMaxWidths);
60723
60483
  result.push(renderResult.line);
60724
60484
  if (renderResult.wasTruncated) {
60725
60485
  truncated = true;
60726
60486
  }
60727
- const nonMergedWidgets = lineItems.filter((_, idx) => idx === lineItems.length - 1 || !lineItems[idx]?.merge);
60728
- if (nonMergedWidgets.length > 1) {
60729
- globalSeparatorIndex += nonMergedWidgets.length - 1;
60730
- }
60487
+ globalSeparatorIndex = advanceGlobalSeparatorIndex(globalSeparatorIndex, lineItems);
60731
60488
  }
60732
60489
  }
60733
60490
  return { renderedLines: result, anyTruncated: truncated };
60734
- }, [lines, terminalWidth, widthDetectionAvailable, settings]);
60491
+ }, [lines, terminalWidth, settings]);
60735
60492
  import_react43.default.useEffect(() => {
60736
60493
  onTruncationChange?.(anyTruncated);
60737
60494
  }, [anyTruncated, onTruncationChange]);
@@ -60766,6 +60523,59 @@ var StatusLinePreview = ({ lines, terminalWidth, settings, onTruncationChange })
60766
60523
  };
60767
60524
  // src/tui/components/TerminalOptionsMenu.tsx
60768
60525
  var import_react44 = __toESM(require_react(), 1);
60526
+
60527
+ // src/utils/color-sanitize.ts
60528
+ function isCustomColor(value) {
60529
+ if (!value) {
60530
+ return false;
60531
+ }
60532
+ return value.startsWith("ansi256:") || value.startsWith("hex:");
60533
+ }
60534
+ function isIncompatibleForLevel(value, nextLevel) {
60535
+ if (!isCustomColor(value)) {
60536
+ return false;
60537
+ }
60538
+ if (nextLevel === 2) {
60539
+ return Boolean(value?.startsWith("hex:"));
60540
+ }
60541
+ if (nextLevel === 3) {
60542
+ return Boolean(value?.startsWith("ansi256:"));
60543
+ }
60544
+ return true;
60545
+ }
60546
+ function resetWidgetForegroundToDefault(widget, nextWidget) {
60547
+ if (widget.type === "separator" || widget.type === "flex-separator") {
60548
+ return nextWidget;
60549
+ }
60550
+ const widgetImpl = getWidget(widget.type);
60551
+ if (!widgetImpl) {
60552
+ return nextWidget;
60553
+ }
60554
+ return {
60555
+ ...nextWidget,
60556
+ color: widgetImpl.getDefaultColor()
60557
+ };
60558
+ }
60559
+ function hasCustomWidgetColors(lines) {
60560
+ return lines.some((line) => line.some((widget) => isCustomColor(widget.color) || isCustomColor(widget.backgroundColor)));
60561
+ }
60562
+ function sanitizeLinesForColorLevel(lines, nextLevel) {
60563
+ return lines.map((line) => line.map((widget) => {
60564
+ let nextWidget = { ...widget };
60565
+ if (isIncompatibleForLevel(widget.color, nextLevel)) {
60566
+ nextWidget = resetWidgetForegroundToDefault(widget, nextWidget);
60567
+ }
60568
+ if (isIncompatibleForLevel(widget.backgroundColor, nextLevel)) {
60569
+ nextWidget = {
60570
+ ...nextWidget,
60571
+ backgroundColor: undefined
60572
+ };
60573
+ }
60574
+ return nextWidget;
60575
+ }));
60576
+ }
60577
+
60578
+ // src/tui/components/TerminalOptionsMenu.tsx
60769
60579
  var jsx_dev_runtime16 = __toESM(require_jsx_dev_runtime(), 1);
60770
60580
  var TerminalOptionsMenu = ({ settings, onUpdate, onBack }) => {
60771
60581
  const [showColorWarning, setShowColorWarning] = import_react44.useState(false);
@@ -60777,7 +60587,7 @@ var TerminalOptionsMenu = ({ settings, onUpdate, onBack }) => {
60777
60587
  } else if (selectedIndex === 0) {
60778
60588
  onBack("width");
60779
60589
  } else if (selectedIndex === 1) {
60780
- const hasCustomColors = settings.lines.some((line) => line.some((widget) => Boolean(widget.color && (widget.color.startsWith("ansi256:") || widget.color.startsWith("hex:"))) || Boolean(widget.backgroundColor && (widget.backgroundColor.startsWith("ansi256:") || widget.backgroundColor.startsWith("hex:")))));
60590
+ const hasCustomColors = hasCustomWidgetColors(settings.lines);
60781
60591
  const currentLevel = settings.colorLevel;
60782
60592
  const nextLevel = (currentLevel + 1) % 4;
60783
60593
  if (hasCustomColors && (currentLevel === 2 && nextLevel !== 2 || currentLevel === 3 && nextLevel !== 3)) {
@@ -60785,47 +60595,7 @@ var TerminalOptionsMenu = ({ settings, onUpdate, onBack }) => {
60785
60595
  setPendingColorLevel(nextLevel);
60786
60596
  } else {
60787
60597
  source_default.level = nextLevel;
60788
- const cleanedLines = settings.lines.map((line) => line.map((widget) => {
60789
- const newWidget = { ...widget };
60790
- if (nextLevel === 2) {
60791
- if (widget.color?.startsWith("hex:")) {
60792
- if (widget.type !== "separator" && widget.type !== "flex-separator") {
60793
- const widgetImpl = getWidget(widget.type);
60794
- if (widgetImpl) {
60795
- newWidget.color = widgetImpl.getDefaultColor();
60796
- }
60797
- }
60798
- }
60799
- if (widget.backgroundColor?.startsWith("hex:")) {
60800
- newWidget.backgroundColor = undefined;
60801
- }
60802
- } else if (nextLevel === 3) {
60803
- if (widget.color?.startsWith("ansi256:")) {
60804
- if (widget.type !== "separator" && widget.type !== "flex-separator") {
60805
- const widgetImpl = getWidget(widget.type);
60806
- if (widgetImpl) {
60807
- newWidget.color = widgetImpl.getDefaultColor();
60808
- }
60809
- }
60810
- }
60811
- if (widget.backgroundColor?.startsWith("ansi256:")) {
60812
- newWidget.backgroundColor = undefined;
60813
- }
60814
- } else {
60815
- if (widget.color?.startsWith("ansi256:") || widget.color?.startsWith("hex:")) {
60816
- if (widget.type !== "separator" && widget.type !== "flex-separator") {
60817
- const widgetImpl = getWidget(widget.type);
60818
- if (widgetImpl) {
60819
- newWidget.color = widgetImpl.getDefaultColor();
60820
- }
60821
- }
60822
- }
60823
- if (widget.backgroundColor?.startsWith("ansi256:") || widget.backgroundColor?.startsWith("hex:")) {
60824
- newWidget.backgroundColor = undefined;
60825
- }
60826
- }
60827
- return newWidget;
60828
- }));
60598
+ const cleanedLines = sanitizeLinesForColorLevel(settings.lines, nextLevel);
60829
60599
  onUpdate({
60830
60600
  ...settings,
60831
60601
  lines: cleanedLines,
@@ -60837,23 +60607,7 @@ var TerminalOptionsMenu = ({ settings, onUpdate, onBack }) => {
60837
60607
  const handleColorConfirm = () => {
60838
60608
  if (pendingColorLevel !== null) {
60839
60609
  source_default.level = pendingColorLevel;
60840
- const cleanedLines = settings.lines.map((line) => line.map((widget) => {
60841
- const newWidget = { ...widget };
60842
- if (pendingColorLevel !== 2 && pendingColorLevel !== 3 || pendingColorLevel === 2 && (widget.color?.startsWith("hex:") || widget.backgroundColor?.startsWith("hex:")) || pendingColorLevel === 3 && (widget.color?.startsWith("ansi256:") || widget.backgroundColor?.startsWith("ansi256:"))) {
60843
- if (widget.color?.startsWith("ansi256:") || widget.color?.startsWith("hex:")) {
60844
- if (widget.type !== "separator" && widget.type !== "flex-separator") {
60845
- const widgetImpl = getWidget(widget.type);
60846
- if (widgetImpl) {
60847
- newWidget.color = widgetImpl.getDefaultColor();
60848
- }
60849
- }
60850
- }
60851
- if (widget.backgroundColor?.startsWith("ansi256:") || widget.backgroundColor?.startsWith("hex:")) {
60852
- newWidget.backgroundColor = undefined;
60853
- }
60854
- }
60855
- return newWidget;
60856
- }));
60610
+ const cleanedLines = sanitizeLinesForColorLevel(settings.lines, pendingColorLevel);
60857
60611
  onUpdate({
60858
60612
  ...settings,
60859
60613
  lines: cleanedLines,
@@ -61215,7 +60969,7 @@ var App2 = () => {
61215
60969
  loadSettings().then((loadedSettings) => {
61216
60970
  source_default.level = loadedSettings.colorLevel;
61217
60971
  setSettings(loadedSettings);
61218
- setOriginalSettings(JSON.parse(JSON.stringify(loadedSettings)));
60972
+ setOriginalSettings(cloneSettings(loadedSettings));
61219
60973
  });
61220
60974
  isInstalled().then(setIsClaudeInstalled);
61221
60975
  const fontStatus = checkPowerlineFonts();
@@ -61254,7 +61008,7 @@ var App2 = () => {
61254
61008
  if (key.ctrl && input === "s" && settings) {
61255
61009
  (async () => {
61256
61010
  await saveSettings(settings);
61257
- setOriginalSettings(JSON.parse(JSON.stringify(settings)));
61011
+ setOriginalSettings(cloneSettings(settings));
61258
61012
  setHasChanges(false);
61259
61013
  setFlashMessage({
61260
61014
  text: "✓ Configuration saved",
@@ -61367,7 +61121,7 @@ ${GITHUB_REPO_URL}`,
61367
61121
  break;
61368
61122
  case "save":
61369
61123
  await saveSettings(settings);
61370
- setOriginalSettings(JSON.parse(JSON.stringify(settings)));
61124
+ setOriginalSettings(cloneSettings(settings));
61371
61125
  setHasChanges(false);
61372
61126
  exit();
61373
61127
  break;
@@ -61433,7 +61187,7 @@ ${GITHUB_REPO_URL}`,
61433
61187
  install: 5,
61434
61188
  starGithub: hasChanges ? 8 : 7
61435
61189
  };
61436
- setMenuSelections({ ...menuSelections, main: menuMap[value] ?? 0 });
61190
+ setMenuSelections((prev) => ({ ...prev, main: menuMap[value] ?? 0 }));
61437
61191
  }
61438
61192
  handleMainMenuSelect(value);
61439
61193
  },
@@ -61447,12 +61201,12 @@ ${GITHUB_REPO_URL}`,
61447
61201
  screen === "lines" && /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(LineSelector, {
61448
61202
  lines: settings.lines,
61449
61203
  onSelect: (line) => {
61450
- setMenuSelections({ ...menuSelections, lines: line });
61204
+ setMenuSelections((prev) => ({ ...prev, lines: line }));
61451
61205
  handleLineSelect(line);
61452
61206
  },
61453
61207
  onLinesUpdate: updateLines,
61454
61208
  onBack: () => {
61455
- setMenuSelections({ ...menuSelections, main: 0 });
61209
+ setMenuSelections((prev) => ({ ...prev, main: 0 }));
61456
61210
  setScreen("main");
61457
61211
  },
61458
61212
  initialSelection: menuSelections.lines,
@@ -61465,7 +61219,7 @@ ${GITHUB_REPO_URL}`,
61465
61219
  updateLine(selectedLine, widgets);
61466
61220
  },
61467
61221
  onBack: () => {
61468
- setMenuSelections({ ...menuSelections, lines: selectedLine });
61222
+ setMenuSelections((prev) => ({ ...prev, lines: selectedLine }));
61469
61223
  setScreen("lines");
61470
61224
  },
61471
61225
  lineNumber: selectedLine + 1,
@@ -61475,12 +61229,12 @@ ${GITHUB_REPO_URL}`,
61475
61229
  lines: settings.lines,
61476
61230
  onLinesUpdate: updateLines,
61477
61231
  onSelect: (line) => {
61478
- setMenuSelections({ ...menuSelections, lines: line });
61232
+ setMenuSelections((prev) => ({ ...prev, lines: line }));
61479
61233
  setSelectedLine(line);
61480
61234
  setScreen("colors");
61481
61235
  },
61482
61236
  onBack: () => {
61483
- setMenuSelections({ ...menuSelections, main: 1 });
61237
+ setMenuSelections((prev) => ({ ...prev, main: 1 }));
61484
61238
  setScreen("main");
61485
61239
  },
61486
61240
  initialSelection: menuSelections.lines,
@@ -61511,7 +61265,7 @@ ${GITHUB_REPO_URL}`,
61511
61265
  if (target === "width") {
61512
61266
  setScreen("terminalWidth");
61513
61267
  } else {
61514
- setMenuSelections({ ...menuSelections, main: 3 });
61268
+ setMenuSelections((prev) => ({ ...prev, main: 3 }));
61515
61269
  setScreen("main");
61516
61270
  }
61517
61271
  }
@@ -61531,7 +61285,7 @@ ${GITHUB_REPO_URL}`,
61531
61285
  setSettings(updatedSettings);
61532
61286
  },
61533
61287
  onBack: () => {
61534
- setMenuSelections({ ...menuSelections, main: 4 });
61288
+ setMenuSelections((prev) => ({ ...prev, main: 4 }));
61535
61289
  setScreen("main");
61536
61290
  }
61537
61291
  }, undefined, false, undefined, this),
@@ -61589,6 +61343,17 @@ function runTUI() {
61589
61343
  render_default(/* @__PURE__ */ jsx_dev_runtime18.jsxDEV(App2, {}, undefined, false, undefined, this));
61590
61344
  }
61591
61345
  // src/types/StatusJSON.ts
61346
+ var CoercedNumberSchema = exports_external.preprocess((value) => {
61347
+ if (typeof value !== "string") {
61348
+ return value;
61349
+ }
61350
+ const trimmed = value.trim();
61351
+ if (trimmed.length === 0) {
61352
+ return value;
61353
+ }
61354
+ const parsed = Number(trimmed);
61355
+ return Number.isFinite(parsed) ? parsed : value;
61356
+ }, exports_external.number());
61592
61357
  var StatusJSONSchema = exports_external.looseObject({
61593
61358
  hook_event_name: exports_external.string().optional(),
61594
61359
  session_id: exports_external.string().optional(),
@@ -61608,27 +61373,27 @@ var StatusJSONSchema = exports_external.looseObject({
61608
61373
  version: exports_external.string().optional(),
61609
61374
  output_style: exports_external.object({ name: exports_external.string().optional() }).optional(),
61610
61375
  cost: exports_external.object({
61611
- total_cost_usd: exports_external.number().optional(),
61612
- total_duration_ms: exports_external.number().optional(),
61613
- total_api_duration_ms: exports_external.number().optional(),
61614
- total_lines_added: exports_external.number().optional(),
61615
- total_lines_removed: exports_external.number().optional()
61376
+ total_cost_usd: CoercedNumberSchema.optional(),
61377
+ total_duration_ms: CoercedNumberSchema.optional(),
61378
+ total_api_duration_ms: CoercedNumberSchema.optional(),
61379
+ total_lines_added: CoercedNumberSchema.optional(),
61380
+ total_lines_removed: CoercedNumberSchema.optional()
61616
61381
  }).optional(),
61617
61382
  context_window: exports_external.object({
61618
- context_window_size: exports_external.number().nullable().optional(),
61619
- total_input_tokens: exports_external.number().nullable().optional(),
61620
- total_output_tokens: exports_external.number().nullable().optional(),
61383
+ context_window_size: CoercedNumberSchema.nullable().optional(),
61384
+ total_input_tokens: CoercedNumberSchema.nullable().optional(),
61385
+ total_output_tokens: CoercedNumberSchema.nullable().optional(),
61621
61386
  current_usage: exports_external.union([
61622
- exports_external.number(),
61387
+ CoercedNumberSchema,
61623
61388
  exports_external.object({
61624
- input_tokens: exports_external.number().optional(),
61625
- output_tokens: exports_external.number().optional(),
61626
- cache_creation_input_tokens: exports_external.number().optional(),
61627
- cache_read_input_tokens: exports_external.number().optional()
61389
+ input_tokens: CoercedNumberSchema.optional(),
61390
+ output_tokens: CoercedNumberSchema.optional(),
61391
+ cache_creation_input_tokens: CoercedNumberSchema.optional(),
61392
+ cache_read_input_tokens: CoercedNumberSchema.optional()
61628
61393
  })
61629
61394
  ]).nullable().optional(),
61630
- used_percentage: exports_external.number().nullable().optional(),
61631
- remaining_percentage: exports_external.number().nullable().optional()
61395
+ used_percentage: CoercedNumberSchema.nullable().optional(),
61396
+ remaining_percentage: CoercedNumberSchema.nullable().optional()
61632
61397
  }).nullable().optional()
61633
61398
  });
61634
61399
 
@@ -61699,12 +61464,10 @@ async function renderMultipleLines(data) {
61699
61464
  const line = renderStatusLine(lineItems, settings, lineContext, preRenderedWidgets, preCalculatedMaxWidths);
61700
61465
  const strippedLine = getVisibleText(line).trim();
61701
61466
  if (strippedLine.length > 0) {
61702
- const nonMergedWidgets = lineItems.filter((_, idx) => idx === lineItems.length - 1 || !lineItems[idx]?.merge);
61703
- if (nonMergedWidgets.length > 1)
61704
- globalSeparatorIndex += nonMergedWidgets.length - 1;
61705
61467
  let outputLine = line.replace(/ /g, " ");
61706
61468
  outputLine = "\x1B[0m" + outputLine;
61707
61469
  console.log(outputLine);
61470
+ globalSeparatorIndex = advanceGlobalSeparatorIndex(globalSeparatorIndex, lineItems);
61708
61471
  }
61709
61472
  }
61710
61473
  }