← reports

#5004 · Injected question visibility after turn completion

BugPriority: MediumEffort: Mediumui · plugins · ask-user-question · provider-piIssue2026-10-06 · base df913a79dc687341d9bec06e483ff545376225de

Verdict: NOT REPRODUCED · Root-cause confidence: low · Reproduction label: no-repro

1. TL;DR

The report describes a multiple-choice question that never appeared in a visible Pi thread, although the server recorded a pending interaction. I tested the real bundled Ask User Question plugin through the authenticated injected-tool route, on a visible thread whose provider is Pi. In two clean trusted-main checkouts, the public interaction API retained the question after a completed turn and through the last millisecond before the configured 30-minute timeout. The timeout and non-blocking tool result are expected server behavior, not evidence that a form rendered. The missing desktop card remains unverified: this host lacks Chrome/Chromium, so Browser Automation could not open a browser, and no actual Pi CLI session or desktop AppImage was exercised.

This verdict does not invalidate the reported occurrence, close the issue, or claim an existing fix. No visual reproduction, screenshot, or root cause for the missing card is established.

2. Claims vs findings

Paraphrased claimFindingEvidence
The injected tool can return before the user answers.Verified at the server boundaryThe real plugin returns the asynchronous acknowledgement while its interaction remains pending.
A normally completed turn leaves the interaction pending.Verified in the synthetic Pi-thread scenarioThe injected-tool route followed by the real completion-event route retains the same question in the public list API.
An unanswered question times out after 30 minutes and disappears from the pending list.Verified with fake timeAt 1,799,999 ms the interaction remains pending; at 1,800,000 ms it is interrupted with reason timeout, and the pending list is empty.
The visible desktop thread never showed a question card.UnverifiedNo desktop or browser screenshot was captured. Browser Automation failed its missing-Chrome prerequisite. DOM tests pass but cannot prove pixel visibility or production WebSocket delivery.
The failure is specific to Pi.UnverifiedThe test uses a Pi thread and the real shared server dispatch, not a Pi CLI process.
A selected answer arrives in a later agent turn.Not exercised by the new reproThe new test covers the unanswered completion/timeout branch only. Existing plugin form tests cover submission, not a full Pi follow-up turn.

3. Environment

4. Minimal reproduction attempt

  1. Start from a new checkout of the trusted base. Install/build without changing dependencies:
    git clone https://github.com/get-bb/bb.git bb-5004-first
    cd bb-5004-first
    git checkout --detach df913a79dc687341d9bec06e483ff545376225de
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build
  2. Copy the complete investigator-authored test embedded below into apps/server/test/services/plugins/issue-5004-repro.test.ts, then run:
    pnpm exec turbo run test --force --filter=@bb/server -- test/services/plugins/issue-5004-repro.test.ts
  3. The test loads the actual bundled plugin, seeds a visible active Pi thread, sends a valid injected-tool call through /internal/session/tool-call, and verifies both the public list response and the server's interactions-changed notification. It sends a completion event seven seconds later, checks the same question remains available, then advances fake time to the expiry boundary.
  4. Expected and actual at this boundary match:
    Expected: question discoverable after turn completion; pending until 1,799,999 ms;
              interrupted with statusReason "timeout" at 1,800,000 ms.
    Actual:   all assertions passed in both clean checkouts.
    
    First run, 2026-10-06 06:18:50 UTC:
      Test Files  1 passed (1)
           Tests  1 passed (1)
    Second run, 2026-10-06 06:19:56 UTC:
      Test Files  1 passed (1)
           Tests  1 passed (1)

The test is a server-boundary reproduction attempt, not a failing regression for the reported visual defect. The complete test is included for repeatability:

Full reproduction test
import { eq } from "drizzle-orm";
import { events, pendingInteractions } from "@bb/db";
import { turnScope } from "@bb/domain";
import { groupHostDaemonEvents } from "@bb/host-daemon-contract";
import { describe, expect, it, vi } from "vitest";
import { PLUGIN_TOOL_CALL_AWAITING_USER_RESULT_TEXT } from "../../../src/services/plugins/plugin-tool-calls.js";
import { internalAuthHeaders } from "../../helpers/commands.js";
import {
  seedEnvironment,
  seedHostSession,
  seedProjectWithSource,
  seedThread,
  seedTurnStarted,
} from "../../helpers/seed.js";
import { withTestHarness } from "../../helpers/test-app.js";

describe("issue 5004 injected question lifecycle", () => {
  it("keeps the real plugin question discoverable after a Pi turn completes, until its 30-minute timeout", async () => {
    await withTestHarness(async (harness) => {
      const installed = await harness.pluginService.install(
        "builtin:ask-user-question",
        { kind: "root" },
      );
      expect(installed.status).toBe("running");
      const { host, session } = seedHostSession(harness.deps);
      const { project } = seedProjectWithSource(harness.deps, { hostId: host.id });
      const environment = seedEnvironment(harness.deps, {
        hostId: host.id,
        projectId: project.id,
      });
      const thread = seedThread(harness.deps, {
        projectId: project.id,
        environmentId: environment.id,
        providerId: "pi",
        status: "active",
        visibility: "visible",
      });
      const turnId = "turn-question-repro";
      const providerThreadId = "provider-question-repro";
      seedTurnStarted(harness.deps, { threadId: thread.id, turnId, providerThreadId });
      const notify = vi.spyOn(harness.hub, "notifyThread");
      vi.useFakeTimers();
      try {
        const startedAt = Date.now();
        const toolResponse = await harness.app.request("/internal/session/tool-call", {
          method: "POST",
          headers: internalAuthHeaders(harness),
          body: JSON.stringify({
            sessionId: session.id,
            threadId: thread.id,
            providerThreadId,
            turnId,
            callId: "call-question-repro",
            tool: "AskUserQuestion",
            arguments: {
              questions: [{
                header: "Choice",
                question: "Which sample should run?",
                options: [
                  { label: "First", description: "Run the first sample." },
                  { label: "Second", description: "Run the second sample." },
                ],
              }],
            },
          }),
        });
        expect(toolResponse.status).toBe(200);
        expect(await toolResponse.json()).toMatchObject({
          success: true,
          contentItems: [{ type: "inputText", text: PLUGIN_TOOL_CALL_AWAITING_USER_RESULT_TEXT }],
        });
        expect(notify).toHaveBeenCalledWith(thread.id, ["interactions-changed"], {
          hasPendingInteraction: true,
          projectId: project.id,
        });
        const list = async () => {
          const response = await harness.app.request(`/api/v1/threads/${thread.id}/interactions`);
          expect(response.status).toBe(200);
          return response.json();
        };
        const expectedQuestion = [{
          status: "pending",
          origin: { kind: "plugin", pluginId: "ask-user-question", rendererId: "ask-user-question" },
          payload: { kind: "plugin", data: { questions: [{ prompt: "Which sample should run?" }] } },
          expiresAt: startedAt + 30 * 60_000,
        }];
        expect(await list()).toMatchObject(expectedQuestion);
        await vi.advanceTimersByTimeAsync(7_000);
        const completed = await harness.app.request("/internal/session/events", {
          method: "POST",
          headers: internalAuthHeaders(harness),
          body: JSON.stringify({
            sessionId: session.id,
            eventGroups: groupHostDaemonEvents([{
              threadId: thread.id,
              event: {
                type: "turn/completed",
                threadId: thread.id,
                providerThreadId,
                scope: turnScope(turnId),
                status: "completed",
              },
            }]),
          }),
        });
        expect(completed.status).toBe(200);
        expect(await list()).toMatchObject(expectedQuestion);
        await vi.advanceTimersByTimeAsync(30 * 60_000 - 7_001);
        expect(await list()).toMatchObject(expectedQuestion);
        await vi.advanceTimersByTimeAsync(1);
        expect(await list()).toEqual([]);
        const stored = harness.db.select().from(pendingInteractions)
          .where(eq(pendingInteractions.threadId, thread.id)).all();
        expect(stored).toMatchObject([{ status: "interrupted", statusReason: "timeout" }]);
        const lifecycle = harness.db.select().from(events)
          .where(eq(events.threadId, thread.id)).all()
          .filter((event) => event.type === "system/interaction/lifecycle")
          .map((event) => JSON.parse(event.data));
        expect(lifecycle.map((event) => event.interaction.status)).toEqual(["pending", "interrupted"]);
      } finally {
        notify.mockRestore();
        vi.useRealTimers();
      }
    });
  });
});

