Conversation
- Updated progress event handling in NetworkProvider and WorkflowProvider to use part indices for unique IDs instead of timestamps. - Enhanced AGENTS.md documentation with a sequence diagram for progress event handling. - Adjusted width of SelectTrigger in WorkflowHeader component for better UI consistency.
Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
Reviewer's GuideRefactors progress event handling in network and workflow providers to generate stable, deterministic IDs based on message part indices, documents the progress event flow with a new sequence diagram, and slightly adjusts a workflow header select width for UI consistency. Sequence diagram for progress event handling with stable IDssequenceDiagram
actor User as User
participant Assistant as Assistant_Message
participant NetworkProvider as NetworkProvider
participant WorkflowProvider as WorkflowProvider
participant ProgressPanel as ProgressPanel
User->>Assistant: Run network or workflow
Assistant->>NetworkProvider: Stream messages with parts
Assistant->>WorkflowProvider: Stream messages with parts
loop For_each_assistant_message_in_network
NetworkProvider->>NetworkProvider: Iterate parts with index partIndex
NetworkProvider->>NetworkProvider: Build id using messageId_partType_partIndex
NetworkProvider->>NetworkProvider: Append ProgressEvent to allProgressEvents
end
loop For_each_assistant_message_in_workflow
WorkflowProvider->>WorkflowProvider: Iterate parts with index partIndex
WorkflowProvider->>WorkflowProvider: Build id using messageId_partType_partIndex
WorkflowProvider->>WorkflowProvider: Append ProgressEvent to allProgressEvents
end
NetworkProvider->>ProgressPanel: Provide progressEvents for network view
WorkflowProvider->>ProgressPanel: Provide progressEvents for workflow view
ProgressPanel->>User: Render grouped progress items with stable IDs
Class diagram for progress event extraction with part index-based IDsclassDiagram
class Message {
+string id
+string role
+MessagePart[] parts
}
class MessagePart {
+string type
+AgentDataPart data
}
class AgentDataPart {
+string text
+string status
+string stage
+string stepId
+string message
+string agentId
+string workflowId
}
class ProgressEvent {
+string id
+string stage
+string status
+string message
+string agentId
+string workflowId
}
class NetworkProvider {
+ProgressEvent[] extractProgressEvents(messages)
}
class WorkflowProvider {
+ProgressEvent[] extractProgressEvents(messages)
}
class ProgressPanel {
+void render(progressEvents)
}
Message "1" --> "*" MessagePart : has
MessagePart "1" --> "0..1" AgentDataPart : data
NetworkProvider --> Message : reads
WorkflowProvider --> Message : reads
NetworkProvider --> ProgressEvent : creates_with_id_messageId_partType_partIndex
WorkflowProvider --> ProgressEvent : creates_with_id_messageId_partType_partIndex
ProgressPanel "1" --> "*" ProgressEvent : renders
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
🤖 Hi @ssdeanx, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
Summary by CodeRabbitRelease Notes
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughThese changes transition progress event ID generation from time-based (Date.now()) to index-based (partIndex) in network and workflow context providers, introduce documentation describing progress event handling flow, and adjust a UI component width. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (17)**/app/**📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Files:
**/components/**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Files:
**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)
Files:
app/**/*.{tsx,ts}📄 CodeRabbit inference engine (app/AGENTS.md)
Files:
app/workflows/components/**/*.{ts,tsx}📄 CodeRabbit inference engine (app/workflows/AGENTS.md)
Files:
app/workflows/**/*.{ts,tsx}📄 CodeRabbit inference engine (app/workflows/AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx,py,java,cs,rb,go,rs,cpp,c,h,hpp,swift,kotlin,php,scala,clj,groovy,lua,sh,bash}📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)
Files:
app/**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{css,tsx,ts}📄 CodeRabbit inference engine (AGENTS.md)
Files:
app/**/*.tsx📄 CodeRabbit inference engine (AGENTS.md)
Files:
app/networks/**/*.tsx📄 CodeRabbit inference engine (app/networks/AGENTS.md)
Files:
app/networks/providers/network-context.tsx📄 CodeRabbit inference engine (app/networks/AGENTS.md)
Files:
**/*.md📄 CodeRabbit inference engine (.github/instructions/markdown.instructions.md)
Files:
app/workflows/AGENTS.md📄 CodeRabbit inference engine (app/workflows/AGENTS.md)
Files:
app/workflows/providers/workflow-context.tsx📄 CodeRabbit inference engine (app/workflows/AGENTS.md)
Files:
🧬 Code graph analysis (1)app/workflows/components/workflow-header.tsx (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🤖 I'm sorry @ssdeanx, but I was unable to process your request. Please see the logs for more details. |
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Switching from
Date.now()topartIndexfor theidmeans multiple progress events derived from the samemessage.id+part.type+partIndex(e.g., text + later status) will now share the sameid; if consumers rely onidbeing unique (e.g., as React keys or for lookups), consider including an additional discriminator (like status or a sequence counter) or keeping a monotonic suffix to avoid collisions. - The progress event extraction and mapping logic in
NetworkProviderandWorkflowProvideris very similar; consider extracting shared helpers (e.g., for buildingProgressEventand derivingstage) to reduce duplication and keep behavior in sync across contexts.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Switching from `Date.now()` to `partIndex` for the `id` means multiple progress events derived from the same `message.id` + `part.type` + `partIndex` (e.g., text + later status) will now share the same `id`; if consumers rely on `id` being unique (e.g., as React keys or for lookups), consider including an additional discriminator (like status or a sequence counter) or keeping a monotonic suffix to avoid collisions.
- The progress event extraction and mapping logic in `NetworkProvider` and `WorkflowProvider` is very similar; consider extracting shared helpers (e.g., for building `ProgressEvent` and deriving `stage`) to reduce duplication and keep behavior in sync across contexts.
## Individual Comments
### Comment 1
<location> `app/networks/providers/network-context.tsx:305` </location>
<code_context>
if (eventData?.data?.text?.trim()) {
allProgressEvents.push({
- id: `${message.id}-${part.type}-${Date.now()}`,
+ id: `${message.id}-${part.type}-${partIndex}`,
stage: part.type.replace("data-tool-", ""),
status: "in-progress",
</code_context>
<issue_to_address>
**question (bug_risk):** Using partIndex instead of Date.now() might create duplicate IDs if messages are reprocessed or parts change order.
This makes IDs deterministic, but also means reprocessed messages or reordered/updated parts can emit progress events with the same ID. If these IDs are used as keys or for de-duplication, that can introduce subtle bugs. Consider adding another stable discriminator (e.g., a per-event sequence, `eventData.status`, or some unique field from the part) to keep IDs both deterministic and distinct across logically separate events.
</issue_to_address>
### Comment 2
<location> `app/workflows/providers/workflow-context.tsx:271` </location>
<code_context>
if (eventData?.data?.text?.trim()) {
allProgressEvents.push({
- id: `${message.id}-${part.type}-${Date.now()}`,
+ id: `${message.id}-${part.type}-${partIndex}`,
stage: part.type.replace("data-tool-", ""),
status: "in-progress",
</code_context>
<issue_to_address>
**question (bug_risk):** Deterministic IDs based on partIndex may collide across workflow progress updates.
Using `partIndex` instead of `Date.now()` means multiple progress updates for the same message/part/type can share an ID if this logic runs more than once or the data changes. If these IDs are used to track or update individual progress entries, collisions will make distinct updates indistinguishable. Consider including additional fields (e.g. `eventData.stepId`, `eventData.status`, or a sequence number) in the ID to keep it deterministic but unique per update.
</issue_to_address>
### Comment 3
<location> `app/workflows/AGENTS.md:52` </location>
<code_context>
+ Note over Panel: If suspendPayload exists<br/>& status="paused"
+ Panel->>Panel: Show SuspendDialog<br/>with approve/reject
+ Panel->>Context: User clicks Approve<br/>(calls approveWorkflow)
+ Context->>Context: Clear suspendPayload<br/>Resume workflow
+```
+
</code_context>
<issue_to_address>
**issue (typo):** Consider adding punctuation or a conjunction between "Clear suspendPayload" and "Resume workflow" for grammatical clarity.
Right now it reads like a run-on. Consider phrasing it as `Clear suspendPayload, then resume workflow` or `Clear suspendPayload and resume workflow` so the sequence is clearer.
```suggestion
Context->>Context: Clear suspendPayload,<br/>then resume workflow
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if (eventData?.data?.text?.trim()) { | ||
| allProgressEvents.push({ | ||
| id: `${message.id}-${part.type}-${Date.now()}`, | ||
| id: `${message.id}-${part.type}-${partIndex}`, |
There was a problem hiding this comment.
question (bug_risk): Using partIndex instead of Date.now() might create duplicate IDs if messages are reprocessed or parts change order.
This makes IDs deterministic, but also means reprocessed messages or reordered/updated parts can emit progress events with the same ID. If these IDs are used as keys or for de-duplication, that can introduce subtle bugs. Consider adding another stable discriminator (e.g., a per-event sequence, eventData.status, or some unique field from the part) to keep IDs both deterministic and distinct across logically separate events.
| if (eventData && eventData.text !== null && typeof eventData.text === "string" && eventData.text.trim()) { | ||
| allProgressEvents.push({ | ||
| id: `${message.id}-${part.type}-${Date.now()}`, | ||
| id: `${message.id}-${part.type}-${partIndex}`, |
There was a problem hiding this comment.
question (bug_risk): Deterministic IDs based on partIndex may collide across workflow progress updates.
Using partIndex instead of Date.now() means multiple progress updates for the same message/part/type can share an ID if this logic runs more than once or the data changes. If these IDs are used to track or update individual progress entries, collisions will make distinct updates indistinguishable. Consider including additional fields (e.g. eventData.stepId, eventData.status, or a sequence number) in the ID to keep it deterministic but unique per update.
| Note over Panel: If suspendPayload exists<br/>& status="paused" | ||
| Panel->>Panel: Show SuspendDialog<br/>with approve/reject | ||
| Panel->>Context: User clicks Approve<br/>(calls approveWorkflow) | ||
| Context->>Context: Clear suspendPayload<br/>Resume workflow |
There was a problem hiding this comment.
issue (typo): Consider adding punctuation or a conjunction between "Clear suspendPayload" and "Resume workflow" for grammatical clarity.
Right now it reads like a run-on. Consider phrasing it as Clear suspendPayload, then resume workflow or Clear suspendPayload and resume workflow so the sequence is clearer.
| Context->>Context: Clear suspendPayload<br/>Resume workflow | |
| Context->>Context: Clear suspendPayload,<br/>then resume workflow |
Greptile OverviewGreptile SummaryThis PR improves progress event handling by replacing timestamp-based IDs with deterministic part indices, enhancing documentation with a sequence diagram, and adjusting UI width for better consistency. Key Changes:
Benefits:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Assistant as Assistant<br/>(Message)
participant Context as Workflow/Network<br/>Context
participant Extractor as Progress Event<br/>Extractor
participant State as Context State
participant Panel as Progress<br/>Panel/Dialog
Assistant->>Context: Receive message with<br/>data-tool-* parts
Context->>Extractor: Extract progress events<br/>from message parts
Extractor->>Extractor: Parse stage, status,<br/>message, agentId/stepId
Note over Extractor: Generate unique ID using<br/>message.id + part.type + partIndex
Extractor->>State: Update progressEvents<br/>and suspendPayload
State->>Panel: Trigger re-render with<br/>new events
Panel->>Panel: Group by stage &<br/>render event items
Note over Panel: If suspendPayload exists<br/>& status="paused"
Panel->>Panel: Show SuspendDialog<br/>with approve/reject
Panel->>Context: User clicks Approve<br/>(calls approveWorkflow)
Context->>Context: Clear suspendPayload<br/>Resume workflow
|
There was a problem hiding this comment.
Pull request overview
This PR improves the stability and reliability of progress event handling in both workflow and network contexts by switching from timestamp-based IDs to index-based IDs. The change prevents duplicate or unstable IDs when messages are re-processed during re-renders. Additionally, it includes a minor UI adjustment and enhanced documentation with a sequence diagram.
Key Changes:
- Replaced
Date.now()withpartIndexin progress event ID generation for deterministic, stable IDs - Updated both WorkflowProvider and NetworkProvider to use consistent ID generation strategy
- Added a Mermaid sequence diagram documenting the progress event handling flow
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/workflows/providers/workflow-context.tsx | Updated progress event ID generation to use part indices instead of timestamps (2 occurrences) |
| app/networks/providers/network-context.tsx | Updated progress event ID generation to use part indices instead of timestamps (2 occurrences) |
| app/workflows/components/workflow-header.tsx | Adjusted SelectTrigger width from w-70 to w-72 for improved UI consistency |
| app/workflows/AGENTS.md | Added comprehensive sequence diagram documenting progress event handling flow |
The changes are well-structured and improve the codebase by addressing a potential issue where progress event IDs could be non-deterministic when effects re-run. The documentation update provides valuable context for understanding the progress event handling architecture.

Summary by Sourcery
Improve progress event handling for network and workflow contexts and align related UI and documentation.
New Features:
Enhancements: