Skip to content

Extract inline styles to external CSS and improve code quality - #2

Merged
hyperpolymath merged 2 commits into
mainfrom
claude/suggest-improvements-ZiGyN
Apr 16, 2026
Merged

Extract inline styles to external CSS and improve code quality#2
hyperpolymath merged 2 commits into
mainfrom
claude/suggest-improvements-ZiGyN

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

This PR refactors the stylesheet organization and improves code quality across the codebase by extracting inline styles to an external CSS file, optimizing array operations in ReScript modules, and enhancing security checks.

Key Changes

Styling & Build

  • Extracted 593 lines of inline CSS from index.html <style> tag into new src/styles/shell.css file with SPDX license header
  • Added CSS import to src/main.js to load extracted styles
  • Improves maintainability and enables Vite HMR for CSS changes
  • Updated vite.config.js to ignore target/ directory instead of src-tauri/

Accessibility Improvements

  • Added ARIA attributes to key elements in index.html:
    • role="status" and aria-live="polite" to status indicators
    • role="alert" and aria-live="assertive" to error container
    • aria-label and aria-live attributes to preview and verification panels

ReScript/OCaml Optimizations

  • Proven_SafeHex.res: Refactored decodeToString to use Array.map + Array.join instead of mutable ref with forEach
  • Proven_SafeHex.res: Optimized encodeSpaced and encodeSpacedUppercase to use pre-allocated arrays with indexed assignment instead of array concatenation in loops
  • Proven_SafePath.res: Added hasNullByte function to detect null byte injection attacks (security hardening)
  • Proven_SafePath.res: Updated isSafe to check both traversal and null byte conditions
  • Proven_SafeString.res: Refactored fromCodePoints to use pre-allocated array instead of mutable ref

Testing & Configuration

  • Removed TypeScript generics from test helper functions (simplified to plain JavaScript)
  • Added test task to deno.json
  • Updated ReScript lock file (transitive dependency resolution)

Implementation Details

  • Array operations now use pre-allocation with Array.make and indexed assignment (Array.setUnsafe) for better performance
  • String concatenation in loops replaced with array join operations
  • Security validation now explicitly checks for null bytes in file paths
  • All changes maintain backward compatibility with existing functionality

https://claude.ai/code/session_01ApYxQtnUdsJ9BpmEfBUe8W

claude added 2 commits April 16, 2026 03:21
- security: escape contaminant descriptions in main.js innerHTML to prevent XSS
- security: reject null bytes in Proven_SafePath.isSafe (truncation attack)
- perf: fix O(n²) loops in Proven_SafeHex.encodeSpaced, decodeToString, and
  Proven_SafeString.fromCodePoints (preallocate arrays, use Array.join)
- lang policy: convert .ts test files to .js (TypeScript is banned)
- config: replace remaining TAURI_/src-tauri references in vite.config.js
  with GOSSAMER_/target (repo migrated to Gossamer in 1b32494)
- a11y: add role="status"/role="alert" + aria-live on status, error, and
  preview/verify panels
- dx: split inline <style> from index.html into src/styles/shell.css so
  Vite can HMR it alongside main.css
- dx: add `deno task test` for running the Deno test suite

Regenerates .res.js outputs and lib/ocaml/ build artefacts.

https://claude.ai/code/session_01ApYxQtnUdsJ9BpmEfBUe8W
@hyperpolymath
hyperpolymath merged commit d5e17ec into main Apr 16, 2026
16 of 19 checks passed
@hyperpolymath
hyperpolymath deleted the claude/suggest-improvements-ZiGyN branch April 16, 2026 03:26
@sonarqubecloud

Copy link
Copy Markdown

Repository owner deleted a comment from chatgpt-codex-connector Bot May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants