Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/pomodoro-timer/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class GradientProgressBar extends Widget {

const attrs = styleToCellAttrs(this._style);

const label = this._showLabel ? ` ${Math.round(this._value * 100)}%` : '';
const label = this._showLabel ? ` ${Math.round(this._value * 100 + Number.EPSILON)}%` : '';
const barWidth = Math.max(0, width - label.length);
const filled = this._value <= 0 ? 0 : Math.round(barWidth * this._value);
const empty = barWidth - filled;
Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ShowcaseApp extends Widget {
if (event.key === 'q' || (event.ctrl && event.key === 'c')) return false;

// Tab switching: 1-5
const num = parseInt(event.key);
const num = parseInt(event.key, 10);
if (num >= 1 && num <= 5) {
this.switchTab(num - 1);
return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export class DevServer {

this._killChild();

await exitedPromise.catch(() => {});
await exitedPromise.catch( => console.error());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Fix the malformed .catch callback.

Line 383 is invalid TypeScript because the arrow function has no parameter list. This prevents packages/dev-server/src/server.ts from parsing. Pass the rejection value to console.error:

Proposed fix
-            await exitedPromise.catch( => console.error());
+            await exitedPromise.catch((error) => console.error(error));

Static analysis confirms the parser error at Line 383.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await exitedPromise.catch( => console.error());
await exitedPromise.catch((error) => console.error(error));
🧰 Tools
🪛 Biome (2.5.6)

[error] 383-383: Expected a parenthesis '(' but instead found '=>'.

(parse)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/dev-server/src/server.ts` at line 383, Fix the malformed catch
callback on exitedPromise by adding a valid rejection parameter and pass it to
console.error, preserving the existing await and error-handling flow.

Source: Linters/SAST tools


if (this._running && this._entryFile) {
this._spawnChild();
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function collectDeps(content: string): string[] {
const deps = new Set<string>();
let m: RegExpExecArray | null;
while ((m = re.exec(content)) !== null) deps.add(m[1]!);
return [...deps].sort();
return [...deps].sort((a, b) => a - b);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "## file list"
git ls-files | rg '(^|/)build-registry(\.test)?\.ts$|scripts/build-registry' || true

echo "## scripts/build-registry.ts outline"
ast-grep outline scripts/build-registry.ts --view compact || true

echo "## scripts/build-registry.ts relevant lines"
sed -n '1,90p' scripts/build-registry.ts

echo "## tests around registry sorting"
sed -n '100,155p' scripts/build-registry.test.ts

echo "## JS runtime behavior for array of strings subtracting"
node - <<'JS'
const deps = ['zebra', 'apple', 'Mango', 'banana'];
console.log(JSON.stringify([
  deps.map(v => {
    const values = [];
    const result = [...deps].sort((a, b) => (values.push([JSON.stringify([a,b]), a-b]), [].sort((a, b) => a - b)(v)).flat())
    return undefined;
  })
)));
console.log(JSON.stringify({
  directSubtractionDemo: deps.map((a,i) => a + ' - ' + deps[i] + ' = ' + (a - deps[i])),
  sortBefore: JSON.stringify(deps),
  sortMinusComparator: JSON.stringify([...deps].sort((a, b) => a - b)),
  naturalSort: JSON.stringify([...deps].sort()),
}))
JS

Repository: Karanjot786/TermUI

Length of output: 7130


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "## runtime behavior for string comparator and JS/TC semantics"
node - <<'JS'
const src = [
  `import { Widget } from '`@termuijs/widgets`';`,
  `import { Screen } from '`@termuijs/core`';`,
  `import { timerPoolSubscribe } from '`@termuijs/motion`';`,
  `import { Widget as W2 } from '`@termuijs/widgets`';`,
].join('\n');

const re = /from\s+['"](`@termuijs`\/[a-z-]+)['"]/g;
const deps = new Set();
let m;
while ((m = re.exec(src)) !== null) deps.add(m[1]);
const list = [...deps];

console.log(JSON.stringify({
  directSubtractionDemo: {
    a: JSON.stringify('`@termuijs/widgets` - `@termuijs/core` = ' + ('`@termuijs/widgets`' - '`@termuijs/core`')),
    comparison: JSON.stringify('`@termuijs/motion`' < '`@termuijs/widgets`')
  },
  sortWithSubtractionComparator: JSON.stringify([...list].sort((a, b) => a - b)),
  defaultStringSort: JSON.stringify([...list].sort()),
  expected: JSON.stringify(['`@termuijs/core`', '`@termuijs/motion`', '`@termuijs/widgets`']),
  inputOrder: JSON.stringify(list)
}));
JS

Repository: Karanjot786/TermUI

Length of output: 657


Use a string comparator for dependency identifiers.

Line 47 subtracts string values. This breaks TypeScript strict mode and yields NaN comparisons at runtime, so registry dependencies stay in insertion order instead of sorted order. The collectDeps test expects ["@termuijs/core", "@termuijs/motion", "@termuijs/widgets"].

Proposed fix
-  return [...deps].sort((a, b) => a - b);
+  return [...deps].sort();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return [...deps].sort((a, b) => a - b);
return [...deps].sort();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/build-registry.ts` at line 47, Update the dependency sorting in
collectDeps to use a string comparator for identifiers rather than numeric
subtraction, ensuring alphabetical ordering such as `@termuijs/core`,
`@termuijs/motion`, and `@termuijs/widgets` while preserving deduplication.

}

export function toSlug(name: string): string {
Expand Down
Loading