Skip to content

Conversation

@jdilla1277
Copy link
Contributor

@jdilla1277 jdilla1277 commented Aug 15, 2025

  • Add optional taskId field to StartNewTask IPC command
  • Update API handler to resume tasks when taskId is provided
  • Add handleStartTask method to ClineProvider for web UI integration
  • Ensure bridge service properly connects to resumed tasks
  • Fix message routing to correct task after resumption

Related GitHub Issue

Closes: #

Roo Code Task Context (Optional)

Description

Test Procedure

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Documentation Updates

Additional Notes

Get in Touch


Important

Implement task resumption from web UI by adding taskId to StartNewTask command and updating API and ClineProvider to handle resumption.

  • Behavior:
    • Add taskId field to StartNewTask command in ipc.ts for task resumption.
    • Update startNewTask() in api.ts to resume tasks if taskId is provided.
    • Implement handleStartTask() in ClineProvider.ts to handle task resumption from web UI.
    • Ensure bridge service connects to resumed tasks in handleStartTask().
  • Misc:
    • Fix message routing to correct task after resumption in ClineProvider.ts.

This description was created by Ellipsis for 3293d78. You can customize this summary. It will automatically update as commits are pushed.

- Add optional taskId field to StartNewTask IPC command
- Update API handler to resume tasks when taskId is provided
- Add handleStartTask method to ClineProvider for web UI integration
- Ensure bridge service properly connects to resumed tasks
- Fix message routing to correct task after resumption
@jdilla1277 jdilla1277 requested review from cte, jr and mrubens as code owners August 15, 2025 04:50
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. Enhancement New feature or request labels Aug 15, 2025
Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! I've reviewed the changes and found several issues that need attention before this can be merged.

text: z.string(),
images: z.array(z.string()).optional(),
newTab: z.boolean().optional(),
taskId: z.string().optional(), // Optional taskId for resuming existing tasks
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment is helpful, but consider adding JSDoc documentation for this new field to explain when and how it should be used. This would help other developers understand the resumption flow better.

// after the task is restored and ready
if (payload.text) {
// Give a small delay to ensure the task is fully restored
setTimeout(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this 200ms delay reliable across different system loads? Consider using a more deterministic approach, such as waiting for a specific state change event rather than using setTimeout. This would eliminate the race condition risk.

const resumedTask = this.getCurrentCline()
if (resumedTask) {
try {
const { ExtensionBridgeService } = await import("@roo-code/cloud")
Copy link
Contributor

Choose a reason for hiding this comment

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

This bridge service connection logic is duplicated from the remote control toggle method. Could we extract this into a shared helper method like connectBridgeServiceToTask(task: Task) to reduce duplication and ensure consistency?

return
}
} catch (error) {
this.log(`Failed to resume task ${payload.taskId}: ${error}. Creating new task instead.`)
Copy link
Contributor

Choose a reason for hiding this comment

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

When task resumption fails, we silently fall back to creating a new task. Should we notify the user that their requested task couldn't be resumed? This might be confusing if they expected to continue a specific task.

return taskId
}
// If task is not found in history, continue with creating a new task
this.log(`[API] Task ${taskId} not found in history, creating new task`)
Copy link
Contributor

Choose a reason for hiding this comment

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

The function returns the taskId on success, but what happens when resumption fails and we fall back to creating a new task? The caller won't know that resumption failed. Consider returning a different value or throwing an error to indicate resumption failed.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 16, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Aug 16, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 16, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

Thank you @jdilla1277!

*
* @param payload - The task payload containing text, images, and optional taskId for resumption
*/
public async handleStartTask(payload: { text: string; images?: string[]; taskId?: string }): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

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

I noticed that handleStartTask isn't being called from anywhere yet. The comment mentions it should be called by ExtensionBridgeService when receiving StartTask commands from the web UI.

Are you planning to add the ExtensionBridgeService integration in a follow-up commit, or is there perhaps a missing file in this PR? I'd be happy to help figure out where this should be wired up!

text: z.string(),
images: z.array(z.string()).optional(),
newTab: z.boolean().optional(),
taskId: z.string().optional(), // Optional taskId for resuming existing tasks
Copy link
Member

Choose a reason for hiding this comment

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

Would it be helpful to add JSDoc documentation for this new field? It could help future developers understand the resumption flow better:

// after the task is restored and ready
if (payload.text) {
// Give a small delay to ensure the task is fully restored
setTimeout(async () => {
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious about this 200ms delay - have you found this timing works reliably in your testing? I'm wondering if we might encounter race conditions on slower systems or under heavy load.

What do you think about using an event-based approach instead? For example, we could wait for a 'ready' signal from the webview, or queue messages until the task restoration is complete. This might be more reliable across different environments.

const resumedTask = this.getCurrentCline()
if (resumedTask) {
try {
const { ExtensionBridgeService } = await import("@roo-code/cloud")
Copy link
Member

Choose a reason for hiding this comment

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

I noticed this bridge service connection pattern is similar to what's in handleRemoteControlToggle (around line 2213). Would it make sense to extract this into a shared helper method?

Something like could reduce duplication and make it easier to maintain consistent behavior. What do you think?

return taskId
}
// If task is not found in history, continue with creating a new task
this.log(`[API] Task ${taskId} not found in history, creating new task`)
Copy link
Member

Choose a reason for hiding this comment

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

I see that when a taskId isn't found in history, we fall back to creating a new task. This is a nice graceful fallback!

One thought: since both paths return a taskId string, callers might not know whether resumption succeeded or a new task was created. Would it be useful to return something like so callers can handle each case if needed?

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Aug 18, 2025
@jdilla1277 jdilla1277 closed this Aug 19, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 19, 2025
@github-project-automation github-project-automation bot moved this from PR [Changes Requested] to Done in Roo Code Roadmap Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request PR - Changes Requested size:M This PR changes 30-99 lines, ignoring generated files.

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants