Stabilize OpenCode pending approval/question compatibility

Open
#20 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript

Research direction

Start with src/server/routes/agent.test.ts, src/server/routes/approval.test.ts, and src/server/sse/broadcaster.test.ts, then inspect the adapter interfaces and route mocks around listPendingPermissions. Run the listed Vitest and TypeScript checks, and verify that both tree routes, approval/question replies, pending-state precedence, and SSE cleanup meet the acceptance criteria.

Written by the indexing model from the issue text.

Description

agent:worker area:ai area:backend priority:p1 status:ready type:task

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

  • Do not change final UI interaction design in this issue.
  • Do not push the broad dirty worktree into PR #13.
  • Do not mutate GitHub/Gira state from Agentree runtime.

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.

Dominant language
TypeScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from StatPan/agentree

All issues in StatPan/agentree

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.