This repository was archived by the owner on Aug 17, 2026. It is now read-only.
Repository navigation
feat(grunt/tui): persist peer-id on session row — gruntcode -s alone recovers identity - #13
Merged
Merged
Conversation
… alone recovers identity Refs hivemind anomalyco#229 follow-up — Nik's observation: 'I still had to use gruntcode -s ses_... but we are here only thing is I guess I'd have to run the -s and -id right'. Today --peer-id is a flag you have to remember to type every restart. Without it the MCP child registers under `<cwd>#<pid>` which churns every restart and breaks wakeable continuity. ## The fix Persist peer_id on the session row. So: - First launch of a tab: `gruntcode --peer-id nik-coord-main --project ~/foo` (creates session row with peer_id='nik-coord-main') - Every subsequent restart: `gruntcode -s ses_xyz` (reads peer_id from row, sets env before worker spawn → MCP child auto-announces correctly) ## Resolution priority in thread.ts 1. Explicit --peer-id flag (always wins; lets a user re-launch with a NEW identity, also catches up backfilling onto pre-existing session rows) 2. peer_id stored on the session row (when --session <id> is used to resume) 3. unset → MCP child falls back to <cwd>#<pid> Backfill: when both --peer-id AND --session are given, the explicit flag is also UPDATEd onto the row so old sessions get caught up on next resume. ## Schema ALTER TABLE `session` ADD `peer_id` text (drizzle migration generated: migration/20260527000333_add_session_peer_id/migration.sql). Info schema gains optional `peerID` field; fromRow/toRow round-trip it; Session.createNext captures getPeerID() into result.peerID at creation. ## Verified bun typecheck clean. scripts/install-local.sh builds + signs + installs without errors. Bin reports v1.15.10-grunt.7-6-g1e35d2514-dirty-local.
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
terrxo
added a commit
that referenced
this pull request
May 28, 2026
… alone recovers identity (#13) Refs hivemind anomalyco#229 follow-up — Nik's observation: 'I still had to use gruntcode -s ses_... but we are here only thing is I guess I'd have to run the -s and -id right'. Today --peer-id is a flag you have to remember to type every restart. Without it the MCP child registers under `<cwd>#<pid>` which churns every restart and breaks wakeable continuity. ## The fix Persist peer_id on the session row. So: - First launch of a tab: `gruntcode --peer-id nik-coord-main --project ~/foo` (creates session row with peer_id='nik-coord-main') - Every subsequent restart: `gruntcode -s ses_xyz` (reads peer_id from row, sets env before worker spawn → MCP child auto-announces correctly) ## Resolution priority in thread.ts 1. Explicit --peer-id flag (always wins; lets a user re-launch with a NEW identity, also catches up backfilling onto pre-existing session rows) 2. peer_id stored on the session row (when --session <id> is used to resume) 3. unset → MCP child falls back to <cwd>#<pid> Backfill: when both --peer-id AND --session are given, the explicit flag is also UPDATEd onto the row so old sessions get caught up on next resume. ## Schema ALTER TABLE `session` ADD `peer_id` text (drizzle migration generated: migration/20260527000333_add_session_peer_id/migration.sql). Info schema gains optional `peerID` field; fromRow/toRow round-trip it; Session.createNext captures getPeerID() into result.peerID at creation. ## Verified bun typecheck clean. scripts/install-local.sh builds + signs + installs without errors. Bin reports v1.15.10-grunt.7-6-g1e35d2514-dirty-local.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Refs hivemind anomalyco#229 follow-up. Closes the 'I have to remember --peer-id every restart' ergonomics gap.
Behavior
gruntcode --peer-id nik-coord-main --project ~/foocreates session row with peer_id='nik-coord-main'gruntcode -s ses_xyzreads peer_id from the row, sets OPENCODE_PEER_ID env BEFORE worker spawn → MCP child auto-announces correctlyResolution priority
--peer-idflag (always wins)peer_idstored on the session row (when--session <id>is used)<cwd>#<pid>Backfill
When both
--peer-idAND--sessionare given, the explicit flag is alsoUPDATEd onto the row. Pre-existing sessions get caught up on next resume that includes the flag.Schema
ALTER TABLE session ADD peer_id text(drizzle migration:migration/20260527000333_add_session_peer_id/migration.sql). Info schema gains optionalpeerID; fromRow/toRow round-trip it;Session.createNextcapturesgetPeerID()into the new row.Files
packages/opencode/src/session/session.sql.tspeer_idcolumnpackages/opencode/migration/20260527000333_add_session_peer_id/packages/opencode/src/session/session.tsInfoschema +fromRow/toRow+createNextcapturepackages/opencode/src/cli/cmd/tui/thread.ts--sessionresume; backfill on--peer-id+--sessionVerified
bun typecheckclean.scripts/install-local.shbuilds + signs + installs. Bin reports v1.15.10-grunt.7-6-g1e35d2514-dirty-local.