Visual verification limitation: BB Browser Automation was invoked with the local headless backend on this thread's execution host. It failed before opening a session: Install Chrome/Chromium on this host or link its executable at the plugin data runtime/chrome path. No screenshot was produced; none is fabricated.

5. Root cause

The missing-card root cause is not established. The observed server sequence has an expected explanation, but that explanation does not account for a card being absent:

The matching production timestamps therefore support creation and timeout, not a Pi-specific renderer failure. A lost/refused list fetch, missed real-time notification, wrong active-thread state, footer geometry, or an AppImage-specific frontend state is still possible; none was reproduced here.

6. Proposed fix / next experiment

No production patch is justified yet. On a fresh actual Pi session with a working desktop/browser, call the injected tool while the thread is open and capture: the pending-list HTTP response immediately after creation and after turn completion; the delivered WebSocket interactions-changed notification; the selected query key; frontend plugin renderer state; and a full-window screenshot including the composer/footer. Compare that with a reload of the same still-pending interaction. These observations distinguish transport/cache loss from renderer mounting or layout. Only then add a failing regression at the responsible boundary.

7. Pull-request check

No linked open PR was found in the issue's connected/cross-reference metadata or an open-PR search for this issue number. No PR was opened: the reported defect was not reproduced on trusted main, the cause is unknown, and the new test passes without a production change. Those facts fail the simple-fix gate.

8. Related reports

The repository's existing Ask User Question issue classification uses UI/plugins area labels and the built-in plugin label. Related categories such as hidden-thread discoverability, native provider questions, and submission/persistence failures do not by themselves demonstrate this visible-thread missing-card defect. No duplicate or already-fixed conclusion is made.

9. Verification

The same investigator repeated the reproduction in a second clean trusted checkout at df913a79dc687341d9bec06e483ff545376225de, with newly installed frozen dependencies, a fresh build, and fresh migrated harness data. This is a repeat run, not independent-agent verification. The second commands used --force; no test task reused the first run's result. The test remained green and the report's wording was limited to the server-boundary result rather than claiming full visual reproduction.

CheckFirst checkoutSecond checkout
Frozen install and Turbo buildPassed; 64 build tasksPassed; 64 build tasks
New real injected-tool lifecycle reproduction1/1 passed1/1 passed, forced execution
Existing pending-interaction / plugin-tool dispatch / tool-call registry suites59/59 passedNot repeated; the new reproduction itself was repeated
Existing UI composer, plugin form host, prompt area, and realtime-cache suites182/182 passed182/182 passed, forced execution
Ask User Question plugin tests, including its real React form35/35 passed35/35 passed, forced execution
Actual Pi CLI + desktop pixel verificationNot run; browser prerequisite missingNot run; same prerequisite

Focused supporting commands:

pnpm exec turbo run test --filter=@bb/server -- test/services/pending-interactions.test.ts test/services/plugins/plugin-tool-calls.test.ts test/services/plugins/plugin-agent-tools.test.ts
pnpm exec turbo run test --force --filter=@bb/app -- src/components/plugin/PluginPendingInteractionComposer.test.tsx src/views/thread-detail/ThreadDetailPromptArea.test.tsx src/components/promptbox/FollowUpPromptBox.test.tsx src/hooks/realtime-cache-effects.test.ts
pnpm exec turbo run test --force --filter=bb-plugin-ask-user-question

10. Appendix / artifacts

The complete source test is embedded in section 4. Verbatim execution output follows, with checkout paths sanitized to $FIRST_CHECKOUT and $SECOND_CHECKOUT. Raw files remain in the investigator's local backup, not in this public repository. This report is self-contained; it does not depend on unpublished artifact links.

repro-first
@bb/server:test:  RUN  v4.1.1 $FIRST_CHECKOUT/apps/server
@bb/server:test: 
@bb/server:test: (node:9393) ExperimentalWarning: SQLite is an experimental feature and might change at any time
@bb/server:test: (Use `node --trace-warnings ...` to show where the warning was created)
@bb/server:test:  ✓ |@bb/server:isolated| test/services/plugins/issue-5004-repro.test.ts (1 test) 1550ms
@bb/server:test:      ✓ keeps the real plugin question discoverable after a Pi turn completes, until its 30-minute timeout  810ms
@bb/server:test: 
@bb/server:test:  Test Files  1 passed (1)
@bb/server:test:       Tests  1 passed (1)
@bb/server:test:    Start at  06:18:50
@bb/server:test:    Duration  9.45s (transform 5.77s, setup 1.65s, import 6.05s, tests 1.55s, environment 0ms)
@bb/server:test: 

 Tasks:    9 successful, 9 total
Cached:    0 cached, 9 total
  Time:    43.185s 

repro-second
@bb/server:test:  RUN  v4.1.1 $SECOND_CHECKOUT/apps/server
@bb/server:test: 
@bb/server:test: (node:10385) ExperimentalWarning: SQLite is an experimental feature and might change at any time
@bb/server:test: (Use `node --trace-warnings ...` to show where the warning was created)
@bb/server:test:  ✓ |@bb/server:isolated| test/services/plugins/issue-5004-repro.test.ts (1 test) 1276ms
@bb/server:test:      ✓ keeps the real plugin question discoverable after a Pi turn completes, until its 30-minute timeout  542ms
@bb/server:test: 
@bb/server:test:  Test Files  1 passed (1)
@bb/server:test:       Tests  1 passed (1)
@bb/server:test:    Start at  06:19:56
@bb/server:test:    Duration  8.77s (transform 5.60s, setup 1.81s, import 5.45s, tests 1.28s, environment 0ms)
@bb/server:test: 

 Tasks:    9 successful, 9 total
Cached:    0 cached, 9 total
  Time:    41.461s 

server-tests-first
@bb/server:test:  RUN  v4.1.1 $FIRST_CHECKOUT/apps/server
@bb/server:test: 
@bb/server:test: (node:7579) ExperimentalWarning: SQLite is an experimental feature and might change at any time
@bb/server:test: (Use `node --trace-warnings ...` to show where the warning was created)
@bb/server:test: (node:7578) ExperimentalWarning: SQLite is an experimental feature and might change at any time
@bb/server:test: (Use `node --trace-warnings ...` to show where the warning was created)
@bb/server:test: (node:7585) ExperimentalWarning: SQLite is an experimental feature and might change at any time
@bb/server:test: (Use `node --trace-warnings ...` to show where the warning was created)
@bb/server:test:  ✓ |@bb/server:isolated| test/services/plugins/plugin-tool-calls.test.ts (9 tests) 818ms
@bb/server:test:  ✓ |@bb/server:isolated| test/services/pending-interactions.test.ts (31 tests) 2440ms
@bb/server:test:  ✓ |@bb/server:isolated| test/services/plugins/plugin-agent-tools.test.ts (19 tests) 4178ms
@bb/server:test: 
@bb/server:test:  Test Files  3 passed (3)
@bb/server:test:       Tests  59 passed (59)
@bb/server:test:    Start at  06:15:19
@bb/server:test:    Duration  11.94s (transform 13.78s, setup 5.18s, import 17.26s, tests 7.44s, environment 0ms)
@bb/server:test: 

 Tasks:    9 successful, 9 total
Cached:    0 cached, 9 total
  Time:    45.756s 

app-tests-first
@bb/app:test:  RUN  v4.1.1 $FIRST_CHECKOUT/apps/app
@bb/app:test: 
@bb/app:test:  ✓ |@bb/app:isolated| src/hooks/realtime-cache-effects.test.ts (78 tests) 628ms
@bb/app:test:  ✓ |@bb/app:isolated| src/components/promptbox/FollowUpPromptBox.test.tsx (45 tests) 893ms
@bb/app:test:  ✓ |@bb/app:isolated| src/components/plugin/PluginPendingInteractionComposer.test.tsx (12 tests) 707ms
@bb/app:test:  ✓ |@bb/app:isolated| src/views/thread-detail/ThreadDetailPromptArea.test.tsx (47 tests) 2199ms
@bb/app:test: 
@bb/app:test:  Test Files  4 passed (4)
@bb/app:test:       Tests  182 passed (182)
@bb/app:test:    Start at  06:16:45
@bb/app:test:    Duration  8.62s (transform 11.43s, setup 782ms, import 16.48s, tests 4.43s, environment 3.40s)
@bb/app:test: 

 Tasks:    4 successful, 4 total
Cached:    0 cached, 4 total
  Time:    11.163s 

app-tests-second
@bb/app:test:  RUN  v4.1.1 $SECOND_CHECKOUT/apps/app
@bb/app:test: 
@bb/app:test:  ✓ |@bb/app:isolated| src/hooks/realtime-cache-effects.test.ts (78 tests) 625ms
@bb/app:test:  ✓ |@bb/app:isolated| src/components/promptbox/FollowUpPromptBox.test.tsx (45 tests) 750ms
@bb/app:test:  ✓ |@bb/app:isolated| src/components/plugin/PluginPendingInteractionComposer.test.tsx (12 tests) 504ms
@bb/app:test:  ✓ |@bb/app:isolated| src/views/thread-detail/ThreadDetailPromptArea.test.tsx (47 tests) 1720ms
@bb/app:test: 
@bb/app:test:  Test Files  4 passed (4)
@bb/app:test:       Tests  182 passed (182)
@bb/app:test:    Start at  06:20:08
@bb/app:test:    Duration  8.51s (transform 11.98s, setup 1.03s, import 16.98s, tests 3.60s, environment 4.31s)
@bb/app:test: 

 Tasks:    4 successful, 4 total
Cached:    0 cached, 4 total
  Time:    11.342s 

plugin-tests-first
bb-plugin-ask-user-question:test:  RUN  v4.1.1 $FIRST_CHECKOUT/plugins/ask-user-question
bb-plugin-ask-user-question:test: 
bb-plugin-ask-user-question:test:  ✓ src/contracts.test.ts (2 tests) 6ms
bb-plugin-ask-user-question:test:  ✓ src/translate.test.ts (11 tests) 12ms
bb-plugin-ask-user-question:test:  ✓ src/server-harness.test.ts (19 tests) 45ms
bb-plugin-ask-user-question:test:  ✓ app.test.tsx (3 tests) 85ms
bb-plugin-ask-user-question:test: 
bb-plugin-ask-user-question:test:  Test Files  4 passed (4)
bb-plugin-ask-user-question:test:       Tests  35 passed (35)
bb-plugin-ask-user-question:test:    Start at  06:18:34
bb-plugin-ask-user-question:test:    Duration  1.53s (transform 412ms, setup 0ms, import 1.14s, tests 148ms, environment 783ms)
bb-plugin-ask-user-question:test: 

 Tasks:    6 successful, 6 total
Cached:    4 cached, 6 total
  Time:    3.123s 

plugin-tests-second
bb-plugin-ask-user-question:test:  RUN  v4.1.1 $SECOND_CHECKOUT/plugins/ask-user-question
bb-plugin-ask-user-question:test: 
bb-plugin-ask-user-question:test:  ✓ src/translate.test.ts (11 tests) 9ms
bb-plugin-ask-user-question:test:  ✓ src/contracts.test.ts (2 tests) 7ms
bb-plugin-ask-user-question:test:  ✓ src/server-harness.test.ts (19 tests) 45ms
bb-plugin-ask-user-question:test:  ✓ app.test.tsx (3 tests) 81ms
bb-plugin-ask-user-question:test: 
bb-plugin-ask-user-question:test:  Test Files  4 passed (4)
bb-plugin-ask-user-question:test:       Tests  35 passed (35)
bb-plugin-ask-user-question:test:    Start at  06:20:20
bb-plugin-ask-user-question:test:    Duration  1.49s (transform 405ms, setup 0ms, import 965ms, tests 141ms, environment 774ms)
bb-plugin-ask-user-question:test: 

 Tasks:    6 successful, 6 total
Cached:    0 cached, 6 total
  Time:    3.896s 

Classification applied: Type Bug, Priority Medium, Effort Medium; ui, plugins, ask-user-question, provider-pi. A workaround exists and the occurrence/fix scope is not isolated; existing values were empty, so none was replaced.

Investigation and report generated by an agent on 2026-10-06.