7 Commits
Author SHA1 Message Date
Harshal Paltse 1a490f9d72 fix(dev): parse THINKRAIL_PORT strictly in the dev launchers (#1156)
* fix(dev): parse THINKRAIL_PORT strictly in the dev launchers

Add parsePort to @thinkrail/shared/freePort (plain decimal 0-65535) and use it in scripts/dev.ts and packages/server/src/dev.ts. Invalid values now warn and fall back to the default instead of becoming port 0, 16 or NaN. Adds tests and updates the shared SPEC.

* fix(dev): keep port 0 and warn on empty THINKRAIL_PORT
2026-11-05 10:41:37 +00:00
Rinat S 77ab071d04 chore: near-zero code comments — rationale lives in specs (#269)
Strip ~10.6k comments across apps/packages/e2e/scripts (parser-accurate,
string/JSX-safe). What survives: biome-ignore directives, five one-line
hazard notes pointing at their specs, and opaque-literal label tables
(unicode controls, git ref syntax, DEC modes, chunk-error strings,
line-number fixtures).

Rationale not yet specced was promoted first: xterm #6065 IME rescue ->
panels/SPEC.md; palette-reset ordering + alias self-reference ->
apps/web/scripts/SPEC.md. Everything else checked was already recorded
in the owning SPEC.md; the abandoned wsProtocol v4-v17 changelog is
deleted (git history retains it).

Codify the rule where agents read it: AGENTS.md ('Comments: avoid them.
Near-zero is the norm.' + a 'No comment creep' handoff audit),
writing-specs (specs are the only home for rationale), brainstorming
step 9 (self-review checks for rationale comments).
2026-08-20 17:43:43 +02:00
danyaberezunandRinat S ca17198fff feat(cli): add branded startup mark (#238)
Co-authored-by: Rinat S <rinat.suleimanov@jetbrains.com>
2026-08-19 15:39:14 +02:00
Rinat S 3aab075149 Rebrand thinkrail-pi → thinkrail (#71)
* Rebrand thinkrail-pi → thinkrail

Rename all thinkrail-pi references to thinkrail across the monorepo:
- npm scope @thinkrail-pi/* → @thinkrail/* (all import sites + package.json + bun.lock)
- env vars THINKRAIL_PI_* → THINKRAIL_*
- CLI bin `thinkrail`, APP_SLUG, default state dir ~/.thinkrail, .idea module
- ThinkRail-PI display name → ThinkRail in docs/specs

Portable pi extensions (pi-spec-graph, pi-visualize, pi-thinkrail-workflow)
and the .git worktree pointer are intentionally left untouched.

Split out from #67; the open-source docs/README/badge ship separately in #69.

* e2e: assert terminal text against .xterm-rows (fix xterm measure-element flake)

The terminal specs asserted `toContainText` on the whole terminal-instance
container. xterm.js 6.0.0 appends hidden `.xterm-char-measure-element` width-probe
spans (each `char.repeat(32)`, e.g. 32×"E" / 32×"1") inside the terminal element, so
`toContainText` on the container also reads those. Before the shell output paints,
the container's text is a run of measure glyphs ("EEEE…1111…") rather than the typed
command — a render-timing race that fails on loaded CI runners (passes locally).

Scope the text assertions to `.xterm-rows` (the painted screen only) via a new
`visibleTerminalScreen` helper, so assertions wait for the real output and never see
the measure spans. Test-only; no product change.
2026-07-07 13:21:29 +02:00
Rinat S b7e11ac5cd dev: open the OS default browser, not vite's Chrome heuristic (#28)
vite's `server.open` on macOS opens a running Chrome via AppleScript
regardless of the user's default browser (react-dev-utils heuristic), and no
BROWSER value cleanly bypasses it. Open the browser from scripts/dev.ts
instead, using `open`/`xdg-open`/`start` (the OS default) once vite is serving.

To open the exact URL, pre-pick the vite port too (THINKRAIL_PI_WEB_PORT,
symmetric with the host's THINKRAIL_PI_PORT) and pin it in vite with
`strictPort`; a bare `dev:web` leaves it unset → 24269, free to auto-increment.
Replaces the THINKRAIL_PI_DEV_OPEN flag.
2026-07-01 14:38:52 +02:00
Rinat S 0fbc9faebb host: one boot path (bootHost) + fix doubled dev host, open browser on dev (#25)
* host: one boot path (bootHost) + fix doubled dev host, open browser on dev

Split host launch by *who controls the port and owns the UI URL*, not by
dev-vs-prod, and share one boot wrapper:

- packages/server: add `bootHost(options)` (host/boot.ts) — resolve login-shell
  PATH, pick the port per `portMode` ("exact" honors it, "free" scans upward),
  start createServer, and install SIGINT/SIGTERM graceful-shutdown handlers.
  dev.ts and apps/cli both route through it; dev.ts thereby gains the graceful
  shutdown it previously lacked.
- scripts/dev.ts: filter `turbo run dev` to web + server only. apps/cli was
  booting a redundant second host (24242 taken by server:dev → cli bumped to
  24243) that nothing connected to. Now one host, no stray port.
- apps/web: vite `server.open: true` — `bun run dev` opens the browser at the
  HMR URL (which proxies /ws to the host). The prod bin still opens the host URL.
- e2e (self-contained) is unchanged: still boots server/dev.ts on the pinned
  port with staticDir=dist, tears down after.

SPECs updated first (server + host): bootHost public surface, shared dep.

Verify: typecheck + lint + unit (new host/boot.test.ts: port modes, SPA
serving, stop() releases port) + e2e no-agent (new host.spec.ts: /health, SPA
root, SPA fallback) + turbo dry-run (cli excluded) + CLI-bin smoke (free-pick,
--no-open, serves dist, clean shutdown releases port).

* dev: scope browser-open to the full `bun run dev` launcher

Gate vite's `server.open` on THINKRAIL_PI_DEV_OPEN, which scripts/dev.ts sets
(alongside THINKRAIL_PI_PORT, via the same turbo THINKRAIL_PI_* passthrough).
A bare `bun run dev:web` doesn't go through the launcher, so it no longer opens
the browser. Vite still opens its own actual URL, so it stays correct when the
vite port drifts for a second concurrent dev session.
2026-07-01 12:17:12 +00:00
Rinat S c364703557 host: auto-pick a free port for dev + thinkrail-pi (#19)
Bun.serve does not report EADDRINUSE for a busy localhost port (it shares
it via SO_REUSEPORT), so a second host silently co-bound 24242 and the OS
load-balanced requests across the stale and new backends. The apps/cli
EADDRINUSE->port:0 fallback never fired, and vite's hardcoded proxy target
pointed a second dev UI at the wrong host.

- packages/shared/freePort: findFreePort()/isPortFree() probe occupancy via
  a TCP connect (refused = free) and scan upward from the preferred port,
  falling back to an OS-assigned port. Unit-tested.
- thinkrail-pi (apps/cli): resolve a free port before binding.
- bun run dev: scripts/dev.ts launcher picks a free host port, sets
  THINKRAIL_PI_PORT, then runs turbo; vite's proxy target reads the same var.
- packages/server dev entry: auto-pick when THINKRAIL_PI_PORT is unset;
  an explicit value (e2e's 24252, the launcher's pre-picked port) stays strict.

A second `bun run dev` now lands on its own port with its UI wired to its
own host, instead of colliding with one already running.
2026-06-30 16:24:39 +02:00