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

Sessions you can see, resume and stop; idle ones stop themselves; a nice environment from the first keystroke #10490

Parked opened this in answer to
Closed without merging

This pull covers the machine-shell part of #10457: a list of your sessions at /settings/terminals, idle stopping, detach on tab close, and a better shell environment. The rest is not done (listed below). bun x tsc --noEmit, bun scripts/gate.ts and the design lint are clean.

Notes

stopped parked by the crew deploy 307ac88

opened this

This pull covers the machine-shell part of #10457: a list of your sessions at /settings/terminals, idle stopping, detach on tab close, and a better shell environment. The rest is not done (listed below). bun x tsc --noEmit, bun scripts/gate.ts and the design lint are clean. I ran only the shell, terminal and settings-page test files. The 8 tests in test/terminals.test.ts and the shell tests I touched pass. I did not run the whole suite, and I did not run scripts/fast.ts file by file, because it named about 1,700 files for this diff.

What changed

  • Session list (src/web/pages/terminals.ts, linked from the user menu and the command palette):

- Each line shows the machine, the repository, when it started, its last input, and CPU seconds and memory for the whole process tree now, read from /proc (src/machines/usage.ts). - Each line is marked attached, or "detached, stops at HH:MM unless you come back". - Resume opens the shell page and reattaches to the live session. - Stop ends one session, and Stop all idle ends every session with no input or output for a minute. - Stops only touch the caller's own sessions. A cross-origin stop gets a 403.

  • Idle: a session stops when it has had no input and no output for FORGE_SESSION_IDLE_MIN minutes (default 30, 1–1440, anything else falls back to 30). Output counts as activity, so a build that prints is not idle.
  • Leaving: closing a tab only detaches, and the session stays in the list until it goes idle. The "connection dropped" message now says the session keeps running.
  • Environment (src/machines/environment.ts):

- A one-line greeting says what the session is, how to leave it and where to resume it. - The prompt shows user owner/repo@branch cwd. - History persists in ~/.forge_history, and there are a few defaults and aliases. - Your own .bashrc and .profile are never overwritten.

  • Wording change: the stopped end reason now reads "it was stopped" instead of "the forge stopped", because a person's Stop also uses it. I did not add a new end reason, since a database CHECK constraint limits the values.
  • Test change: the existing disconnect-wording assertion in test/machine-shell-page.test.ts changed because I changed the text.

Left out

  • Scrollback and working directory across an idle stop: the program is hung up, so Resume after an idle stop starts a fresh shell in the same home directory. Files and history survive, scrollback does not.
  • Repo checkout and tool install: the repository is not checked out in the session and no tools are installed. A cell has no route to clone it.
  • Dotfiles repo: applying dotfiles from a named repo is not built.
  • App tty sessions: they run over ssh and end with the connection. They are not in this list.
  • Silent long jobs: a long job that prints nothing counts as quiet.

To try: open a machine shell, close the tab, then open /settings/terminals. The session shows as detached with its stop time, and Resume reattaches.

Closes #10457

3 earlier comments
commented

This pull covers the machine-shell part of #10457: a list of your sessions at /settings/terminals, idle stopping, detach on tab close, and a better shell environment. The rest is not done (listed below). bun x tsc --noEmit, bun scripts/gate.ts and the design lint are clean. I ran only the shell, terminal and settings-page test files. The 8 tests in test/terminals.test.ts and the shell tests I touched pass. I did not run the whole suite, and I did not run scripts/fast.ts file by file, because it named about 1,700 files for this diff.

What changed

  • Session list (src/web/pages/terminals.ts, linked from the user menu and the command palette):

- Each line shows the machine, the repository, when it started, its last input, and CPU seconds and memory for the whole process tree now, read from /proc (src/machines/usage.ts). - Each line is marked attached, or "detached, stops at HH:MM unless you come back". - Resume opens the shell page and reattaches to the live session. - Stop ends one session, and Stop all idle ends every session with no input or output for a minute. - Stops only touch the caller's own sessions. A cross-origin stop gets a 403.

  • Idle: a session stops when it has had no input and no output for FORGE_SESSION_IDLE_MIN minutes (default 30, 1–1440, anything else falls back to 30). Output counts as activity, so a build that prints is not idle.
  • Leaving: closing a tab only detaches, and the session stays in the list until it goes idle. The "connection dropped" message now says the session keeps running.
  • Environment (src/machines/environment.ts):

- A one-line greeting says what the session is, how to leave it and where to resume it. - The prompt shows user owner/repo@branch cwd. - History persists in ~/.forge_history, and there are a few defaults and aliases. - Your own .bashrc and .profile are never overwritten.

  • Wording change: the stopped end reason now reads "it was stopped" instead of "the forge stopped", because a person's Stop also uses it. I did not add a new end reason, since a database CHECK constraint limits the values.
  • Test change: the existing disconnect-wording assertion in test/machine-shell-page.test.ts changed because I changed the text.

Left out

  • Scrollback and working directory across an idle stop: the program is hung up, so Resume after an idle stop starts a fresh shell in the same home directory. Files and history survive, scrollback does not.
  • Repo checkout and tool install: the repository is not checked out in the session and no tools are installed. A cell has no route to clone it.
  • Dotfiles repo: applying dotfiles from a named repo is not built.
  • App tty sessions: they run over ssh and end with the connection. They are not in this list.
  • Silent long jobs: a long job that prints nothing counts as quiet.

To try: open a machine shell, close the tab, then open /settings/terminals. The session shows as detached with its stop time, and Resume reattaches.

commented

I fixed 8 of the 10 failing tests. Two still fail: "child quota > room for small but not large…" and "an allowed module that has become reached leaves the list". Both fail the same way on the parent commit, so this pull doesn't cause them. The other test the check reported ("a real child forge > boots…") I didn't run; I didn't look into it.

Locally, the 70 tests in the affected files pass, as do tsc --noEmit, the design lint and scripts/gate.ts. I did not run the real-child-forge test or the full suite.

What changed

  • Phases: /settings/terminals now names its render phase in Server-Timing, so it no longer counts as unnamed.
  • Reserved label: "terminals" is added to the labels a feature may not take, in src/apps/feature.ts, since "Terminals" is now in the account menu.
  • Account-menu test: "Terminals" is added to the expected titles in test/now-links.test.ts.
  • Design audit: /settings/terminals has an entry in docs/design/audit.md.
  • Budgets: I raised three budgets for the new menu and settings-sidebar entry.

- The settings first-view budget goes from 137 to 138 words. - The pull-page byte budget goes from 31,250 to 31,620. - The pull-list byte budget goes from 25,230 to 25,430.

What to look at: the budget raises add to what the page may weigh, and the repo's usual practice is to lower budgets. If you'd rather not raise them, drop the "Terminals" row from the settings sidebar or the account menu.

To try it: open /settings/terminals on the preview after opening a machine shell, close the tab, and see it detached with its stop time.

commented

I fixed nothing this round: none of the 7 failures comes from this pull's code, and 3 of them fail the same way on the parent commit. I merged current main into the branch and pushed it. After the merge, tsc --noEmit is clean and the terminals, attention and pull-quiet tests pass.

The last round's fixes (named render phase, menu and audit entries, budgets, reserved label) are what cleared the other failures.

Still red, none caused by this pull

  • Fail on the parent commit and after the merge: "an allowed module that has become reached leaves the list" and "child quota > room for small but not large…". The unreached test wants src/kernel/why_now.ts off scripts/unreached-allow.json, though nothing under src/ imports it, and I didn't dig into why. The quota test reports 2048 MiB already held. This pull touches neither file.
  • Not reproduced here: "a real child forge > boots in its own cell…" needs cells, which this sandbox lacks. The pull changes nothing about child forges.
  • Pass locally, fail only in the check: the shell-sandbox tests (#560) and "the member actor… from a crew shell: every entry of the data directory but crew/ is denied". test/crew-sandbox.test.ts and test/outsiders-member.test.ts pass here, 31 of 31. Recent main commits (0dfe641b7, 636aa0355) changed the cell's home and temp-directory handling, so these look like environment or main drift in the check.

If the check stays red on these after a rerun, they need fixing on main. Say so and I'll look at the unreached and quota tests there.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs