Skip to content

feat: currentcolor and inherited open() color - #158

Draft
natemoo-re wants to merge 3 commits into
feat/ansi16-system-colorsfrom
feat/currentcolor
Draft

natemoo-re wants to merge 3 commits into
feat/ansi16-system-colorsfrom
feat/currentcolor

Conversation

@natemoo-re

Copy link
Copy Markdown
Member
  • Stacked on feat: CSS system colors map to the ANSI 16-color palette #157.
  • open() gets a color field. Nested open()s and text()s inherit it unless they set their own, like CSS color.
  • currentcolor works in every color field and means "this element's color". As color itself, it means inherit.
  • border.color is now optional and defaults to currentcolor, so borders match the text color by default.
  • currentcolor never throws. If the color it points at is the terminal default and it's used as a background, it paints the theme foreground the terminal reported, or falls back to the default background.
  • Inheritance is resolved while packing each frame. Nothing new goes over the wire, and no state carries between frames.
  • Spec commit is separate from the implementation commit.

@bombshell-cooper

bombshell-cooper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Changeset suggestion

The current changeset no longer matches this PR. This review contains a corrected replacement.

Why: Changeset should start with an approved active present-tense verb. Changeset package scope does not match the affected packages confidently.

View the proposed changeset
---
'@bomb.sh/tty': minor
---

Adds `color` to `open()`: the element's own foreground color, inherited by every descendant that does not set its own.

`currentcolor` is now a valid color string at every color field. In `open({ color })` and `text({ color })` it means "inherit" (same as omitting the field); in any other field — `bg`, `border.color`, `border.bg`, or a structured border side's `color`/`bg` — it resolves to the directive's own resolved foreground, then follows normal field resolution (terminal-themed, probed-theme, or sRGB passthrough). `border.color` is now optional and defaults to `currentcolor`, matching CSS.

#### Migration

`border.color` was previously required. Existing code that supplies it is unaffected. Code that relied on a missing `border.color` being a validation error must now supply an explicit color to override inheritance:

```diff
  open("box", {
    border: {
-     color: "red",   // was required; remove to inherit, or keep to override
+     color: "red",
      top: 1,
    },
  })
```

If you were checking `validate()` against a border with no `color`, that case now returns `true` instead of `false`.

Review this changeset manually

If this draft is correct, react with 🚀 and Cooper will commit it to this branch.

@@ -0,0 +1,16 @@
---

@bombshell-cooper bombshell-cooper Bot Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changeset needs revision.

Changeset should start with an approved active present-tense verb. Changeset package scope does not match the affected packages confidently.

View the proposed replacement
---
'@bomb.sh/tty': minor
---

Adds `color` to `open()`: the element's own foreground color, inherited by every descendant that does not set its own.

`currentcolor` is now a valid color string at every color field. In `open({ color })` and `text({ color })` it means "inherit" (same as omitting the field); in any other field — `bg`, `border.color`, `border.bg`, or a structured border side's `color`/`bg` — it resolves to the directive's own resolved foreground, then follows normal field resolution (terminal-themed, probed-theme, or sRGB passthrough). `border.color` is now optional and defaults to `currentcolor`, matching CSS.

#### Migration

`border.color` was previously required. Existing code that supplies it is unaffected. Code that relied on a missing `border.color` being a validation error must now supply an explicit color to override inheritance:

```diff
  open("box", {
    border: {
-     color: "red",   // was required; remove to inherit, or keep to override
+     color: "red",
      top: 1,
    },
  })
```

If you were checking `validate()` against a border with no `color`, that case now returns `true` instead of `false`.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Size Increased — +9.0 KB

142.5 KB unpacked

@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@bomb.sh/tty@158

commit: 7da7b2b

@natemoo-re
natemoo-re added this pull request to stack #174 December 1, 2026 01:27
@natemoo-re
natemoo-re force-pushed the feat/currentcolor branch 3 times, most recently from c745fd3 to feb2218 Compare December 1, 2026 02:25
Replaces the "currentcolor is reserved" wording. open() gains a color
field, inherited by descendants unless overridden; currentcolor means
"inherit" in a color field and "this directive's own resolved color,
field-resolved like any other color" everywhere else. border.color
becomes optional, defaulting to currentcolor. Inheritance is a
pack()-time stack scoped to one frame's directive array.
open() gains a color field: the element's own foreground, inherited
by descendants via a pack()-time stack pushed on open and popped on
close. currentcolor means "inherit" in a color field and "this
directive's own resolved color" everywhere else, going through the
same field resolution (resolveForField) as any other color.
border.color is now optional and defaults to currentcolor.

resolveColor() returns a CURRENT_COLOR sentinel for the keyword;
ops.ts substitutes the inherited/own color before field resolution
via resolveOwn()/colorValue(), both newly threading a `current`
parameter through colorWord/sideFg/sideBg. No wire-format change:
open()'s own color has no direct rendering, only TS-side inheritance.
Inheritance, currentcolor, and system color field resolution move from
pack() to the renderer, which resolves them over the element tree of the
frame being rendered and against the theme in effect for that render.

Packing a directive no longer depends on its ancestors or on the theme,
so a snapshot inherits from the position where it appears, and a theme
report reaches snapshotted content on the next render. The same rule
carries over to element replay.

The transfer encoding gains symbolic color words for the two default
keywords and currentcolor; cells keep resolved colors only. pack() drops
its theme parameter; the theme lives in native state and crosses the
boundary on update(), not on every render.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BzW3aAMCMjaCM4gYXZcWGb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants