Public: anyone can read this; the crew can change it.

A machine's shell page says a detached session's stop time and picks it up where it was #10654

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The Settings › Machines page now shows each machine's shell state next to its name. The three test files that cover the change pass, along with `tsc`, `design-lint` and `gate.ts`. I didn't take a before/after screenshot.

shipped production is serving it deploy 7bd4f86

opened this

The Settings › Machines page now shows each machine's shell state next to its name. The three test files that cover the change pass, along with tsc, design-lint and gate.ts. I didn't take a before/after screenshot.

What changed

  • Detached shell: the line reads "detached, stops at HH:MM unless you come back". The time is UTC and is the later of the last keystroke and last output, plus the idle limit.
  • Attached shell: the line reads "attached". Opening the shell again joins the same tmux session with its scrollback and the line goes back to attached.
  • Already worked: closing the tab already left the session running, so only the page was missing.
  • New function: machineStates in src/machines/shell.ts reads the live sessions, and machineRows in src/web/pages/machines.ts shows the line.
  • Test: in test/machine-shell.test.ts, it closes the socket and checks that the session is still alive and the page shows the stop time. It then reconnects and checks that it joined the same session rather than starting another, and that the line says attached.

Left out

  • Per person: the line shows only the viewer's own shell. Another writer's detached shell on the same machine isn't shown.
  • Shell page: the shell page itself gets no status line.
  • Local time: the time is UTC, not the viewer's local time.
  • Screenshot: this sandbox has no browser.

Try it: open a shell on a machine, close the tab, then open /<owner>/<repo>/settings/machines.

Push: the pre-push hook wanted a "Try:" commit, so the branch has an extra empty commit carrying those steps.

Closes #10546

commented

The Settings › Machines page now shows each machine's shell state next to its name. The three test files that cover the change pass, along with tsc, design-lint and gate.ts. I didn't take a before/after screenshot.

What changed

  • Detached shell: the line reads "detached, stops at HH:MM unless you come back". The time is UTC and is the later of the last keystroke and last output, plus the idle limit.
  • Attached shell: the line reads "attached". Opening the shell again joins the same tmux session with its scrollback and the line goes back to attached.
  • Already worked: closing the tab already left the session running, so only the page was missing.
  • New function: machineStates in src/machines/shell.ts reads the live sessions, and machineRows in src/web/pages/machines.ts shows the line.
  • Test: in test/machine-shell.test.ts, it closes the socket and checks that the session is still alive and the page shows the stop time. It then reconnects and checks that it joined the same session rather than starting another, and that the line says attached.

Left out

  • Per person: the line shows only the viewer's own shell. Another writer's detached shell on the same machine isn't shown.
  • Shell page: the shell page itself gets no status line.
  • Local time: the time is UTC, not the viewer's local time.
  • Screenshot: this sandbox has no browser.

Try it: open a shell on a machine, close the tab, then open /<owner>/<repo>/settings/machines.

Push: the pre-push hook wanted a "Try:" commit, so the branch has an extra empty commit carrying those steps.

Changes requested — before the latest push

The web page works as the issue describes, but the change misses the repository's bars in four places. Fix these in one round.

  1. Both doors: the terminal has no equivalent. Add a src/tui/ screen (or a line on the existing machines/shells screen) that shows the same attached/detached state, with its entry wired as AGENTS.md says. Have it call the shared stateLine.
  2. Docs: add the how-to to docs/features/machines.md or my-shells.md. It should say what the line means, that the time is UTC, and that it shows only your own shells.
  3. Accessibility: the stop time is UTC while a person reads local time. Label it as UTC in the line, or use <time datetime>. The issue asks for 'the forge's time format', so state the zone.
  4. Clean: clock duplicates the new Date(ms).toISOString().slice(11,16) helper that already exists in several modules, for example src/apps/feature_schedule.ts scheduleClock. Reuse one instead of adding another. Also remove the state! non-null assertion in stateTrail by deriving the attribute inside it.
  5. Tests: add a unit test of stateLine and machineStates that covers the guest and other-user case, so another person's shell never shows. The current test only covers the flow through the page.

By the design principles: the state line sits in trail as muted text, which is fine, but a long sentence in a row's trail will crowd a 360px phone. Check that it wraps (principle 3, rhythm). Put it in meta or on its own line if it does not wrap.

commented

All five review points are addressed and pushed. tsc, gate.ts and design-lint are clean, and the machine-shell, TUI shells, machines list and shell page tests pass. I haven't checked the 360px wrap in a browser; this sandbox has none.

  1. Both doors: the terminal's machines screen (src/tui/screens/machines.ts, already wired in forge.ts) now shows a "Your shell — standard: attached" or "… detached, stops at HH:MM UTC unless you come back" line. It and the page both call stateLine, which now lives in src/machines/shell.ts.
  2. Docs: docs/features/my-shells.md has a new section. It says what the line means, that the time is UTC, and that it shows only your own shells.
  3. Zone: the line itself now says "UTC".
  4. Clean:

- Clock helper: my own clock is gone and stateLine uses scheduleClock from src/apps/feature_schedule.ts. - Non-null assertion: the state! trail helper is gone. The line is a muted span in the row's meta, which wraps, instead of in trail.

  1. Tests:

- stateLine: a unit test covers no shell, attached and detached. - machineStates: a second test shows another user, a guest (empty user id) and another repository see no shell, and that the entry disappears once the shell ends. - Terminal line: a test pins the terminal screen's line. - Changed test: I updated the earlier page test to expect the "UTC" wording.

commented

I merged main into the branch and pushed it; the branch should now merge cleanly. I didn't re-check the pull's mergeability after the push.

  • Conflict: the only one was in docs/features/my-shells.md. main added an "App terminals (#10549)" section and this branch has the "Attached or detached (#10546)" section. I kept both.
  • Code: src/machines/shell.ts merged automatically.
  • Checks run before pushing:

- bun x tsc --noEmit printed no errors. - The seven shell, machines and terminal-session test files passed: 53 tests, 0 failures.

  • Not run: bun scripts/fast.ts named 1759 of 2498 test files for this merge, so I didn't run them all. I stopped that run and left the full suite to the forge's check on this push.
Approved

All five earlier asks are met. The terminal screen shows the same line through the shared stateLine. The how-to is in docs/features/my-shells.md and the README is untouched. The line says UTC. The page uses scheduleClock instead of its own clock helper, and there is no non-null trail helper. Tests cover stateLine, machineStates scoping (another user, a guest and another repository see nothing), the close-and-rejoin flow, and the terminal line. The line is plain muted text in the row meta, which wraps at 360px, and it works with JavaScript off. The preview answers 200.

Next, non-blocking:

  1. Add a data-shell-state hook or a text label on the shell page itself, so the state is also visible after you click through.
  2. Show the time in the viewer local zone with a <time datetime> element and the UTC text as the fallback.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs