Implement the following plan: Fix PR #607 Review Comments Context PR #607 (stabilize…
- User
Implement the following plan:
Fix PR #607 Review Comments
Context
PR #607 (stabilize Droid interactive E2E tests for CI) received 3 inline review comments from Copilot. All are valid improvements to robustness.
Fixes
1.
e2e/testutil/repo.go:167— Usejson.Marshalfor model ID stringProblem: Building JSON via string concatenation (
"\"" + value + "\"") can produce invalid JSON if the value contains special characters. Fix: Usejson.Marshal()to properly encode the string. Note: Copilot suggestedagents.DroidCustomModelBaseID()which doesn't exist — the actual exported function isagents.DefaultDroidModel()which returns"custom:<baseID>". That's the value we want in themodelsetting, so we marshal that.File:
e2e/testutil/repo.go:167go// Before: repoSettings["model"] = json.RawMessage(`"` + agents.DefaultDroidModel() + `"`) // After: modelJSON, err := json.Marshal(agents.DefaultDroidModel()) if err != nil { return fmt.Errorf("marshal model setting: %w", err) } repoSettings["model"] = json.RawMessage(modelJSON)2.
e2e/agents/tmux.go:162-169— Treat tmux errors as dead paneProblem:
IsPaneDead()returnsfalseon tmux errors (e.g., session not found), causingWaitForto poll the full timeout on a nonexistent pane. Fix: When tmux command fails, check if the error output indicates the session/pane no longer exists and treat that as dead.File:
e2e/agents/tmux.go:162-1693.
e2e/agents/droid.go:202— Make sleep context-awareProblem:
time.Sleep(2 * time.Second)ignores context cancellation/deadlines. Fix: Replace with timer + select onctx.Done().File:
e2e/agents/droid.go:200-203Verification
bashmise run fmt && mise run lint && mise run test:ci Assistant
★ Insight ─────────────────────────────────────These three fixes address common robustness patterns in E2E test infrastructure:- JSON injection safety — string concatenation for JSON is fragile;
json.Marshalhandles escaping - Error semantics — when checking external process state, command failure often means "gone", not "unknown"
- Context-aware delays —
time.Sleepis a concurrency anti-pattern in Go;selectonctx.Done()enables cancellation─────────────────────────────────────────────────
Let me read the three files to see the exact current code.
- JSON injection safety — string concatenation for JSON is fragile;
Assistant
Now I'll apply all three fixes.
Assistant
Now let me verify
ctxis available in the droid.go function scope and check if there are any unused import issues.Assistant
Good —
ctxis a parameter ofStartSession. Now let me check thattime.Sleepis no longer imported if unused, and verifytime.Afteris fine.Assistant
Good, no more
time.Sleepcalls.timeis still used viatime.Now,time.Second,time.Afterso no unused import issue. Now let's run the verification.Assistant
All passing. Here's a summary of the three fixes:
-
e2e/testutil/repo.go:167— Replaced string concatenation withjson.Marshal()for the model ID, preventing potential JSON injection from special characters. -
e2e/agents/tmux.go:162— ChangedIsPaneDead()to returntrueon tmux errors (e.g., session gone), soWaitForfails fast instead of polling until timeout. -
e2e/agents/droid.go:200— Replacedtime.Sleep(2s)withselectonctx.Done()+time.After, making the startup wait cancellable.
★ Insight ─────────────────────────────────────Thetime.Afterin aselectis fine here since it's a one-shot call (not in a loop). In a loop,time.Afterwould leak timers — you'd needtime.NewTimerwith explicitStop()/Reset()instead, per Go best practices.─────────────────────────────────────────────────-
- User
is IsPaneDead necessary / valuable?
Assistant
Let me check how
IsPaneDeadis used in the codebase.Assistant
Yes,
IsPaneDeadis valuable. It's the only early-exit mechanism inWaitForwhen the agent process crashes or exits unexpectedly.Here's the flow:
WaitForpolls in a loop waiting for a regex pattern to appear in the tmux pane output. WithoutIsPaneDead(line 124), if the Droid process crashes mid-test,WaitForwould keep polling the (now static) pane content for the full timeout (often 30s–2min) before failing. With it, the loop detects the process is gone and returns immediately with a clear "process exited" error.The
remain-on-exittmux option is key — it keeps the pane visible after the process exits (so you can still capture its output for diagnostics), but marks#{pane_dead}as1. Withoutremain-on-exit, tmux would destroy the pane entirely andCapture()would fail.So it's not just valuable — it's essential for fast failure in E2E tests. Removing it would make every agent-crash scenario wait the full timeout before reporting.
- User
commit and push
Assistant
I'm in plan mode so I can't make changes. Let me exit plan mode first so I can commit and push.
- User
[Request interrupted by user for tool use]