Skip to content

fix(question): implement recovery for pending questions when app starts#15603

Open
aklajnert wants to merge 2 commits intoanomalyco:devfrom
aklajnert:fix_question_tool
Open

fix(question): implement recovery for pending questions when app starts#15603
aklajnert wants to merge 2 commits intoanomalyco:devfrom
aklajnert:fix_question_tool

Conversation

@aklajnert
Copy link

Issue for this PR

Closes #15172

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When OpenCode restarts, unanswered question tool calls (persisted as "running" or "aborted" parts in the DB) were lost from the in-memory pending state, making them invisible to the user.

Added a recover() function in Question that runs once on first list() call. It scans PartTable for question tool parts that are still running or were aborted mid-execution, reconstitutes them as pending question requests, and publishes the appropriate events so both TUI and GUI display them. When the user answers or dismisses a recovered question, the DB part is updated to reflect the outcome. The TUI bootstrap also calls question.list() to populate the store with any recovered questions on startup.

How did you verify your code works?

Manual testing with running bun run dev -s <my-sessionid> to check it loads the question correctly.
Added a couple of test checking that recover() function works correctly.

Screenshots / recordings

N/A — no UI changes, behavior change only (recovered questions now appear in existing UI)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant