Skip to content

H-6800: Fix concurrent Voice provenance rollback - #9615

Merged
kostandinang merged 2 commits into
mainfrom
kostandin/h-6800-fix-voice-provenance-rollback
Sep 9, 2026
Merged

H-6800: Fix concurrent Voice provenance rollback#9615
kostandinang merged 2 commits into
mainfrom
kostandin/h-6800-fix-voice-provenance-rollback

Conversation

@kostandinang

Copy link
Copy Markdown
Contributor

🌟 What is the purpose of this PR?

Prevent overlapping rejected Voice tool answers from restoring stale provenance onto an assistant message. Each failed submission now removes only its own temporary Voice tool-call ID from the latest metadata, preserving successful siblings and unrelated concurrent updates.

🔗 Related links

🚫 Blocked by

  • Nothing

🔍 What does this change?

  • Coordinate overlapping Voice tool submissions against one pre-submission provenance baseline.
  • Roll failed submissions back from current metadata instead of restoring a captured snapshot.
  • Preserve successful sibling IDs, pre-existing attribution, independent message-level Voice source, unrelated metadata and concurrent message parts.
  • Remove submission coordination state once the overlapping group settles.
  • Add regressions for both dual-rejection orders and concurrent metadata updates.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • modifies an npm-publishable library and I have added a changeset file

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

Direct spoken-user attribution after hydration remains explicitly deferred. This focused fix does not restore the obsolete inline brunch_ask widget provenance slot.

🐾 Next steps

After this fix and the remaining provenance omissions are explicitly accepted, #9512 can close as a donor.

🛡 What tests cover this?

  • Both completion orders when two overlapping Voice tool submissions reject.
  • One-success/one-failure sibling preservation.
  • Typed retry after rejection.
  • Pre-existing and independent Voice attribution.
  • Unrelated concurrent metadata and message-part preservation.
  • Complete ai-assistant-panel.test.tsx: 62 tests.

❓ How to test this?

  1. Run yarn workspace @hashintel/petrinaut test:unit --run src/ui/views/Editor/panels/ai-assistant-panel.test.tsx.
  2. Run yarn workspace @hashintel/petrinaut lint:tsc.
  3. Run yarn workspace @hashintel/petrinaut lint:eslint.

📹 Demo

Not applicable; this repairs internal provenance bookkeeping and is covered by deterministic regressions.

Made with Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hash Ready Ready Preview Sep 9, 2026 12:35pm UTC
petrinaut Ready Ready Preview Sep 9, 2026 12:35pm UTC
petrinaut-docs Ready Ready Preview Sep 9, 2026 12:35pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Sep 9, 2026 12:35pm UTC

Request Review

lunelson
lunelson previously approved these changes Sep 9, 2026

@lunelson lunelson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Two non-blocking observations:

  • Voice-ID normalization is repeated across markVoiceToolOrigin, submission-state initialization, and rollback; the added tests also repeat substantial fixture setup. A small shared helper/test harness could reduce drift and noise.
  • Low-probability residual risk: submission coordination is keyed by the stable setMessages identity plus message ID, rather than conversation ID. A pending submission across a conversation switch could therefore share coordination state if message IDs collide.

Neither blocks this focused fix.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copy link
Copy Markdown
Contributor Author

Addressed the duplication in bb46ded1ec: getVoiceToolCallIds now centralizes current/legacy provenance normalization for marking, submission-state initialization, and rollback. The repeated direct-message fixtures now use a small message factory/store.

I kept the coordination key unchanged. AiAssistantPanel keys ConversationAiAssistantPanel by aiAssistant.conversationId, so an actual conversation change remounts useChat and creates a distinct setMessages callback. A pending submission from the old mount therefore cannot share its WeakMap entry with the replacement conversation, even when message IDs collide.

@lunelson lunelson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after bb46ded1ec. The follow-up centralizes Voice-ID normalization and consolidates the repeated test setup without changing provenance behavior.

I am also withdrawing my earlier conversation-key concern: AiAssistantPanel is keyed by conversationId, so a conversation change remounts the hook tree and isolates the setMessages coordination key. No remaining findings.

@kostandinang
kostandinang added this pull request to the merge queue Sep 9, 2026
Merged via the queue into main with commit db4f62c Sep 9, 2026
61 checks passed
@kostandinang
kostandinang deleted the kostandin/h-6800-fix-voice-provenance-rollback branch September 9, 2026 15:46
@hash-release hash-release Bot mentioned this pull request Sep 9, 2026
lunelson pushed a commit that referenced this pull request Sep 9, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>

@lunelson lunelson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking concerns:

  • Add an integration regression covering a rejected Voice answer through the panel and confirming the transport does not serialize it as source: "voice".
  • Direct-user Voice provenance after reopen remains intentionally unresolved.
  • The already-large AI assistant panel now also owns concurrent provenance bookkeeping.
  • Local verification in this worktree was blocked by stale or missing workspace package resolution; the PR CI checks passed.

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

Labels

area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

2 participants