Repository navigation
feat: ls shows when each VM was last connected to and who made it - #260
Merged
Merged
Conversation
Abandoned VMs were hard to spot: `ls` said nothing about whether anyone still reached into a VM or whose it was. Now every VM listing has three more fields: - last_connected_at: when the VM last got a new ssh connection. `connect`, the ssh ProxyCommand every VM connection goes through, rewrites $BOXERY_CONF/last-connected/NAME with a Bash builtin (no fork, no Node), and ls reads its mtime. A file older than the VM (an earlier VM of that name) is ignored; rm removes it. Named for what it records: work running inside the VM doesn't count, so it isn't "last used". - created_at, created_by: written to vm_records by new/fork (schema v3, which adds the two columns, only those missing). The controller sends BOXERY_BY=user@machine on new/fork, with "via CLIENT" for an agent: the MCP client's name per session, or pi. Older hosts ignore the variable. Text ls gains LAST CONNECTED and CREATED BY columns, and so does vm_info list for agents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"LAST CONNECTED" made the table 5 columns wider than its values need. The
values ("just now", "7d ago") read as a sentence after CONNECTED, and the JSON
keeps the explicit last_connected_at.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rollback test played a broken release that bumps the store to schema 3, hardcoded. With 3 now the real version, its text edits no longer matched. It now reads SCHEMA_VERSION from the checkout and bumps it by one, so the next real schema change doesn't break it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
benvinegar
marked this pull request as ready for review
November 15, 2026 18:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
boxery lscouldn't tell a VM someone is using from one an agent made a week ago and forgot. Now every listing shows when each VM was last connected to and who made it, so leftovers are easy to spot.Before / after
Same steps on both sides:
web-devmade at the CLI and connected to just now,fix-flaky-testmade by Claude Code through MCP a week ago and not touched since,old-boxmade before this change.boxery lsBefore (
master):After:
fix-flaky-testnow reads as what it is: an agent's VM nobody has connected to in a week.old-boxshows-, because nothing was recorded before this change.boxery ls --jsonThree new fields on each VM. They don't exist on
master. Shown here withjq -c '.[] | {name, created_at, created_by, last_connected_at}':{"name":"fix-flaky-test","created_at":1794156458,"created_by":"ben@macbook via claude-code","last_connected_at":1794158258} {"name":"old-box","created_at":null,"created_by":null,"last_connected_at":null} {"name":"web-dev","created_at":1794764857,"created_by":"ben@macbook","last_connected_at":1794764858}The terminal header is a short
CONNECTEDand the JSON field is the explicitlast_connected_at. Agents get the same two columns invm_info list, plus the JSON fields in its structured output.Captured on the fake backend in a temp directory (
sshandncstubbed, no VMs). Connections were made by runningboxery-host connect, which is what ssh runs as its ProxyCommand.fix-flaky-test's timestamps were moved back a week andold-box's record was cleared, to show an old VM and one from before the change. The username and machine are replaced withben@macbook.How it works
last_connected_at:connect, the ssh ProxyCommand that every new connection to a VM goes through, rewrites$BOXERY_CONF/last-connected/NAMEwith a Bash builtin (no fork, no Node, so connections aren't slower), andlsreads the file's mtime. If the file can't be written, the connection still goes through. A file older than the VM (left by an earlier VM of the same name) is ignored, andrmdeletes it.created_at/created_by: written tovm_recordsbynewandfork. The controller sendsBOXERY_BY=user@machine, addingvia CLIENTwhen an agent makes the VM: the MCP client's name, per session, orpi. Control characters are stripped and the label is capped at 100 characters. It's a label for people to read, not an identity.What it doesn't measure
The name says "last connected", not "last used", on purpose. Only new ssh connections through boxery count:
run --bgjob, or apromptagent in tmux that nobody checks on.start,patch,snapshot,ls --refresh) don't count.So
just nowreliably means someone reached in, while7d agomeans probably abandoned, not certainly. That's fine for a list a person reads. Anything automatic (stop, prune) would also need a "busy" signal from inside the VM, which this PR leaves out.Compatibility
BOXERY_BY, and the new fields are missing from its output. The tables show-, andvm_info listleaves the columns out.-in CREATED BY. CONNECTED fills in after their next connection.Testing
npm run lint,npm run typechecknpm test: 541 pass, 0 fail. New tests cover the v2→v3 migration and running it twice, record round trips, thecreatorcleanup,lastConnected, which ignores a file from an earlier VM,BOXERY_BYreaching local and remote hosts only onnew/fork, the per-session client inrunTool,ago, and theformatVmscolumns.npm run test:shell: 1,233 pass, 0 fail, including under bash 3.2. These cover connect writing the file, connect still connecting when the directory is unwritable,rmdeleting the file, and thels --jsonfields from a realnew.test/shell/linux/host-upgrade.shstood in for a future release by bumping the schema to a hardcoded 3. It now reads the current version and adds one, so it keeps working after real schema bumps. The full shell suite, Linux-only tests included, passes under bash 3.2 in the CI container (bash:3.2).This PR description was generated by Claude Code using Claude Opus 5.5