Skip to content

fix(flows): route Copilot reasoning to Agentic task insights (B4)#4662

Merged
graycyrus merged 2 commits into
tinyhumansai:mainfrom
graycyrus:feat/flows-copilot-reasoning-insights
Jul 7, 2026
Merged

fix(flows): route Copilot reasoning to Agentic task insights (B4)#4662
graycyrus merged 2 commits into
tinyhumansai:mainfrom
graycyrus:feat/flows-copilot-reasoning-insights

Conversation

@graycyrus

@graycyrus graycyrus commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The bug

The workflow_builder agent narrates between tool calls ("Let me check…", "Now let me build…", "The mock doesn't match…"). ChatRuntimeProvider's onInterim persisted each narration as a permanent agent message, so it rendered twice: once live via the tool timeline / streaming preview, and again as a permanent chat bubble once persisted. Only the turn's terminal answer should ever become a bubble — the rest is reasoning that belongs in the Agentic task insights timeline.

The fix

  • ChatRuntimeProvider: tag interim addInferenceResponse messages with extraMetadata.isInterim: true (additive — the main chat is unaffected, it still renders every message).
  • useWorkflowBuilderChat: new displayMessages = messages filtered to drop agent messages tagged isInterim. messages itself is kept fully intact (full transcript) for callers that need it.
  • WorkflowCopilotPanel: renders displayMessages instead of messages for the bubble list (and the scroll-to-bottom effect); ToolTimelineBlock + the live streaming preview are unchanged.
  • A turn's terminal answer — including a feat(flows): builder clarifies ambiguous inputs instead of guessing (orchestrator posture) #4630-style clarifying question, appended via the assistantText fallback in send() with no isInterim tag — still renders as a bubble.

Verification

  • pnpm typecheck, eslint, format:check — clean on all changed files.
  • vitest run on the touched test files — 21/21 passing, including a new isInterim-bubble-suppression test in WorkflowCopilotPanel.test.tsx and the displayMessages filter test in useWorkflowBuilderChat.test.ts.

Note

Split from #4650 (previously combined with B11 in one PR since they touched the same files). This PR is B4 standalone; B11 (chat persistence) stacks on top of this one in a separate PR.

Summary by CodeRabbit

  • New Features

    • Chat transcripts now provide a separate, filtered set of messages for the workflow copilot panel, improving readability by excluding interim narration.
    • The workflow chat hook now exposes a dedicated displayMessages view for transcript rendering.
  • Bug Fixes

    • Interim agent updates are no longer rendered as conversation bubbles.
    • Transcript auto-scroll and empty-state behavior now align with the displayed transcript content.
    • Interim narration is now consistently tagged so it’s handled correctly across the UI and runtime.

Between-tool narration currently double-renders: once live via the tool
timeline, and again as a persisted chat bubble once ChatRuntimeProvider
appends it on chat_done. Tag that narration with extraMetadata.isInterim
when persisting it, and have useWorkflowBuilderChat expose a
displayMessages view (the full messages transcript with isInterim agent
messages filtered out) for WorkflowCopilotPanel to render instead of the
raw list. The main chat is unaffected — it still renders every message —
and a turn's terminal answer (including a tinyhumansai#4630-style clarifying
question, which is never tagged isInterim) still renders as a bubble.

Split from tinyhumansai#4650.
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a0535936-982a-42b9-9c1b-eeeda347b0a5

📥 Commits

Reviewing files that changed from the base of the PR and between 96d9980 and 108c37e.

📒 Files selected for processing (1)
  • app/src/providers/ChatRuntimeProvider.tsx

📝 Walkthrough

Walkthrough

Adds displayMessages to useWorkflowBuilderChat to filter interim agent narration via extraMetadata.isInterim. ChatRuntimeProvider tags interim responses with that flag, and WorkflowCopilotPanel now renders the filtered transcript and updates its tests accordingly.

Changes

Interim message filtering

Layer / File(s) Summary
Tag interim narration in ChatRuntimeProvider
app/src/providers/ChatRuntimeProvider.tsx
onInterim now dispatches addInferenceResponse with extraMetadata.isInterim: true and optional requestId.
Add displayMessages to useWorkflowBuilderChat
app/src/hooks/useWorkflowBuilderChat.ts, app/src/hooks/useWorkflowBuilderChat.test.ts
The hook returns displayMessages, computed by filtering out interim agent messages while keeping user and non-interim agent turns; tests verify the filtered output.
Render displayMessages in WorkflowCopilotPanel
app/src/components/flows/WorkflowCopilotPanel.tsx, app/src/components/flows/WorkflowCopilotPanel.test.tsx
The panel switches transcript rendering, scroll tracking, and empty-state logic to displayMessages; tests confirm interim bubbles are hidden and terminal messages render.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ChatRuntimeProvider
  participant useWorkflowBuilderChat
  participant WorkflowCopilotPanel

  ChatRuntimeProvider->>useWorkflowBuilderChat: addInferenceResponse with extraMetadata.isInterim
  useWorkflowBuilderChat->>useWorkflowBuilderChat: filter messages into displayMessages
  useWorkflowBuilderChat->>WorkflowCopilotPanel: return messages and displayMessages
  WorkflowCopilotPanel->>WorkflowCopilotPanel: render transcript from displayMessages
Loading

Possibly related PRs

Suggested labels: bug

Poem

A rabbit hops through chat so neat,
Interim whispers take a seat 🐇
Final bubbles stay in view,
Clear transcripts bloom anew,
Soft ears twitch at the tidy beat.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: it routes Copilot reasoning into agentic task insights by treating interim narration differently.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@graycyrus graycyrus marked this pull request as draft July 7, 2026 16:45
@coderabbitai coderabbitai Bot added the bug label Jul 7, 2026

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
app/src/providers/ChatRuntimeProvider.tsx (1)

878-905: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Correct and well-scoped; consider a debug log for the new tagging decision.

The isInterim tagging is correctly scoped to between-tool narration only — onSegment/chat_done paths (which represent the terminal answer) are left untouched, matching the intended filtering contract in useWorkflowBuilderChat.

Since this introduces a new interim-vs-terminal distinction that downstream code now depends on for correct rendering, consider adding a rtLog call here (thread/request/round correlation, mirroring the workflow proposal parsed logging pattern elsewhere in this handler) to aid future debugging if the double-render regression resurfaces.

As per coding guidelines: "On new or changed flows, add verbose debug logging with stable prefixes, correlation fields, and no secrets or full PII; incomplete changes are those lacking logging."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/providers/ChatRuntimeProvider.tsx` around lines 878 - 905, Add a
debug log in the `onInterim` handler around the new `isInterim` tagging
decision, using `rtLog` with a stable prefix and correlation fields for
thread/request/round so the interim-vs-terminal split is easy to trace later.
Keep the log scoped to `ChatRuntimeProvider`’s interim path only, mirroring the
existing “workflow proposal parsed” style, and avoid logging secrets or full
content while still showing enough context to debug replay or double-render
issues.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/src/providers/ChatRuntimeProvider.tsx`:
- Around line 878-905: Add a debug log in the `onInterim` handler around the new
`isInterim` tagging decision, using `rtLog` with a stable prefix and correlation
fields for thread/request/round so the interim-vs-terminal split is easy to
trace later. Keep the log scoped to `ChatRuntimeProvider`’s interim path only,
mirroring the existing “workflow proposal parsed” style, and avoid logging
secrets or full content while still showing enough context to debug replay or
double-render issues.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 91252d41-c051-4c91-8c60-979bfb8a8114

📥 Commits

Reviewing files that changed from the base of the PR and between 67a6558 and 96d9980.

📒 Files selected for processing (5)
  • app/src/components/flows/WorkflowCopilotPanel.test.tsx
  • app/src/components/flows/WorkflowCopilotPanel.tsx
  • app/src/hooks/useWorkflowBuilderChat.test.ts
  • app/src/hooks/useWorkflowBuilderChat.ts
  • app/src/providers/ChatRuntimeProvider.tsx

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 7, 2026
…@coderabbitai on ChatRuntimeProvider.tsx:878)

CodeRabbit nitpick: the new interim-vs-terminal split that displayMessages
now depends on for correct rendering had no debug logging. Add an rtLog
call mirroring the existing "workflow proposal parsed" style so the
double-render regression (if it resurfaces) is traceable via thread/
request/round correlation.
@graycyrus

Copy link
Copy Markdown
Contributor Author

@coderabbitai nitpick on ChatRuntimeProvider.tsx:878-905 (interim tagging debug logging) — fixed in 108c37e. Added an rtLog('interim_narration_tagged', { thread, request, round }) call right after the isInterim dispatch, mirroring the existing "workflow proposal parsed" logging style in this same handler, per the project's debug-logging convention (verbose diagnostics on new/changed flows).

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@graycyrus Thanks for confirming — glad the logging now matches the existing "workflow proposal parsed" convention in that handler. Appreciate the quick turnaround.

@graycyrus graycyrus marked this pull request as ready for review July 7, 2026 19:20
@graycyrus graycyrus merged commit 5d3a18e into tinyhumansai:main Jul 7, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Team Openhuman Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant