Skip to content

Conversation

@mafredri
Copy link
Member

@mafredri mafredri commented Nov 25, 2025

Summary

Fixes the issue where stopped or errored tasks were incorrectly showing in the "Waiting for input" tab on the TasksPage.

Root Cause

The frontend was filtering tasks by checking only if current_state.state === "idle". This caused tasks with status === "paused" or status === "error" to still appear in the "waiting for input" tab if they had an idle state.

Solution

Updated the filter to check both:

  • current_state.state === "idle"
  • task.status === "active"

This ensures only running tasks that are actually waiting for user input are shown in the "Waiting for input" tab.


🤖 This change was initially written by Claude Code using Coder Tasks, then reviewed and edited by a human 🏂

@mafredri mafredri marked this pull request as ready for review November 25, 2025 18:20
});
const idleTasks = tasksQuery.data?.filter(
(task) => task.current_state?.state === "idle",
(task) => task.current_state?.state === "idle" && task.status === "active",
Copy link
Member Author

@mafredri mafredri Nov 25, 2025

Choose a reason for hiding this comment

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

An alternative solution is handling this on the backend instead and unsetting current state. Thoughts?

This is probably good enough for now though.

Edit: On second thought, I'll give the BE approach a try.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I prefer the frontend approach here. The backend should just return the real data, if the task has a state, we should send it. Different parts of the UI (or other clients) might want to use that state differently, so it makes more sense for the FE to handle the filtering, rather than having the BE selectively return the field.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, after trying the alternative approach I agree, I'll revert to the original solution. 👍🏻

Copy link
Member Author

Choose a reason for hiding this comment

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

That said, I think the task state would need a different type or some change to better reflect the state. I don't think idle makes sense for a stopped task, even if that's the last app state the workspace had.

For now, though, the FE approach will suffice.

@mafredri mafredri force-pushed the fix-tasks-waiting-for-input branch from 9b24954 to b3b3929 Compare November 25, 2025 18:31
@mafredri mafredri marked this pull request as draft November 25, 2025 18:34
@mafredri mafredri force-pushed the fix-tasks-waiting-for-input branch from b3b3929 to 3c84902 Compare November 25, 2025 18:42
@mafredri mafredri force-pushed the fix-tasks-waiting-for-input branch 2 times, most recently from 47dd436 to 4bd500d Compare November 26, 2025 12:30
@mafredri mafredri force-pushed the fix-tasks-waiting-for-input branch from 4bd500d to e528432 Compare November 26, 2025 12:43
Copy link
Contributor

@ssncferreira ssncferreira left a comment

Choose a reason for hiding this comment

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

LGTM, just a small nit

spyOn(API, "getTasks").mockResolvedValue([
{
...firstTask,
id: "active-idle-task",
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, the preferred method for these GET endpoints mocks is something like:

parameters: {
		queries: [
			{
				key: ["tasks", { owner: MockUserOwner.username }],
				data: [
					{
						...firstTask,
						id: "active-idle-task",
						display_name: "Active Idle Task",
						status: "active",
						current_state: {
							...firstTask.current_state,
							state: "idle",
						},
					},
					...
				],
			},
			{
				key: getTemplatesQueryKey({ q: "has-ai-task:true" }),
				data: [MockTemplate],
			},
		],
	},

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe most of this file should be converted, doesn't feel appropriate to do it in this PR, or to introduce mixed usage. 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, I think we already have mixed usages in a lot of files, as this is something that I was already called out on in other PRs as well, and I only updated the stories I was changing 😞 I'm ok with addressing this in a separate PR 👍

Copy link
Contributor

@DanielleMaywood DanielleMaywood left a comment

Choose a reason for hiding this comment

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

We should have a follow-up PR to address the spyOn issue @ssncferreira raised

@mafredri mafredri marked this pull request as ready for review November 26, 2025 13:01
@mafredri
Copy link
Member Author

We should have a follow-up PR to address the spyOn issue @ssncferreira raised

@DanielleMaywood I can start a mux for this, but in principle, this PR didn't introduce the spyOn as it was there from before.

@mafredri mafredri enabled auto-merge (squash) November 26, 2025 13:09
Copy link
Contributor

@ssncferreira ssncferreira left a comment

Choose a reason for hiding this comment

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

LGTM 🎸

spyOn(API, "getTasks").mockResolvedValue([
{
...firstTask,
id: "active-idle-task",
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, I think we already have mixed usages in a lot of files, as this is something that I was already called out on in other PRs as well, and I only updated the stories I was changing 😞 I'm ok with addressing this in a separate PR 👍

@mafredri mafredri merged commit b7d8918 into main Nov 26, 2025
52 of 54 checks passed
@mafredri mafredri deleted the fix-tasks-waiting-for-input branch November 26, 2025 13:13
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2025
@mafredri mafredri added cherry-pick/v2.29 Needs to be cherry-picked to the 2.29 release branch and removed cherry-pick/v2.29 Needs to be cherry-picked to the 2.29 release branch labels Nov 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants