Skip to content

Stabilize OpenCode pending approval/question compatibility #20

Description

@StatPan

Goal

Make pending permission/question discovery and reply handling reliable across /api/tree, /api/agent/tree, approval routes, SSE state, and OpenCode 1.3.

Derived from #14 Phase 6 dirty branch handoff.

Scope

  • Decide the canonical pending-state source: direct OpenCode REST, SSE broadcaster memory, or a documented merge of both.
  • Validate /permission, /question, and /question/:requestID/reply request/response shapes against OpenCode 1.3.
  • Update adapter interfaces and route tests together.
  • Preserve read-only session state except explicit approval/question replies.

Out of Scope

Acceptance Criteria

Functional:

  • GET /api/tree and GET /api/agent/tree expose pending permissions/questions consistently.
  • Pending status overrides are deterministic when permission and question are both present.
  • Question replies use the OpenCode-compatible payload shape.
  • Freeform and option answers have regression tests.
  • SSE cleanup after reply/reject is covered by tests or explicitly documented as eventual-consistency behavior.

Code/product quality:

  • Adapter boundaries are clear and route mocks match the updated interface.
  • Error handling is explicit for missing OpenCode endpoints or malformed pending payloads.
  • The route behavior remains read-only except explicit approval/question replies.

Verification

  • ./node_modules/.bin/vitest run src/server/routes/agent.test.ts src/server/routes/approval.test.ts src/server/sse/broadcaster.test.ts
  • ./node_modules/.bin/tsc -p tsconfig.json --noEmit
  • git diff --check
  • Optional/manual: run against a live OpenCode 1.3 server with one permission request and one question request.

Notes

Current dirty-branch evidence from #14: route tests fail because agent.ts now calls opencodeAdapter.listPendingPermissions, but the existing test mock does not provide that method. approval.test.ts and broadcaster.test.ts passed in the handoff run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:workerReady for an implementation worker.area:aiAI and agent workflow behavior.area:backendBackend, CLI, and core workflow implementation.priority:p1High priority work.status:readyReady to start.type:taskConcrete implementation task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions