kodevu 0.1.15 → 0.1.16

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/package.json +1 -1
  2. package/src/progress-ui.js +29 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kodevu",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "description": "Poll SVN revisions or Git commits, send each change diff to a reviewer CLI, and write configurable review reports.",
6
6
  "bin": {
@@ -2,7 +2,6 @@ import readline from "node:readline";
2
2
 
3
3
  const SPINNER_FRAMES = ["|", "/", "-", "\\"];
4
4
  const DEFAULT_BAR_WIDTH = 24;
5
- const MIN_BAR_WIDTH = 8;
6
5
 
7
6
  function clampProgress(value) {
8
7
  if (!Number.isFinite(value)) {
@@ -109,16 +108,34 @@ class ProgressItem {
109
108
  buildLine(prefix, suffix) {
110
109
  const availableWidth = this.display.getAvailableWidth();
111
110
  const pct = `${Math.round(this.progress * 100)}`.padStart(3, " ");
112
- const reservedWidth = prefix.length + this.label.length + pct.length + 6;
113
- const dynamicBarWidth = Math.min(
114
- this.barWidth,
115
- Math.max(MIN_BAR_WIDTH, availableWidth - reservedWidth - (suffix ? suffix.length + 1 : 0))
116
- );
117
- const bar = buildBar(this.progress, dynamicBarWidth);
118
- return truncateLine(
119
- `${prefix} ${this.label} ${bar} ${pct}%${suffix ? ` ${suffix}` : ""}`,
120
- availableWidth
121
- );
111
+ const parts = [prefix, this.label];
112
+ const suffixText = suffix ? ` ${suffix}` : "";
113
+
114
+ if (availableWidth < 10) {
115
+ return truncateLine(`${prefix} ${pct}%`, availableWidth);
116
+ }
117
+
118
+ const fullReservedWidth = prefix.length + this.label.length + pct.length + suffixText.length + 4;
119
+ const fullBarWidth = availableWidth - fullReservedWidth;
120
+
121
+ if (fullBarWidth >= 4) {
122
+ return truncateLine(
123
+ `${parts.join(" ")} ${buildBar(this.progress, Math.min(this.barWidth, fullBarWidth))} ${pct}%${suffixText}`,
124
+ availableWidth
125
+ );
126
+ }
127
+
128
+ const compactReservedWidth = prefix.length + pct.length + suffixText.length + 4;
129
+ const compactBarWidth = availableWidth - compactReservedWidth;
130
+
131
+ if (compactBarWidth >= 4) {
132
+ return truncateLine(
133
+ `${prefix} ${buildBar(this.progress, compactBarWidth)} ${pct}%${suffixText}`,
134
+ availableWidth
135
+ );
136
+ }
137
+
138
+ return truncateLine(`${prefix} ${pct}%${suffixText}`, availableWidth);
122
139
  }
123
140
 
124
141
  writeFallback(line) {
@@ -237,7 +254,7 @@ export class ProgressDisplay {
237
254
 
238
255
  getAvailableWidth() {
239
256
  const columns = this.stream.columns || 80;
240
- return Math.max(columns - 1, 20);
257
+ return Math.max(columns - 1, 1);
241
258
  }
242
259
 
243
260
  handleResize() {