Skip to content

fix(bots): expire unanswered approvals and fit long values - #225

Merged
nixuuu merged 1 commit into
devfrom
fix/bot-approval-expiry
Nov 5, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/bot-approval-expiry

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 5, 2026

Copy link
Copy Markdown
Member

A bot's approval card no longer stays actionable after the bot has stopped waiting, and long values no longer break the card.

1. Expired approvals

The maintainer approved after the bot's tool call had timed out. Nothing ran, yet the card switched to "✓ Approved". Causes:

  • MCP cancellation was not passed on;
  • approvals outlived the turn that asked;
  • decisions did not check the request's lifecycle.

Fix:

  • Expiry: a request now expires durably when its tool call is cancelled or times out, or when its turn ends. The state is broadcast to the UI.
  • Late decisions: expiry and decisions take the same transaction lock. A late Approve, Discard or Edit returns FailedPrecondition: This request expired., and nothing is recorded or run.
  • Existing data: migration 0084_bot_approval_expiry repairs stale bot cards.
  • Threads: thread permissions and synchronous questions get the same protection. Asynchronous questions and offline waits stay supported and do not expire wrongly.

Timeouts found (unchanged):

  • synchronous ask_user in threads: 120 s;
  • Claude's in-process MCP server: 330 s;
  • Claude bots over HTTP MCP: no explicit Canopy timeout (the SDK default applies, overridable through MCP_TOOL_TIMEOUT).

2. Card layout with long values

The label column took most of the width, and parsing newlines split prompt paragraphs into separate fields. Now:

  • Values: structured values are kept as they are.
  • Long fields: stack under their label, full width.
  • Prompts: use the chat's markdown, collapsed with "Show all", with a copy button.
  • Refs and paths: wrap in a monospace font.
  • Expired cards: drop actions and edit fields, keep the footer height, and show a neutral status. The card stayed 529 px high on desktop when it expired.

Tests: expiry broadcasts, late decisions rejected, in-time approvals still working, offline waits, reconnects, restarts and parent-routed questions. check:tmp: 1431 passed, 0 failed.

Copy audit (§8)

  • A resolved "Needs approval" becomes "Approval request".
  • A stale "Approved" becomes "Expired. The bot no longer needs an answer."
  • A race error reads "This request expired. No answer was sent."
  • No status is shown by colour alone.

Checked in a browser at desktop, narrow and phone width, in light and dark.

Fixes: #97

Expire bot approvals and blocking thread interactions when their waiting call or turn ends. Serialize decisions with expiry, retain offline waits and preserve stored decisions on replay.

Render long approval values with shared markdown previews, disclosure and copy controls. Keep structured values intact instead of parsing prompt paragraphs as fields.

Fixes: #97
@nixuuu
nixuuu merged commit 7f2b5ff into dev Nov 5, 2026
9 checks passed
@nixuuu
nixuuu deleted the fix/bot-approval-expiry branch November 5, 2026 21:16
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.

1 participant