Repository navigation
refactor: import Node built-ins with the node: prefix - #28
Closed
eric-engberg wants to merge 12 commits into
Closed
eric-engberg wants to merge 12 commits into
eric-engberg wants to merge 12 commits into
Conversation
The codebase mixed two styles for Node's own modules: a handful of files
imported 'node:fs', 'node:os' and friends while the rest used bare ids
such as 'fs' and 'child_process'. Use the node: prefix everywhere, so
each import says plainly that it is Node's module and cannot resolve to
an npm package of the same name.
This covers static imports and re-exports, type-only imports, dynamic
import(), require() (including the script the Custom Command widget
hands to a child runtime and the scripts tests write to disk), and
vi.mock() ids in tests. Vitest and Bun resolve 'child_process' and
'node:child_process' to the same module, for both mocks and spies, so
every mock still applies to the code under test. ESLint's import order
moved five imports to keep builtins sorted.
No behavior change. The bundle already loads node: imports, and every
Node version that can load the bundle also supports require('node:...').
eric-engberg
marked this pull request as ready for review
October 5, 2026 03:49
…sh style (sirmalloc#665) Fish style replaced any cwd that merely started with the home path, so with home /Users/al the sibling /Users/alex/project rendered as "~ex/project". Reuse the boundary-checked abbreviateHomeDir that the plain ~ option already uses. Co-authored-by: effectustasi <216187407+effectustasi@users.noreply.github.com>
…ith 10 updates (sirmalloc#662) Bumps the dev-dependencies group with 10 updates in the / directory: | Package | From | To | | --- | --- | --- | | [@remotion/cli](https://github.com/remotion-dev/remotion) | `4.0.524` | `4.0.532` | | [chalk](https://github.com/chalk/chalk) | `6.0.0` | `6.0.1` | | [eslint](https://github.com/eslint/eslint) | `10.10.0` | `10.11.0` | | [react](https://github.com/react/react/tree/HEAD/packages/react) | `19.2.8` | `19.3.0` | | [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) | `19.2.18` | `19.3.0` | | [react-dom](https://github.com/react/react/tree/HEAD/packages/react-dom) | `19.2.8` | `19.3.0` | | [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) | `19.2.7` | `19.3.0` | | [remotion](https://github.com/remotion-dev/remotion) | `4.0.524` | `4.0.532` | | [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) | `8.70.0` | `8.70.1` | | [zod](https://github.com/colinhacks/zod) | `4.5.4` | `4.6.5` | Updates `@remotion/cli` from 4.0.524 to 4.0.532 - [Release notes](https://github.com/remotion-dev/remotion/releases) - [Commits](remotion-dev/remotion@v4.0.524...v4.0.532) Updates `chalk` from 6.0.0 to 6.0.1 - [Release notes](https://github.com/chalk/chalk/releases) - [Commits](chalk/chalk@v6.0.0...v6.0.1) Updates `eslint` from 10.10.0 to 10.11.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](eslint/eslint@v10.10.0...v10.11.0) Updates `react` from 19.2.8 to 19.3.0 - [Release notes](https://github.com/react/react/releases) - [Changelog](https://github.com/react/react/blob/main/CHANGELOG.md) - [Commits](https://github.com/react/react/commits/v19.3.0/packages/react) Updates `@types/react` from 19.2.18 to 19.3.0 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react) Updates `react-dom` from 19.2.8 to 19.3.0 - [Release notes](https://github.com/react/react/releases) - [Changelog](https://github.com/react/react/blob/main/CHANGELOG.md) - [Commits](https://github.com/react/react/commits/v19.3.0/packages/react-dom) Updates `@types/react-dom` from 19.2.7 to 19.3.0 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-dom) Updates `remotion` from 4.0.524 to 4.0.532 - [Release notes](https://github.com/remotion-dev/remotion/releases) - [Commits](remotion-dev/remotion@v4.0.524...v4.0.532) Updates `typescript-eslint` from 8.70.0 to 8.70.1 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.70.1/packages/typescript-eslint) Updates `zod` from 4.5.4 to 4.6.5 - [Release notes](https://github.com/colinhacks/zod/releases) - [Commits](colinhacks/zod@v4.5.4...v4.6.5) --- updated-dependencies: - dependency-name: "@remotion/cli" dependency-version: 4.0.532 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: chalk dependency-version: 6.0.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: eslint dependency-version: 10.11.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: react dependency-version: 19.3.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: "@types/react" dependency-version: 19.3.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: react-dom dependency-version: 19.3.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: "@types/react-dom" dependency-version: 19.3.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: remotion dependency-version: 4.0.532 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: typescript-eslint dependency-version: 8.70.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: zod dependency-version: 4.6.5 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…c#661) The status page fetch behind the Claude Status widget was only tested for a response stream that aborts or errors. Its other outcomes had no tests: a body split across chunks, a non-200 or empty response, a request that errors or times out (and must be destroyed so the socket doesn't outlive the render), and HTTPS_PROXY handling, where a blank value must be ignored and a value that isn't a URL must settle as a failed lookup rather than throw out of the render. Also cover the 16-color fallback for incident colors (major drops from orange to red, critical to bright red). The fake response helper now takes the final stream event, so the existing abort and error tests share it.
…irmalloc#660) Powerline separator colors (same, single and missing backgrounds, both normal and inverted), caps on widgets without a background, bold resets at flex gaps and end caps, preserved command colors, and auto-align padding for merged groups had no tests, and neither did inherited and override colors on standard-mode separators and padding. These paths decide whether a status line keeps a continuous color band or shows gaps, wrong arrow colors and leaked bold. The ANSI parser gets direct tests for 8-bit C1 CSI/OSC, unterminated sequences, two-character escapes, flags, ZWJ emoji sequences and hyperlink closing on truncation, so widths and truncation stay right for custom command output. Claude settings gain tests for loadClaudeSettingsSync, refresh-interval reads and writes against unreadable settings, a failed .orig backup not blocking install, invalid ccstatusline configs not syncing hooks, and the getRemoteControlStatus manifest lookup.
The line picker behind Edit Lines and Edit Colors had no tests. These drive it through Ink with one key per write: listing lines with their widget counts, moving and selecting, going back by ESC or the Back entry, appending, the delete confirmation (Yes, No, ESC), move mode with its wrap-around swap, the Powerline theme warning, and new props from the parent. Each key waits for its visible effect before the next one. Keys that must do nothing wait until Ink has read them from stdin, then check that nothing was redrawn.
Render UpdateCheckerMenu in each state it shows (checking, up to date, registry failure, update available with runnable, missing and no commands, auto-update) and drive its keys: Enter on each entry, Down to Check again and Back, and Escape, checking which callback fires.
… busy machine (sirmalloc#655) "returns successful output when a background job keeps stdout open" gave the command 200ms to start, print and exit, and the background job 1.2s to live. On a loaded machine starting node alone can take longer than 200ms, so the command timed out and the test failed. It then waited a fixed 1.3s for the job's file, which a slow start also outran. The command now gets 1.5s and the job lives 3s, so the test still shows the command returns without waiting for the job, with room to start. It polls for the job's file instead of sleeping. The overflow-tree test gets a long timeout too, so only the overflow can end it, which is what it asserts; the timeout-tree test keeps its short one.
The config tests used a fixed /tmp/ccstatusline-config-test-home and deleted it before every test. Two test runs at once (an editor's test runner plus a terminal run, or parallel CI jobs on one machine) deleted each other's settings files mid-test and failed at random. Run three at a time, the file failed 128 of 345 tests on main. A directory from mkdtempSync is unique to each run, so they no longer collide.
…loc#652) The Ink component tests slept a fixed 25ms after rendering and after each key, then asserted. Ink redraws, and React re-attaches Ink's input listener, on their own schedule, so on a loaded machine the assertion ran before the redraw, or the next key arrived before the listener was back and was dropped. Under CPU load these tests failed intermittently: TerminalWidthMenu, RefreshIntervalMenu and the timezone editor most often. Each test now waits for the visible effect of its key (the selection moving, a prompt appearing, a callback firing), with a timeout, through a small shared helper in src/tui/__tests__/helpers/wait-for-ink.ts. After each successful wait it yields two setImmediate turns so React can re-attach the listener before the next key. No assertions change.
…ls (sirmalloc#645) The codebase mixed the two spellings: 39 parseInt vs 6 Number.parseInt, 14 isNaN vs 14 Number.isNaN (Number.isFinite and Number.parseFloat were already used exclusively). parseInt -> Number.parseInt is a pure rename (they are the same function). Number.isNaN differs from the global only for non-number arguments, which it doesn't coerce; every one of the 14 calls checks the result of parseInt(..., 10), a number, so behavior is unchanged. ESLint's built-in no-restricted-globals now rejects global parseInt, parseFloat, isNaN and isFinite with a message pointing at the Number.* form, so the mix doesn't come back. No new dependency.
|
Owner
Author
|
Merged upstream as sirmalloc#657. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Standalone, cut from
main.What
Every import of a Node.js built-in module now uses the
node:prefix:'fs'→'node:fs','child_process'→'node:child_process', and likewise forpath,os,crypto,https,module,url,util,events,ttyandstring_decoder. That covers 84 files (30 runtime/script files, 54 test files) and 203 lines. Nothing visible changes and there's no behavior change.Why
mainmixes both styles. Seven runtime files (custom-command.ts,git.ts,git-review-cache.ts,jsonl-blocks.ts,jsonl-cache.ts,jsonl-metrics.ts,CurrentWorkingDir.tsx) and 19 test files already import withnode:, and two more tests use it inrequire(). Meanwhile 30 runtime/script files and 54 test files use bare ids, and 13 files mix both styles in the same import block (for example,git.tsimports'child_process'next to'node:fs').The prefix says plainly that a module is Node's own and can't resolve to an npm package of the same name. Using one style also ends the per-file choice.
The published bundle already contains
node:imports, because Bun keeps them as written indist/. So the minimum Node version the package needs doesn't change (details under How).How
Every form a module id takes was converted:
import/export ... from, includingimport typeimport()(ccstatusline.ts,powerline.ts)require(): the script the Custom Command widget passes to a child runtime with-e, and the helper scripts tests write to disk and runvi.mock()ids in testsESLint's
import-x/orderkeeps builtins and packages in one alphabetized group, so its auto-fix moved five imports (https-proxy-agentnow sorts beforenode:*, andnode:cryptobeforenode:fs). No other edits.Mocks. The only built-in mocked by id is
child_process, in 30 test files, and all 30 now usevi.mock('node:child_process', ...), the same id the code under test imports. I checked under both Bun's test runner and Vitest on Node that a mock registered under either id applies to static and dynamic imports of both'child_process'and'node:child_process'. Neither runner applies mocks tocreateRequire()calls, so the three tests that userequire('node:child_process')to reach the realexecFileSyncpast the mock still get the real one.vi.spyOnon a module namespace sees the same object for'os'and'node:os'in both runners. As a control, I pointed each of the 30 mocks at an unused built-in (node:dgram), and 29 files then failed when run alone, so their mocks are in effect. The other one,CompactionCounter.test.ts, passes either way onmaintoo; its mock is a guard those tests never reach.Minimum Node version. The Custom Command child script now does
require('node:child_process'), andrequire()acceptsnode:only from Node 16.0 (and 14.18).main's bundle already needs Node 16.6, because its entry chunk callsArray.prototype.atat module load (inget-east-asian-width). Official Node 16.5.0 fails to load bothmainand this branch with the sameambiguousRanges.at is not a function. Node 16.6.0 renders a Custom Command line identically on both.Demo
No demo: nothing visible changes.
Testing
bun run lint: passes.bun test(Bun 1.4.2): 2358 pass, 0 fail, 5210expect()calls across 148 files, the same totals asmain. The JUnit reports matchmaintest by test, assertion counts included.node node_modules/vitest/vitest.mjs run --reporter=json): this branch has 2336 tests, 2185 passed, 151 failed in 17 files. A cleanmaingives the same 151 failures in 17 files, matching test by test; the failures come from spying on Node built-ins, which Node forbids. The only difference: two files that fail at load on both quote the mock id in their error message (No "spawn" export is defined on the "node:child_process" mock). A firstmainrun also failed 5 timing-sensitive TUI/process tests that passed on rerun; this branch had none of them.runtime-check.sh refactor/node-protocol-imports, which builds this branch andmain):echo hello-from-cmd) renders byte-for-byte the same onmainand this branch under Bun 1.4.2, Node 26.10.0 and Node 16.6.0.require('module').builtinModules, in anyfrom/import/import()/require()/vi.mock()position, matches nothing. Searching for any quoted built-in name at all finds only the'url'editor-mode literal insrc/widgets/Link.tsx, which isn't a module id.