spawn/fixtures/claude-code/stream-events.json
L 65a81edc57
fix: add unique spawn IDs to prevent history record corruption (#2235)
* fix: add unique spawn IDs to prevent history record corruption

History records were matched by heuristic ("most recent record for this
cloud without a connection"), which caused saveVmConnection and
saveLaunchCmd to overwrite the wrong record during concurrent or failed
spawns.

Fix: every SpawnRecord now has a unique `id` (UUID). All history
operations (saveVmConnection, saveLaunchCmd, removeRecord,
markRecordDeleted, mergeLastConnection) match by id when available,
falling back to the old heuristic for pre-migration records.

The orchestrator (TS path) now creates the history record AFTER server
creation succeeds, not before — so failed provisions don't leave orphan
entries.

Also adds "Remove from history" option to the spawn ls action picker,
restoring the ability to soft-delete entries without destroying the VM.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add 18 unit tests for spawn ID history behavior

Tests cover:
- generateSpawnId returns unique UUIDs
- saveSpawnRecord auto-generates id when not provided
- saveVmConnection matches by spawnId (not heuristic)
- saveVmConnection does not cross-contaminate concurrent spawns
- saveVmConnection falls back to heuristic without spawnId
- saveLaunchCmd matches by spawnId (not heuristic)
- saveLaunchCmd falls back without spawnId
- removeRecord matches by id, not by timestamp+agent+cloud
- removeRecord handles duplicate timestamps correctly
- removeRecord falls back for legacy records without id
- markRecordDeleted targets correct record by id
- mergeLastConnection uses spawn_id from last-connection.json
- mergeLastConnection falls back to heuristic without spawn_id

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: enable biome import sorting with grouped imports

Adds organizeImports to biome assist config with groups:
1. Type imports
2. Node built-ins
3. Third-party packages
4. @openrouter/* packages
5. Aliases

Auto-fixed import order and lint issues across all TypeScript files,
including .claude/skills/ and packages/cli/src/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-05 23:27:03 -08:00

131 lines
3.3 KiB
JSON

[
{
"type": "assistant",
"message": {
"id": "msg_01ABC",
"type": "message",
"role": "assistant",
"content": [{ "type": "text", "text": "I'll look at the issue and check the repository structure." }],
"model": "claude-sonnet-4-20250514",
"stop_reason": "end_turn"
}
},
{
"type": "assistant",
"message": {
"id": "msg_01DEF",
"type": "message",
"role": "assistant",
"content": [
{
"type": "tool_use",
"id": "toolu_01ABC",
"name": "Bash",
"input": { "command": "gh issue list --repo OpenRouterTeam/spawn --state open --limit 5" }
}
],
"model": "claude-sonnet-4-20250514",
"stop_reason": "tool_use"
}
},
{
"type": "user",
"message": {
"id": "msg_user_01",
"type": "message",
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_01ABC",
"content": "#1234 [Bug]: Fly.io deploy fails on arm64\n#1235 [CLI]: Add --json flag to list command",
"is_error": false
}
]
}
},
{
"type": "assistant",
"message": {
"id": "msg_01GHI",
"type": "message",
"role": "assistant",
"content": [{ "type": "tool_use", "id": "toolu_01DEF", "name": "Glob", "input": { "pattern": "**/*.ts" } }],
"model": "claude-sonnet-4-20250514",
"stop_reason": "tool_use"
}
},
{
"type": "user",
"message": {
"id": "msg_user_02",
"type": "message",
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_01DEF",
"content": "packages/cli/src/index.ts\npackages/cli/src/commands.ts\npackages/cli/src/manifest.ts",
"is_error": false
}
]
}
},
{
"type": "assistant",
"message": {
"id": "msg_01JKL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "tool_use",
"id": "toolu_01GHI",
"name": "Read",
"input": { "file_path": "/home/user/spawn/packages/cli/src/index.ts" }
}
],
"model": "claude-sonnet-4-20250514",
"stop_reason": "tool_use"
}
},
{
"type": "user",
"message": {
"id": "msg_user_03",
"type": "message",
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_01GHI",
"content": "Command execution failed: Permission denied",
"is_error": true
}
]
}
},
{
"type": "assistant",
"message": {
"id": "msg_01MNO",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "I've reviewed the open issues. Here's a summary:\n\n1. **#1234** - Fly.io deploy fails on arm64 architecture\n2. **#1235** - Request to add `--json` flag to the list command\n\nWould you like me to create a new issue or work on one of these?"
}
],
"model": "claude-sonnet-4-20250514",
"stop_reason": "end_turn"
}
},
{
"type": "result",
"subtype": "success",
"session_id": "abc123-def456-ghi789",
"is_error": false,
"result": "I've reviewed the open issues and provided a summary."
}
]