You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ghostty): import palette indexes in supported numeric bases - #50546
Import Ghostty palette colors into their intended slots.
What Changed
Parse the documented decimal, hexadecimal, octal and binary palette-index syntax as whole values, then keep the existing range and ANSI-color mapping. Invalid suffixes no longer overwrite a valid earlier color.
Why
Ghostty supports decimal, hexadecimal, octal, and binary palette indexes. The importer parsed every 0x/0o/0b index as zero, overwriting black and leaving the intended ANSI colors unset. It also accepted invalid trailing characters as a valid index.
src/main/ghostty/index.ts imports terminal config and themes through mapGhosttyConfig.
N/A — no graphical layout or interaction change; data-level evidence follows.
Before/after data-level reproduction of the same input:
Before
After
Both regressions failed on main: supported indexes collapsed onto black, and 1wrong overwrote red.
Documented numeric bases map to red/green/yellow/blue, invalid trailing characters do not override valid earlier colors; 2 tests passed.
No graphical layout change is included. The evidence above is from the production operation; no desktop screenshot is claimed.
Testing
I manually tested these changes locally through the production-entry reproduction described above
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Parser data integrity and accounting; production parser baseline reproduced
node config/scripts/test-runtime/execution-policy/run-vitest.mjs run --config config/vitest.config.ts src/main/ghostty/palette-index-import.test.ts
Locally exercised on Linux with Node 24.22.3. External API cases use protocol fixtures; no live provider account, graphical desktop, macOS, Windows or remote SSH execution is claimed.
Changed-code quality passed with zero findings. Node typecheck passed (17,005 files); web typecheck passed (16,094 files). The integrated regression run passed 51 tests in 30 files; the Drive performance contract passed separately. The final three test typing changes were rerun and passed. These are aggregate first-batch results, not per-PR test counts.
The required pnpm check:changed --base=9890ea181c0f9ae59fb82da64c4a6fbc0504a817 was attempted after final edits. It stopped in the workspace-package build because this environment rejects the tsx CLI's local IPC socket (listen EPERM). The full gate/build is therefore not claimed to pass; CI remains required. The process-host build entry executed successfully using node --import tsx --conditions=orca-source.
Performance
Only documented numeric syntax and 0..255 indexes are accepted. Only the existing ANSI 0..15 mappings are applied. No I/O or allocations proportional to terminal contents.
Risk
Level: Low
Only documented numeric syntax and 0..255 indexes are accepted. Only the existing ANSI 0..15 mappings are applied. No I/O or allocations proportional to terminal contents.
A plain revert restores the previous behavior; no schema migration is introduced.
AI Disclosure
Core contribution owner: @Afloat16. Required tooling disclosure: GPT-6 Astra Pro was used for implementation and review.
Review
Reviewed the production caller, baseline failure, ordinary controls, data integrity and additional work. No new shell commands, path grammar, remote protocol fields, polling or UI layout were introduced. SSH/remote, mobile and agent integrations retain their existing entry points.
Agent skill upstream boundary
Not applicable: this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments or documentation.
The Ghostty palette importer now accepts decimal, hexadecimal, octal, and binary indices as whole values and rejects invalid or out-of-range indices. Tests cover mapping supported indices to ANSI color slots and preventing malformed input from replacing a valid decimal-index override.
Severity of issue fixed: Low
Merge Risk: Low · up to f8ca0
Ghostty palette imports now ignore plus-prefixed indices such as +1, which were previously imported. This is a rare edge case and the import falls back safely, so the risk is low. Handle the leading + before merging, or accept the narrow regression.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: palette indexes in Ghostty imports are now parsed in the supported numeric bases. The raw summary confirms the mapper now validates decimal, 0x, 0o and 0b indices. The…
Description check
The description follows the template and covers the main sections: ELI5, What Changed, Why, Linked Issue (Fixes #50545), Visual Proof (N/A with reason), Testing, Performance, Risk with level, AI Discl…
Linked Issues check
Issue #50545 requires that Ghostty decimal, 0x, 0o, and 0b palette indices map to their ANSI slots, and that an invalid suffix such as 1wrong does not overwrite an earlier valid entry. The diff in src…
Out of Scope Changes check
The whole-PR diff against merge base 9890ea1 changes two files. src/main/ghostty/mapper.ts contains only the palette index parsing change, with the ANSI index mapping …
Full details: Title check
Explanation
The title names the main change: palette indexes in Ghostty imports are now parsed in the supported numeric bases. The raw summary confirms the mapper now validates decimal, 0x, 0o and 0b indices. The fix prefix and the scope in parentheses are clear. The title is specific and does not use vague terms.
Full details: Description check
Explanation
The description follows the template and covers the main sections: ELI5, What Changed, Why, Linked Issue (Fixes #50545), Visual Proof (N/A with reason), Testing, Performance, Risk with level, AI Disclosure, Review, upstream boundary, and Checklist. The What Changed and Why sections explain the before and after and the mechanism. The Testing section records the test command and the local environment, and it states which platforms were not tested. The description also records that the full pnpm check:changed gate did not complete locally, and CI must cover it. The Visual Proof section is a data-level table instead of a before/after visual, which the template accepts when no UI changes. Two items are weak: the Testing checklist entry for the 'fails without this change' anti-pattern check is ticked without a clear per-test demonstration, and the 'Full lint/typecheck/test/build gate' checkbox is left unchecked. The Visual Proof table is also oddly worded (for example 'Both regressions failed on main'). The description also has a stray line about src/main/ghostty/index.ts that is not explained under What Changed. These gaps are minor and do not make the description incomplete, so the check passes.
Full details: Linked Issues check
Explanation
Issue #50545 requires that Ghostty decimal, 0x, 0o, and 0b palette indices map to their ANSI slots, and that an invalid suffix such as 1wrong does not overwrite an earlier valid entry. The diff in src/main/ghostty/mapper.ts replaces Number.parseInt(idxStr, 10) with a whole-value check. The check accepts /^(?:\d+|0x[\da-f]+|0o[0-7]+|0b[01]+)$/i and converts with Number. Non-integers and indices above 255 are skipped. A malformed index now yields NaN and is skipped, so it no longer overwrites red. The added tests in src/main/ghostty/palette-index-import.test.ts cover 0x1 (red), 0b10 (green), 0o3 (yellow), and decimal 4 (blue). They also cover 1wrong not overriding 1=#112233. The code matches the issue requirements. The test results were reported by the author and were not re-run in this review.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against merge base 9890ea1 changes two files. src/main/ghostty/mapper.ts contains only the palette index parsing change, with the ANSI index mapping and color validation kept. src/main/ghostty/palette-index-import.test.ts contains only regression tests for that change. The related issues #7126, #37292, and #42678 are listed as scope references only and are not implemented here. No unrelated change was found in the inspected evidence.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 3f51ed64-fb02-4ca7-8ac3-5fdbbe476d75
Commits
Reviewing files that changed from the base of the PR and between f7eb7be and f8ca09d.
Files selected for processing: 2
src/main/ghostty/mapper.ts
src/main/ghostty/palette-index-import.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Preserve valid plus-prefixed palette indices.
Ghostty 1.2.3 parses palette indices with Zig’s parseInt, which accepts a leading +. (raw.githubusercontent.com)
For palette = +1=#112233, the previous decimal parseInt conversion produced index 1. (tc39.es) The new regex rejects +1, so the supplied mapper drops the red override.
Remove an optional leading + before validation and conversion. Keep whole-value validation so 1wrong remains invalid. Add a regression assertion for +1.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in ff11078. The importer now preserves a leading plus sign in decimal and radix-prefixed indices, signed zero, and interior digit separators supported by Ghostty’s Zig parser. It still rejects malformed whole values such as 1wrong, 0x_1, 1_, and 0_x1.
The new compatibility case failed against the previous commit; all three palette tests now pass. I also saw the follow-up in #50608; this records the corresponding compatibility fix on the original branch.
The reason will be displayed to describe this comment to others. Learn more.
Analysis chain
Script executed:
#!/bin/bashset -u
printf'%s\n''--- Revision ---'
git rev-parse HEAD
git show --no-patch --format='%H %s' ff110780bde874cc04541bf99c787774e89c6b66 2>&1||trueif git merge-base --is-ancestor ff110780bde874cc04541bf99c787774e89c6b66 HEAD 2>/dev/null;thenecho'Reported commit is an ancestor of HEAD';elseecho'Reported commit is not confirmed as an ancestor of HEAD';fiprintf'%s\n''--- Mapper outline ---'
ast-grep outline src/main/ghostty/mapper.ts --items all 2>&1| head -100
printf'%s\n''--- Mapper parser and palette ---'
cat -n src/main/ghostty/mapper.ts | sed -n '1,175p'printf'%s\n''--- Palette test outline ---'
ast-grep outline src/main/ghostty/palette-index-import.test.ts --items all 2>&1| head -100
printf'%s\n''--- Palette tests ---'
cat -n src/main/ghostty/palette-index-import.test.ts | sed -n '1,220p'printf'%s\n''--- Repository instruction file names ---'
fd -H -t f '^(AGENTS\.md|CLAUDE\.md)$'. -E node_modules -E .git | head -80
Length of output: 10362
Script executed:
#!/bin/bashset -u
fix=ff110780bde874cc04541bf99c787774e89c6b66
printf'%s\n''--- Repository instructions ---'
cat -n AGENTS.md | sed -n '1,220p'printf'%s\n''--- Reported fix diff ---'
git show --format=fuller --stat "$fix"
git show --format= "$fix" -- src/main/ghostty/mapper.ts src/main/ghostty/palette-index-import.test.ts
printf'%s\n''--- Commit ancestry ---'if git merge-base --is-ancestor f8ca09d1f791b8057ad917c25349d96dfd7409f6 "$fix";thenecho'Original review commit is an ancestor of the reported fix';elseecho'Original review commit is not confirmed as an ancestor of the reported fix';fiprintf'%s\n''--- Current pull request metadata ---'if metadata=$(gh api repos/stablyai/orca/pulls/50546 --jq '{state, merged, head_sha: .head.sha, head_ref: .head.ref}'2>&1);thenprintf'%s\n'"$metadata"
head_sha=$(printf '%s\n'"$metadata"| jq -r '.head_sha')if git cat-file -e "$head_sha^{commit}"2>/dev/null;thenif git merge-base --is-ancestor "$fix""$head_sha";thenecho'Reported fix is an ancestor of the current pull request head';elseecho'Reported fix is not an ancestor of the current pull request head';fiprintf'%s\n''--- Current pull request head palette index lines ---'
git show "$head_sha:src/main/ghostty/mapper.ts"| cat -n | sed -n '1,70p;120,170p'elseecho'Current pull request head is not available in the local checkout'fielseprintf'Could not retrieve pull request metadata: %s\n'"$metadata"fi
Length of output: 15685
@Afloat16, commit ff11078 accepts +1 and adds a regression test. I did not run the tests.
As of my check, #50546 is closed without merging. Its head is still f8ca09d, which rejects +1; ff11078 is not in that head. I am not marking the finding addressed for this PR.
If you found this review helpful, would you consider giving us a shout-out on X?
Thanks @Afloat16 for finding and fixing this! We needed a couple of follow-ups (keeping +/-0 signs and _ digit separators the way Ghostty parses them) and couldn't push to your branch, so we're landing it in #50608. Your authorship is kept via a Co-authored-by trailer.
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
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.
ELI5
Import Ghostty palette colors into their intended slots.
What Changed
Parse the documented decimal, hexadecimal, octal and binary palette-index syntax as whole values, then keep the existing range and ANSI-color mapping. Invalid suffixes no longer overwrite a valid earlier color.
Why
Ghostty supports decimal, hexadecimal, octal, and binary palette indexes. The importer parsed every 0x/0o/0b index as zero, overwriting black and leaving the intended ANSI colors unset. It also accepted invalid trailing characters as a valid index.
src/main/ghostty/index.ts imports terminal config and themes through mapGhosttyConfig.
Linked Issue
Fixes #50545
Visual Proof
N/A — no graphical layout or interaction change; data-level evidence follows.
Before/after data-level reproduction of the same input:
No graphical layout change is included. The evidence above is from the production operation; no desktop screenshot is claimed.
Testing
Parser data integrity and accounting; production parser baseline reproduced
Locally exercised on Linux with Node 24.22.3. External API cases use protocol fixtures; no live provider account, graphical desktop, macOS, Windows or remote SSH execution is claimed.
Changed-code quality passed with zero findings. Node typecheck passed (17,005 files); web typecheck passed (16,094 files). The integrated regression run passed 51 tests in 30 files; the Drive performance contract passed separately. The final three test typing changes were rerun and passed. These are aggregate first-batch results, not per-PR test counts.
The required
pnpm check:changed --base=9890ea181c0f9ae59fb82da64c4a6fbc0504a817was attempted after final edits. It stopped in the workspace-package build because this environment rejects the tsx CLI's local IPC socket (listen EPERM). The full gate/build is therefore not claimed to pass; CI remains required. The process-host build entry executed successfully usingnode --import tsx --conditions=orca-source.Performance
Only documented numeric syntax and 0..255 indexes are accepted. Only the existing ANSI 0..15 mappings are applied. No I/O or allocations proportional to terminal contents.
Risk
Level: Low
Only documented numeric syntax and 0..255 indexes are accepted. Only the existing ANSI 0..15 mappings are applied. No I/O or allocations proportional to terminal contents.
A plain revert restores the previous behavior; no schema migration is introduced.
AI Disclosure
Core contribution owner: @Afloat16. Required tooling disclosure: GPT-6 Astra Pro was used for implementation and review.
Review
Reviewed the production caller, baseline failure, ordinary controls, data integrity and additional work. No new shell commands, path grammar, remote protocol fields, polling or UI layout were introduced. SSH/remote, mobile and agent integrations retain their existing entry points.
Agent skill upstream boundary
Notes
Primary references:
Related work checked for distinct scope:
Checklist