Skip to content

test(terminal-env): read the stand-in core's environment only once it runs - #3661

Merged
devswha merged 1 commit into
mainfrom
fix/terminal-env-proc-race
Nov 11, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/terminal-env-proc-race

Conversation

@devswha

@devswha devswha commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Change

Test-only fix for a new flaky unit test from #3652: server/herdr-core/terminal-env.test.ts, "fits the terminals to the running core's own environment, else to the one that starts it" (expect(...).toMatchObject at line 57). It failed in a local bun run check fast on main df59ebd, with the same code as main.

Cause

The test starts /bin/sh -c "read _" with its own environment as a stand-in for the running core, then reads that process's environment from /proc/<pid>/environ. Bun.spawn returns the pid as soon as the child is forked, before it runs /bin/sh. Until then, /proc shows the test's own environment, so a read that comes first finds neither PATH=/usr/bin:/core/tools nor NO_COLOR=1. A real core has already answered server.status before it is read, so production code is not affected.

Fix

The stand-in prints a line once it runs (echo started; read _), and the test reads /proc only after that line arrives. No sleep, no timeout, no product change.

Validation

  • The test alone, 8 copies at a time, 25 runs each, on this host (load around 35-50):
    • main: 64 of 200 failed;
    • this branch: 0 of 200.
  • bun run check fast: pass (unit 16109 pass, 0 fail).
  • Not run: check full. Test-only, so no changelog fragment.

… runs

Bun.spawn returns the pid before the child runs /bin/sh, and until then
/proc/<pid>/environ shows the test's own environment, so "fits the terminals
to the running core's own environment" failed when its read came first (64
of 200 runs at 8 copies on main). The stand-in now prints a line once it runs
and the test reads /proc after it. A real core has answered server.status
before it is read, so the product is unaffected.
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Updated a Linux environment test to wait for shell output before checking that the running core’s PATH and NO_COLOR are used.

The Linux running-core environment test now waits for its shell to print started before checking the core’s PATH and NO_COLOR values.

Changes: Terminal environment test

Layer / File(s) Summary
Synchronize environment check
server/herdr-core/terminal-env.test.ts
The shell prints started, and the test waits for stdout before checking the running core’s environment.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Other

Possibly related PRs

  • devswha/ovis#3652: Adds the terminal-environment implementation and the running-core test updated here.
  • devswha/ovis#3657: Adds startup synchronization to the same running-core environment test.
Merge Risk: Minimal · up to d4cf3

This is a test-only change that fixes a flaky environment check and does not change production behavior. There is no actionable merge risk.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly and concisely describes the test-only synchronization change for the flaky terminal environment test.
Description check Passed The description includes the problem, cause, fix, validation results, skipped checks, and the reason no changelog fragment is needed. It matches the required Change and Validation sections.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between df59ebd and d4cf3bb.

Files selected for processing: 1

  • server/herdr-core/terminal-env.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.

@devswha
devswha merged commit 9c07ec1 into main Nov 11, 2026
21 checks passed
@devswha

devswha commented Nov 11, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head d4cf3bbf5c73 as 9c07ec1c1e7a on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
codex CLEAR

One reviewer: test-only PR (one unit test file).

Test-only PR (server/herdr-core/terminal-env.test.ts, four lines), so one reviewer: Codex Terra, CLEAR.

It closes a unit flake that #3652 brought to main: the test "fits the terminals to the running core's own environment" read /proc/<pid>/environ of its stand-in core before the spawned process had started running. The author's runs at 8 copies: 64 of 200 failed on main, 0 of 200 with the fix. It could fail Fast checks for any PR.

@devswha
devswha deleted the fix/terminal-env-proc-race branch November 11, 2026 11:12
devswha added a commit that referenced this pull request Nov 11, 2026
… 0.5.2 (#3550) (#3664)

Owner approved removing the ring on 2026-11-11: this takes out a
design-pass element (#3431's keyboard-focus ring around the terminal)
and brings back the 0.5.1 look.

Fixes #3550

## Cause

#3431 (the 0.5.2 design pass) added three rules to
`src/components/PaneTerminal.css`: an accent outline on
`.pane-terminal:focus-within`, plus inset accent box-shadows on `.xterm`
and `.xterm-viewport`, as a ring
showing where keys go. Its PR and changelog did not mention it. In
Terminal mode it draws a line around the
terminal whenever the terminal has the focus, which is always once you
click into it; Safari shows it most
plainly as a blue line under the tab row.

## Change

The three rules are removed. Nothing replaces them: the terminal's own
cursor shows where keys go, and the
current pane's head already takes the accent and a heavier title
(`.pane-frame.is-current`). No other
keyboard-only indicator was added, since any ring on the xterm textarea
also shows for a mouse click (a
textarea matches `:focus-visible` however it was focused).

The cursor is the focus indicator, as in standalone terminals such as
Ghostty and iTerm2, which draw no ring
around a focused terminal; this is also how 0.5.1 looked.

## Design gate

`bun scripts/design-gate-qa.ts --surfaces terminal-view,split-panes
--checks focus,contrast`, in the CI runner
image, with main's CSS as the baseline: 4 NEW findings, all
`focus-contrast` on
`textarea.xterm-helper-textarea "Terminal input"` (1.00:1 < 3:1, the
hidden textarea's own outline) on
`terminal-view` and `split-panes` at 1440, light and dark; nothing
RESOLVED. They are the ring this PR removes
on purpose, approved by the owner as above, so they are expected, not a
reason to hold the PR. CI does not run
the design gate.

## Screenshots

A shell pane in an owned herdr test workspace, Terminal mode, the
terminal focused, light theme.

| | Desktop 1280 | Phone 390 |
|---|---|---|
| Before (main) | ![before
desktop](https://raw.githubusercontent.com/devswha/ovis/ac220b2d6c9078b0bb7122cc8ea837ef99107b8b/before-desktop.png)
| ![before
phone](https://raw.githubusercontent.com/devswha/ovis/ac220b2d6c9078b0bb7122cc8ea837ef99107b8b/before-phone.png)
|
| After | ![after
desktop](https://raw.githubusercontent.com/devswha/ovis/ac220b2d6c9078b0bb7122cc8ea837ef99107b8b/after-desktop.png)
| ![after
phone](https://raw.githubusercontent.com/devswha/ovis/ac220b2d6c9078b0bb7122cc8ea837ef99107b8b/after-phone.png)
|

## Validation

- `scripts/terminal-keyboard-demo-regression.ts`, in the CI runner image
(`herdr-ci-runner:local`): a new
assertion that the focused grid draws no outline or inset ring. It fails
with main's CSS and the whole script
  passes with this change.
- The design gate run above.
- `bun run check fast`: workflow syntax, generated types and themes,
typecheck and build ok; unit tests
failed only `server/herdr-core/terminal-env.test.ts`, a flake on main at
the time, since fixed by #3661.
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.

1 participant