Skip to content

fix(tui): approval popup disappears when switching b/w agent sessions, subagent hangs forever - #13955

Open
rakshith1928 wants to merge 4 commits into
Kilo-Org:mainfrom
rakshith1928:permission-popup-lost
Open

rakshith1928 wants to merge 4 commits into
Kilo-Org:mainfrom
rakshith1928:permission-popup-lost

Conversation

@rakshith1928

Copy link
Copy Markdown
Contributor

Issue

No existing issue bug reported directly.

Context

In the TUI, when a subagent (Task tool) hit a permission prompt, opening the session list (ctrl+x → down), viewing the subagent, and coming back made the approval popup disappear. The subagent was then stuck forever waiting for an answer that could never be given.

The cause: switching sessions evicts the previous session (and its children) from the sync store, and the eviction deleted pending permission/question asks. These asks are one-shot SSE events — once dropped, nothing ever brought them back.

Implementation

  • evict() no longer deletes draft.permission / draft.question. The permission.replied / question.replied handlers already clean them up on the answer.
  • New syncPending() refetches the server's pending lists (permission.list / question.list — both endpoints already existed, nothing used them) whenever a session syncs or the app bootstraps. This also recovers asks missed during an SSE disconnect. It merges instead of overwriting, so asks arriving mid-fetch survive, and answered asks aren't resurrected by a stale list.

Also added /permission + /question default routes to the TUI test fixture and 4 regression tests.

Screenshots / Video

before after
subagentsnotworking.mp4
subagentsworking.mp4

How to Test

Manual/local verification

  • bun test test/cli/cmd/tui/ test/kilocode/ from packages/tui/ — 71 pass (agent-executed)
  • bun run script/check-opencode-annotations.ts --worktree — clean (agent-executed)
  • Typecheck: only pre-existing errors from missing optional deps in other packages, confirmed identical with changes stashed (agent-executed)

Reviewer test steps

  1. Add to your project's kilo.json so tool calls need approval:
{
  "permission": {
    "edit": "ask",
    "bash": "ask"
  }
}

(or use the pattern form: "edit": { "src/**": "ask", "*": "ask" })
2. Run kilo, ask it something that dispatches a subagent which edits a file (e.g. "use a Task subagent to edit src/foo.ts")
3. When the approval popup appears, press ctrl+x → down, open the subagent's session, then go back to the parent
4. The approval popup should still be there and answerable(which was not); the subagent should continue after answering
5. Before this fix: the popup is gone and the subagent spins forever

Blocked checks and substitute verification

Checklist

  • Issue linked above, or exception explained
  • Tests/verification described
  • Screenshots/video included for visual changes, or marked N/A
  • Changeset considered for user-facing changes
  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.

Get in Touch

Discord @TRAVIX26

Comment thread packages/tui/src/context/sync.tsx
@kilo-code-bot

kilo-code-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/tui/src/context/sync.tsx
  • packages/tui/test/kilocode/sync-pending-asks.test.tsx
Previous Review Summary (commit 0e66528)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 0e66528)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/tui/src/context/sync.tsx 228 Failed permission/question list responses are treated as empty, which can wipe in-memory asks
Files Reviewed (4 files)
  • .changeset/tui-permission-eviction.md - 0 issues
  • packages/tui/src/context/sync.tsx - 1 issue
  • packages/tui/test/fixture/tui-sdk.ts - 0 issues
  • packages/tui/test/kilocode/sync-pending-asks.test.tsx - 0 issues

Fix these issues in Kilo Cloud


Reviewed by grok-4.6 · Input: 96K · Output: 10.1K · Cached: 235.3K

Review guidance: REVIEW.md from base branch main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants