Skip to content

fix(ui): surface pending permission and question interruptions#465

Open
codenomadbot[bot] wants to merge 2 commits into
devfrom
codenomad/issue-448
Open

fix(ui): surface pending permission and question interruptions#465
codenomadbot[bot] wants to merge 2 commits into
devfrom
codenomad/issue-448

Conversation

@codenomadbot
Copy link
Copy Markdown
Contributor

@codenomadbot codenomadbot Bot commented May 16, 2026

Summary

  • Auto-open the permission/question center when the active workspace receives a new pending interruption so hidden earlier permissions are surfaced instead of leaving later questions stuck on “Waiting for earlier responses.”
  • Align permission actions with question ordering by disabling queued permission replies until that permission is the active interruption.
  • Deduplicate question message-store attachments when the same request moves from an unresolved/global entry to a resolved tool part, and keep active question state ordered by enqueue time.

Issue Details

Fixes #448. The reported deadlock can occur when an earlier permission is active but not visible inline yet, while a later question is visible and correctly blocked by the global interruption order. Since the center previously only opened on click, the user could see the later question waiting for an earlier response without an obvious path to answer the earlier permission.

Validation

  • npm run typecheck --workspace @codenomad/ui
  • node --import tsx --test packages/ui/src/stores/message-v2/instance-store.test.ts

--
Yours,
CodeNomadBot

Auto-open the permission/question center when an active instance receives pending interruptions so an earlier permission cannot remain hidden while a later question shows Waiting for earlier responses.

Keep question message-store attachments deduplicated when a request moves from a global fallback entry to a resolved tool part, and order active question state by enqueue time to match the permission flow. Queued permission actions are disabled to preserve the same active-interruption ordering as questions.

Validation: npm run typecheck --workspace @codenomad/ui; node --import tsx --test packages/ui/src/stores/message-v2/instance-store.test.ts
@shantur
Copy link
Copy Markdown
Collaborator

shantur commented May 16, 2026

@CodeNomadBot

Understand the issue that is being fixed here and then implement the change below

  • Auto-open the permission/question center when the active workspace receives a new pending interruption so hidden earlier permissions are surfaced instead of leaving later questions stuck on “Waiting for earlier responses.”

Don't auto open the permission/question center

@codenomadbot
Copy link
Copy Markdown
Contributor Author

codenomadbot Bot commented May 16, 2026

Implemented the requested change.

What changed:

  • Removed the effect that automatically opened the permission/question center when pending interruptions appeared on the active workspace.
  • Kept the pending-request banner and manual click-to-open behavior intact.
  • Kept the existing interruption queue ordering behavior unchanged.

Validation:

  • npm run typecheck --workspace @codenomad/ui

Commit:

  • 2aa1cf0 fix(ui): keep interruption center closed

Note:

  • Touched file packages/ui/src/components/instance/instance-shell2.tsx is already large at roughly 1,276 lines, above the project refactor signal threshold.

--
Yours,
CodeNomadBot

@shantur
Copy link
Copy Markdown
Collaborator

shantur commented May 16, 2026

@CodeNomadBot

Push the chants

Remove the automatic opening behavior for the permission/question center when pending interruptions arrive. Users can still see the pending-request banner and open the center manually, while the existing interruption ordering behavior remains intact.

Validated with npm run typecheck --workspace @codenomad/ui.
@codenomadbot
Copy link
Copy Markdown
Contributor Author

codenomadbot Bot commented May 16, 2026

Pushed the requested change to the PR branch.

What changed:

  • Removed the auto-open behavior for the permission/question center.
  • Preserved the pending-request banner and manual click-to-open behavior.

Validation:

  • npm run typecheck --workspace @codenomad/ui

Pushed commit:

  • de2caa8 fix(ui): keep interruption center closed

--
Yours,
CodeNomadBot

@github-actions
Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/25969805075

Artifacts expire in 7 days.
Artifacts:

  • pr-465-de2caa82917acbfedc6998f844589023de440387-tauri-macos
  • pr-465-de2caa82917acbfedc6998f844589023de440387-tauri-linux
  • pr-465-de2caa82917acbfedc6998f844589023de440387-tauri-windows
  • pr-465-de2caa82917acbfedc6998f844589023de440387-electron-macos
  • pr-465-de2caa82917acbfedc6998f844589023de440387-tauri-macos-arm64
  • pr-465-de2caa82917acbfedc6998f844589023de440387-electron-windows
  • pr-465-de2caa82917acbfedc6998f844589023de440387-electron-linux

@shantur
Copy link
Copy Markdown
Collaborator

shantur commented May 16, 2026

@CodeNomadBot

I want you to perform the gatekeeper checks for latest PR state

check for regressions
check for better possible implementations
Be the PR gatekeeper
Be ruthless about code quality

@codenomadbot
Copy link
Copy Markdown
Contributor Author

codenomadbot Bot commented May 16, 2026

Gatekeeper review completed for the latest PR state.

Findings:

  1. Blocking: duplicate question re-upserts can incorrectly change global interruption order.

packages/ui/src/stores/message-v2/instance-store.ts:986-1013

The PR now sorts question queue entries by enqueuedAt, but upsertQuestion replaces an existing question entry with the new entry as-is. Unlike permissions, questions do not merge with the existing entry or preserve the original enqueue time. If a question first arrives as an unresolved/global entry and later arrives/resolves with a newer enqueuedAt, it can move behind a later question and make the wrong question active.

Repro against the current branch:

const store = createInstanceMessageStore("instance-1")
store.upsertQuestion({ request: { id: "question-1", questions: [] } as any, enqueuedAt: 1000 })
store.upsertQuestion({ request: { id: "question-2", questions: [] } as any, enqueuedAt: 1500 })
store.upsertQuestion({
  request: { id: "question-1", questions: [] } as any,
  messageId: "message-1",
  partId: "part-1",
  enqueuedAt: 2000,
})

// Current result: question-2 becomes active.
// Expected result: question-1 should remain active because it was originally queued first.

I also verified this locally and got:

question-2
question-2:1500,question-1:2000

Recommended implementation:

  • Add a mergeQuestionEntry mirroring mergePermissionEntry.
  • Preserve enqueuedAt: Math.min(existing.enqueuedAt, entry.enqueuedAt) when the same request id is upserted again.
  • Keep the newer messageId / partId when resolving from global to a tool part.
  • Add a test covering question-1@1000, question-2@1500, then duplicate question-1@2000 and asserting question-1 remains active.
  1. Non-blocking quality note: packages/ui/src/components/instance/instance-shell2.tsx:343-350 now has pendingRequestCount only feeding hasPendingRequests after the auto-open behavior was removed. It can be inlined back to the previous simpler boolean memo. Not worth blocking by itself, but it is leftover complexity from the reverted auto-open path.

Validation run:

  • npm run typecheck --workspace @codenomad/ui
  • node --import tsx --test packages/ui/src/stores/message-v2/instance-store.test.ts

Both passed, but the current test suite does not cover the blocking duplicate-question ordering case above.

Gatekeeper verdict: do not merge until the question-entry merge/enqueue-time preservation is fixed and covered by a regression test.

--
Yours,
CodeNomadBot

@shantur
Copy link
Copy Markdown
Collaborator

shantur commented May 16, 2026

@CodeNomadBot

Fix the PR and update with recommendation

@codenomadbot
Copy link
Copy Markdown
Contributor Author

codenomadbot Bot commented May 16, 2026

I implemented the recommended fix locally, but I could not update the remote PR branch because git push was rejected by GitHub authentication:

remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/NeuralNomadsAI/CodeNomad.git/'

Local commit created:

  • e668687 fix(ui): preserve question queue order

What the commit changes:

  • Adds mergeQuestionEntry so duplicate question upserts preserve the original enqueuedAt while still keeping the newer resolved messageId / partId.
  • Adds the regression test from the recommendation: question-1@1000, question-2@1500, then duplicate question-1@2000, asserting question-1 remains first and active after resolving to the tool part.

Validation passed locally:

  • npm run typecheck --workspace @codenomad/ui
  • node --import tsx --test packages/ui/src/stores/message-v2/instance-store.test.ts

Status:

  • The PR branch is not updated yet because push authentication failed in this runtime.
  • The local worktree is clean and contains the committed fix.

Note:

  • Touched source file packages/ui/src/stores/message-v2/instance-store.ts is roughly 1,287 lines, above the project refactor signal threshold.

--
Yours,
CodeNomadBot

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.

[Bug]: questions do not open and garble leading to deadlock "Waiting for earlier responses"

1 participant