Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Merge origin/main into feat/harness-grid

bitcoinbuilder27c4a8d412a9
diff --cc .gitignore
index 4eb1ef20f,583fe0103..33e9dcb29
--- a/.gitignore
+++ b/.gitignore
@@@ -19,7 -19,82 +19,85 @@@ provider/example-provider/sessions.jso
.env.*
!.env.example
+ # ---------------------------------------------------------------------------
+ # Local / personal — machine- or developer-specific, never pushed
+ # ---------------------------------------------------------------------------
+
+ # AI coding assistants (chat history, local rules, per-dev config).
+ # .claude/ contents are ignored by default; whitelist below anything the team
+ # should actually share (drop the leading "#" to start tracking it).
+ .claude/*
+ #!.claude/settings.json
+ #!.claude/commands/
+ #!.claude/agents/
+ #!.claude/skills/
+ .claude/settings.local.json
+ CLAUDE.local.md
+ AGENTS.local.md
+
+ .cursor/
+ .cursorignore
+ .windsurf/
+ .codeium/
+ .continue/
+ .cline/
+ .roo/
+ .kilocode/
+ .trae/
+ .junie/
+ .gemini/
+ .opencode/
+ .crush/
+ .amp/
+ .qodo/
+ .specstory/
+ .serena/
+ .aider*
+ .mcp.local.json
+
+ # Editors / IDEs — personal workspace state
+ .vscode/*
+ !.vscode/launch.json
+ !.vscode/tasks.json
+ !.vscode/extensions.json
+ *.code-workspace
+ .fleet/
+ .zed/
+ .nova/
+ *.sublime-project
+ *.sublime-workspace
+
+ # Xcode per-user state (macOS runner)
+ **/xcuserdata/
+ **/*.xcuserdatad
+ **/DerivedData/
+
+ # OS junk
+ ._*
+ .Spotlight-V100
+ .Trashes
+ Thumbs.db
+ Desktop.ini
+
+ # Secrets & signing material
+ *.pem
+ *.p8
+ *.p12
+ *.key
+ *.jks
+ *.keystore
+ key.properties
+ secrets/
.secrets
+.omc/
+CLAUDE.local.md
+.scratch/
+ service-account*.json
+
+ # Local scratch — notes, experiments, throwaway scripts
+ scratch/
+ tmp/
+ notes/
+ *.local
+ *.local.*
+ TODO.local.md
diff --cc backend/src/lib/adapterWs.ts
index c25f085f9,70b5b9041..f85029605
--- a/backend/src/lib/adapterWs.ts
+++ b/backend/src/lib/adapterWs.ts
@@@ -214,14 -239,26 +239,32 @@@ async function attachAdapter(ws: WebSoc
}
// Tell the adapter its machine's display name (it mirrors it locally for `harness status`); null when
// unnamed so a stale mirror clears. Renames while connected arrive the same way (machine_meta).
- send({ t: 'down', connId: '', frame: { type: 'machine_meta', payload: { name: currentName?.trim() || seededName } } })
+ // The account's private harness grid, carried on the frame the adapter already gets on connect.
+ // Minted and remembered by `routes/grid.ts`; read-only here. A user who has never signed in since
+ // the route shipped simply has none yet, and the daemon treats that as "no grid" rather than an
+ // error — the next `harness login` mints it.
+ const gridName = (await prisma.user.findUnique({ where: { id: userId }, select: { gridName: true } })
+ .catch(() => null))?.gridName ?? null
+ send({ t: 'down', connId: '', frame: { type: 'machine_meta', payload: { name: currentName?.trim() || seededName, gridName } } })
+ // Daily presence row for the machine, mirroring the user/device variants in webWs/deviceWs. The
+ // guard only advances on a SUCCESSFUL write, so a transient DB failure is retried on the next
+ // heartbeat instead of being silently skipped until the interval elapses again. Heartbeats also
+ // skip while a write is still in flight: `onHeartbeat` fires from two 15s sources (node role
+ // interval + app ping), and before the connect write lands `presenceWriteDue` would say "due" —
+ // without this a slow Mongo gets a second concurrent upsert precisely when it is already slow.
+ const lastMachinePresence: PresenceWriteState = { dayKey: null, wroteAt: 0 }
+ let machinePresenceInFlight = false
+ const touchMachinePresence = (kind: 'connect' | 'heartbeat' | 'close'): void => {
+ const now = new Date()
+ if (kind === 'heartbeat' && (machinePresenceInFlight || !presenceWriteDue(lastMachinePresence, now, MACHINE_PRESENCE_WRITE_MS))) return
+ machinePresenceInFlight = true
+ touchMachineOnlineDay(userId, machineId, now, { isNewConnection: kind === 'connect' })
+ .then(() => { lastMachinePresence.dayKey = utcDayKey(now); lastMachinePresence.wroteAt = now.getTime() })
+ .catch((err) => logger.warn('machine presence tracking failed', { machineId, kind, error: String(err) }))
+ .finally(() => { machinePresenceInFlight = false })
+ }
+
// The node role — down subscription, presence, `__clients` resync, node_status — is shared with
// every other backer of a machine and lives in nodeRole.ts. Only the delivery and teardown are
// adapter-specific, so only those are passed in.
diff --cc cli/src/lib/registry.spec.ts
index 7c4c5badb,d0f944ce7..d5aa78938
--- a/cli/src/lib/registry.spec.ts
+++ b/cli/src/lib/registry.spec.ts
@@@ -1036,52 -1036,15 +1036,52 @@@ describe('agent identity: the process o
registry.rename(second.agentId, 'My project')
const { registry: reloaded } = await loadRegistryModule()
reloaded.load()
- expect(reloaded.displayName(reloaded.byAgent(first.agentId)!)).toBe('agent-1')
+ expect(reloaded.displayName(reloaded.byAgent(first.agentId)!)).toBe('harness-1')
expect(reloaded.displayName(reloaded.byAgent(second.agentId)!)).toBe('My project')
const third = reloaded.openPendingAgent({ engine: 'codex', runtimes: [{ backend: 'tmux', paneId: '%9' }], cwd: '/tmp/demo' })!
- expect(reloaded.displayName(third)).toBe('agent-3')
- reloaded.rename(third.agentId, 'agent-10')
+ expect(reloaded.displayName(third)).toBe('harness-3')
+ reloaded.rename(third.agentId, 'agent-10') // the old prefix still counts, so a hand-typed agent-10 moves the next default past it
const fourth = reloaded.openPendingAgent({ engine: 'claude', runtimes: [{ backend: 'tmux', paneId: '%10' }], cwd: '/tmp/demo' })!
- expect(reloaded.displayName(fourth)).toBe('agent-11')
+ expect(reloaded.displayName(fourth)).toBe('harness-11')
})
+ it('opens a pane under the name its creator asked for, keeps it through binding and reload, and does not spend a number on it', async () => {
+ const { registry } = await loadRegistryModule()
+ registry.load()
+ const named = registry.openPendingAgent({ engine: 'opencode', runtimes: [{ backend: 'tmux', paneId: '%7' }], cwd: '/tmp/demo', defaultName: ' Local model ' })!
+ expect(named.defaultName).toBe('Local model')
+ expect(registry.displayName(named)).toBe('Local model')
+ // The engine reporting a session title does not retitle a pane that was named at creation.
+ const bound = registry.register({ engine: 'opencode', sessionId: 'session-named', tmuxPane: '%7', title: 'OC | Greeting' })!.entry
+ expect(registry.displayName(bound)).toBe('Local model')
+ // Blank means "number it", the same as absent — and the named agent took no number.
+ const numbered = registry.openPendingAgent({ engine: 'opencode', runtimes: [{ backend: 'tmux', paneId: '%8' }], cwd: '/tmp/demo', defaultName: ' ' })!
- expect(registry.displayName(numbered)).toBe('agent-1')
++ expect(registry.displayName(numbered)).toBe('harness-1')
+ const { registry: reloaded } = await loadRegistryModule()
+ reloaded.load()
+ expect(reloaded.displayName(reloaded.byAgent(named.agentId)!)).toBe('Local model')
- expect(reloaded.displayName(reloaded.byAgent(numbered.agentId)!)).toBe('agent-1')
++ expect(reloaded.displayName(reloaded.byAgent(numbered.agentId)!)).toBe('harness-1')
+ })
+
+ it('keeps the named agent a pane was opened as through binding and reload, and drops one that is not an identifier', async () => {
+ const { registry } = await loadRegistryModule()
+ registry.load()
+ const named = registry.openPendingAgent({ engine: 'opencode', runtimes: [{ backend: 'tmux', paneId: '%7' }], cwd: '/tmp/demo', agent: 'harness-compute', defaultName: 'Local model' })!
+ expect(named.agent).toBe('harness-compute')
+ // A hook-triggered bind carries it forward, like `dsh` and `codexHome`.
+ const bound = registry.register({ engine: 'opencode', sessionId: 'session-agent', tmuxPane: '%7', title: 'OC | Greeting' })!.entry
+ expect(bound.agent).toBe('harness-compute')
+ // Absent is a general session; a shape the engine could not look a file up by is not kept.
+ const plain = registry.openPendingAgent({ engine: 'opencode', runtimes: [{ backend: 'tmux', paneId: '%8' }], cwd: '/tmp/demo' })!
+ expect(plain.agent).toBeNull()
+ const odd = registry.openPendingAgent({ engine: 'opencode', runtimes: [{ backend: 'tmux', paneId: '%9' }], cwd: '/tmp/demo', agent: '../etc' })!
+ expect(odd.agent).toBeNull()
+ const { registry: reloaded } = await loadRegistryModule()
+ reloaded.load()
+ expect(reloaded.byAgent(named.agentId)!.agent).toBe('harness-compute')
+ expect(reloaded.byAgent(plain.agentId)!.agent).toBeNull()
+ })
+
it('persists a failed launch for reconnect while keeping its terminal route', async () => {
const { registry } = await loadRegistryModule()
registry.load()
diff --cc cli/src/lib/registry.ts
index ea1232106,a0c0220fd..12550be9c
--- a/cli/src/lib/registry.ts
+++ b/cli/src/lib/registry.ts
@@@ -164,8 -138,7 +164,8 @@@ export interface RegisteredSession
launcherId?: string
transcriptPath: string | null
projectDir: string
- /** Stable default for agents created by Harness — the next `agent-N`, or the name the creator asked
- /** Stable default for agents created by Harness; discovered agents keep their existing names. */
++ /** Stable default for agents created by Harness — the next `harness-N`, or the name the creator asked
+ * for (`agent_create`'s `name`). Discovered agents keep their existing names. */
defaultName?: string
cwd: string | null
/** Authoritative backend-neutral terminal placements for this one process-owned agent. */
@@@ -1045,15 -985,10 +1045,15 @@@ class Registry
primaryRuntimeKey?: string
cwd?: string | null
grid?: GridAssignment | null
- gridLaunch?: GridLaunchOverride | null
+ /** The grid launch this pane was opened with and what it decided — the pair `setGridLaunch` keeps. */
+ gridLaunchRecord?: GridLaunchRecord | null
codexHome?: string | null
dsh?: string | null
+ /** The engine's named agent the pane was opened as (`agent_create`'s `agent`), validated upstream. */
+ agent?: string | null
bypassPermission?: boolean
- /** The name the creator asked for, instead of the next `agent-N`. Blank means "number it". */
++ /** The name the creator asked for, instead of the next `harness-N`. Blank means "number it". */
+ defaultName?: string | null
}): RegisteredSession | null {
if (this.writeBlocked) return null
const runtimes = normalizedRuntimes(input.runtimes)
diff --cc desktop/lib/state/app_state.dart
index 3459f7872,a87aec1a4..9af58cbc6
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@@ -7,9 -7,7 +7,8 @@@ import 'package:dio/dio.dart'
import 'dart:ui' show Color;
import 'package:flutter/foundation.dart';
+import 'package:flutter/widgets.dart' show BuildContext;
import 'package:flutter_riverpod/flutter_riverpod.dart';
- import 'package:url_launcher/url_launcher.dart';
import '../analytics/analytics.dart';
import '../api/api_client.dart';