Skip to content
Closed
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/rss-reader/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function decodeEntities(value: string): string {

return value.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (match, entity: string) => {
if (entity.startsWith('#x')) {
const codePoint = Number.parseInt(entity.slice(2), 16);
const codePoint = Number.parseInt(entity.slice(2, 10), 16);
return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : match;
Comment on lines +30 to 31

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

node - <<'EOF'
for (const entity of ['`#x00000041FF`', '`#xFFFFFFFF`']) {
  const codePoint = Number.parseInt(entity.slice(2, 10), 16);
  try {
    console.log(entity, codePoint, String.fromCodePoint(codePoint));
  } catch (error) {
    console.log(entity, codePoint, error.name);
  }
}
EOF

Repository: Karanjot786/TermUI

Length of output: 207


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "File location and relevant lines:"
if [ -f examples/rss-reader/src/index.tsx ]; then
  nl -ba examples/rss-reader/src/index.tsx | sed -n '1,80p'
else
  echo "examples/rss-reader/src/index.tsx not found"
fi

echo
echo "Search for decode helpers and usages:"
rg -n "decode|fromCodePoint|parseInt\\(|&`#x`|fromCharCode|value" examples/rss-reader/src packages -S 2>/dev/null | head -200 || true

echo
echo "Check for error boundaries/error handling in example and app:"
rg -n "ErrorBoundary|try|catch|fallback|error" examples/rss-reader/src -S 2>/dev/null || true

Repository: Karanjot786/TermUI

Length of output: 230


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "File location and relevant lines:"
if [ -f examples/rss-reader/src/index.tsx ]; then
  awk '{printf "%6d\t%s\n", NR, $0}' examples/rss-reader/src/index.tsx | sed -n '1,80p'
else
  echo "examples/rss-reader/src/index.tsx not found"
fi

echo
echo "Search for decode helpers and usages:"
rg -n "decode|fromCodePoint|parseInt\\(|&`#x`|fromCharCode|value" examples/rss-reader/src packages -S 2>/dev/null | head -200 || true

echo
echo "Check for error boundaries/error handling in example and app:"
rg -n "ErrorBoundary|try|catch|fallback|error" examples/rss-reader/src -S 2>/dev/null || true

Repository: Karanjot786/TermUI

Length of output: 25847


Validate the complete entity before conversion.

entity.slice(2, 10) silently discards hexadecimal digits after the eighth. For example, &#x00000041FF; is decoded as A. Also, &#xFFFFFFFF; produces a finite number outside the valid Unicode range, so String.fromCodePoint throws RangeError.

Use the full captured digit string for parseInt, reject sequences longer than eight digits, and reject values greater than 0x10FFFF before calling String.fromCodePoint.

🤖 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 `@examples/rss-reader/src/index.tsx` around lines 30 - 31, Update the entity
decoding logic around codePoint to parse the full captured hexadecimal digit
string, reject entities with more than eight digits, and reject values above
0x10FFFF before calling String.fromCodePoint; preserve returning match for
invalid entities.

}

Expand Down
2 changes: 1 addition & 1 deletion examples/weather/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ async function fetchWeather() {
}
}

setInterval(fetchWeather, 5000);
clearInterval(window.__interval); window.__interval = setInterval(fetchWeather, 5000);
fetchWeather();

// Gauge does not expose a public setColor() method, so dynamic color
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,5 @@ export class Form extends Widget {
}
}
}

.catch(err => console.error("Promise.all failed:", err));
Comment on lines +141 to +142

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '78,146p' packages/ui/src/Form.ts
rg -n -C 3 'Promise\.all|\.catch|_isValidating|markDirty' packages/ui/src/Form.ts

Repository: Karanjot786/TermUI

Length of output: 5634


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,146p' packages/ui/src/Form.ts

python3 - <<'PY'
from pathlib import Path
text = Path("packages/ui/src/Form.ts").read_text()
try:
    import black
except Exception as e:
    print(f"black unavailable: {type(e).__name__}: {e}")
    print("Unable to run black parser check.")
else:
    try:
        black.format_str(text, mode=black.Mode())
        print("black parse check: ok")
    except Exception as e:
        print("black parse check: failed")
        print(e)
PY

Repository: Karanjot786/TermUI

Length of output: 6748


Remove the stray .catch after Form closes.

The final }\n.catch(...) outside the class body is invalid TypeScript, so packages/ui/src/Form.ts cannot compile. If rejection handling is needed, attach it to the Promise.all(validationPromises) call inside submit(), then reset _isValidating and call markDirty() before returning.

🧰 Tools
🪛 Biome (2.5.5)

[error] 142-142: Expected a statement but instead found '.catch(err => console.error("Promise.all failed:", err))'.

(parse)

🪛 GitHub Actions: CI / 0_build-and-test.txt

[error] 142-142: tsup/esbuild build failed: Unexpected "." at .catch(err => console.error("Promise.all failed:", err));. The @termuijs/ui build command exited with code 1.

🪛 GitHub Actions: CI / build-and-test

[error] 142-142: The @termuijs/ui build failed during tsup/esbuild compilation بسبب an unexpected '.' in .catch(err => console.error("Promise.all failed:", err));.

🤖 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/ui/src/Form.ts` around lines 141 - 142, Remove the stray catch after
the Form class closes so Form.ts compiles. If rejection handling is required,
attach it to the Promise.all(validationPromises) flow inside submit(), reset
_isValidating, call markDirty(), and then return.

Source: Linters/SAST tools

2 changes: 1 addition & 1 deletion packages/ui/src/MultiSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class MultiSelect extends Widget {
}

get selectedOptions(): MultiSelectOption[] {
return [...this._checked].sort().map(i => this._options[i]);
return [...this._checked].sort((a, b) => a - b).map(i => this._options[i]);
}
selectNext(): void { if (this._options.length === 0) return; let n = this._cursorIndex + 1; while (n < this._options.length && this._options[n].disabled) n++; if (n < this._options.length) { this._cursorIndex = n; this.markDirty(); } }
selectPrev(): void { if (this._options.length === 0) return; let n = this._cursorIndex - 1; while (n >= 0 && this._options[n].disabled) n--; if (n >= 0) { this._cursorIndex = n; this.markDirty(); } }
Expand Down
Loading