feat: show question icon only for pending input (#782)

* fix: show question icon only for pending input

* fix: address pending input review feedback

* fix: reduce pending input sidebar complexity

* fix: address clarification review comments

* test: cover pending clarification hook
This commit is contained in:
José Almeida
2026-05-02 23:01:21 +01:00
committed by GitHub
parent eee547d891
commit 32f098a6fc
15 changed files with 327 additions and 22 deletions
@@ -19,6 +19,7 @@ import { useTasks } from "@/hooks/use-tasks";
import { useTaskActions, useArchiveAndSwitchTask } from "@/hooks/use-task-actions";
import { useTaskRemoval } from "@/hooks/use-task-removal";
import { getSessionInfoForTask } from "@/lib/utils/session-info";
import { hasPendingClarificationForSession } from "@/lib/utils/pending-clarification";
import type {
TaskState,
TaskSessionState,
@@ -85,6 +86,7 @@ function useSheetData(workspaceId: string | null, workflowId: string | null) {
const sessionsByTaskId = useAppStore((state) => state.taskSessionsByTask.itemsByTaskId);
const gitStatusByEnvId = useAppStore((state) => state.gitStatus.byEnvironmentId);
const envIdBySessionId = useAppStore((state) => state.environmentIdBySessionId);
const messagesBySession = useAppStore((state) => state.messages.bySession);
const { tasks } = useTasks(workflowId);
const steps = useAppStore((state) => state.kanban.steps);
const workspaces = useAppStore((state) => state.workspaces.items);
@@ -123,6 +125,10 @@ function useSheetData(workspaceId: string | null, workflowId: string | null) {
remoteExecutorType: task.primaryExecutorType ?? undefined,
remoteExecutorName: task.primaryExecutorName ?? undefined,
primarySessionId: task.primarySessionId ?? null,
hasPendingClarification: hasPendingClarificationForSession(
messagesBySession,
task.primarySessionId,
),
};
});
}, [
@@ -132,6 +138,7 @@ function useSheetData(workspaceId: string | null, workflowId: string | null) {
sessionsByTaskId,
gitStatusByEnvId,
envIdBySessionId,
messagesBySession,
]);
const dialogSteps = useMemo(
@@ -0,0 +1,48 @@
import { afterEach, describe, expect, it } from "vitest";
import { cleanup, render, screen } from "@testing-library/react";
import type { ComponentProps } from "react";
import { StateProvider } from "@/components/state-provider";
import { TaskItem } from "./task-item";
const REVIEW_ICON_TEST_ID = "task-state-review";
const WAITING_FOR_INPUT_ICON_TEST_ID = "task-state-waiting-for-input";
afterEach(() => cleanup());
function renderTaskItem(props: Partial<ComponentProps<typeof TaskItem>> = {}) {
return render(
<StateProvider>
<TaskItem title="Needs answer" state="REVIEW" {...props} />
</StateProvider>,
);
}
describe("TaskItem status icon", () => {
it("keeps the review check when the session is idle after a turn", () => {
renderTaskItem({ sessionState: "WAITING_FOR_INPUT" });
expect(screen.queryByTestId(REVIEW_ICON_TEST_ID)).not.toBeNull();
expect(screen.queryByTestId(WAITING_FOR_INPUT_ICON_TEST_ID)).toBeNull();
});
it("shows question icon when a clarification is pending", () => {
renderTaskItem({ sessionState: "WAITING_FOR_INPUT", hasPendingClarification: true });
expect(screen.queryByTestId(WAITING_FOR_INPUT_ICON_TEST_ID)).not.toBeNull();
expect(screen.queryByTestId(REVIEW_ICON_TEST_ID)).toBeNull();
});
it("shows question icon when task state is waiting for input", () => {
renderTaskItem({ state: "WAITING_FOR_INPUT", hasPendingClarification: false });
expect(screen.queryByTestId(WAITING_FOR_INPUT_ICON_TEST_ID)).not.toBeNull();
expect(screen.queryByTestId(REVIEW_ICON_TEST_ID)).toBeNull();
});
it("keeps the review check for completed review tasks", () => {
renderTaskItem({ sessionState: "COMPLETED" });
expect(screen.queryByTestId(REVIEW_ICON_TEST_ID)).not.toBeNull();
expect(screen.queryByTestId(WAITING_FOR_INPUT_ICON_TEST_ID)).toBeNull();
});
});
+20 -1
View File
@@ -7,6 +7,7 @@ import {
IconCircleDashed,
IconDots,
IconGitPullRequest,
IconMessageQuestion,
} from "@tabler/icons-react";
import { PRTaskIcon } from "@/components/github/pr-task-icon";
import { IssueTaskIcon } from "@/components/github/issue-task-icon";
@@ -14,6 +15,7 @@ import { useAppStore } from "@/components/state-provider";
import { cn } from "@/lib/utils";
import { DEBUG_UI } from "@/lib/config";
import type { TaskState, TaskSessionState } from "@/lib/types/http";
import { shouldUseQuestionTaskIcon } from "@/lib/ui/state-icons";
import type { SessionPollMode } from "@/lib/state/slices/session-runtime/types";
import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip";
import { RemoteCloudTooltip } from "./remote-cloud-tooltip";
@@ -41,6 +43,7 @@ type TaskItemProps = {
isDeleting?: boolean;
taskId?: string;
primarySessionId?: string | null;
hasPendingClarification?: boolean;
parentTaskTitle?: string;
isSubTask?: boolean;
/** Number of subtasks under this parent task. Only set for parent rows. */
@@ -89,11 +92,21 @@ function TaskStateIcon({
sessionState,
state,
isInProgress,
hasPendingClarification,
}: {
sessionState?: TaskSessionState;
state?: TaskState;
isInProgress: boolean;
hasPendingClarification?: boolean;
}) {
if (shouldUseQuestionTaskIcon(state, hasPendingClarification)) {
return (
<IconMessageQuestion
data-testid="task-state-waiting-for-input"
className="mt-[1px] h-3.5 w-3.5 shrink-0 text-yellow-500"
/>
);
}
if (isInProgress) {
return (
<IconCircleDashed
@@ -275,6 +288,7 @@ export const TaskItem = memo(function TaskItem({
isDeleting,
taskId,
primarySessionId,
hasPendingClarification,
isSubTask,
subtaskCount,
subtasksCollapsed,
@@ -313,7 +327,12 @@ export const TaskItem = memo(function TaskItem({
↳
</span>
)}
<TaskStateIcon sessionState={sessionState} state={state} isInProgress={isInProgress} />
<TaskStateIcon
sessionState={sessionState}
state={state}
isInProgress={isInProgress}
hasPendingClarification={hasPendingClarification}
/>
<TaskItemContent
title={title}
taskId={taskId}
@@ -1,7 +1,13 @@
"use client";
import { useCallback, useEffect, useMemo, useState, memo } from "react";
import type { TaskState, TaskSession, TaskSessionState, Repository } from "@/lib/types/http";
import type {
Message,
TaskState,
TaskSession,
TaskSessionState,
Repository,
} from "@/lib/types/http";
import type { TaskPR } from "@/lib/types/github";
import type { KanbanState } from "@/lib/state/slices";
import type { GitStatusEntry } from "@/lib/state/slices/session-runtime/types";
@@ -22,6 +28,7 @@ import { getWebSocketClient } from "@/lib/ws/connection";
import { useArchivedTaskState } from "./task-archived-context";
import { useRepositories } from "@/hooks/domains/workspace/use-repositories";
import { useWorkspacePRs } from "@/hooks/domains/github/use-task-pr";
import { hasPendingClarificationForSession } from "@/lib/utils/pending-clarification";
/**
* Stabilize a derived array of primary session IDs so the reference only
@@ -95,6 +102,7 @@ type SidebarCtx = {
envIdBySessionId: Record<string, string>;
repositorySlugById: Map<string, string | undefined>;
taskPRsByTaskId: Record<string, TaskPR[] | undefined>;
messagesBySession: Record<string, Message[]>;
titleById: Map<string, string>;
workflowNameById: Map<string, string>;
stepTitleById: Map<string, string>;
@@ -124,6 +132,10 @@ function toSidebarItem(
const repoSlug = task.repositoryId ? ctx.repositorySlugById.get(task.repositoryId) : undefined;
// Sidebar shows just one slot; pick the primary PR (first by created_at).
const pr = ctx.taskPRsByTaskId[task.id]?.[0];
const hasPendingClarificationRequest = hasPendingClarificationForSession(
ctx.messagesBySession,
task.primarySessionId,
);
const diffStats = resolveDiffStats(
sessionInfo.diffStats,
@@ -150,6 +162,7 @@ function toSidebarItem(
remoteExecutorType: task.primaryExecutorType ?? undefined,
remoteExecutorName: task.primaryExecutorName ?? undefined,
primarySessionId: task.primarySessionId ?? null,
hasPendingClarification: hasPendingClarificationRequest,
updatedAt: sessionInfo.updatedAt ?? task.updatedAt ?? task.createdAt,
createdAt: task.createdAt,
isArchived: false as boolean,
@@ -187,6 +200,7 @@ function buildArchivedItem(s: ReturnType<typeof useArchivedTaskState>): SidebarI
remoteExecutorType: undefined,
remoteExecutorName: undefined,
primarySessionId: null,
hasPendingClarification: false,
updatedAt: s.archivedTaskUpdatedAt,
createdAt: undefined,
isArchived: true,
@@ -210,6 +224,7 @@ function useSidebarData(workspaceId: string | null) {
const isMultiLoading = useAppStore((state) => state.kanbanMulti.isLoading);
const repositoriesByWorkspace = useAppStore((state) => state.repositories.itemsByWorkspaceId);
const taskPRsByTaskId = useAppStore((state) => state.taskPRs.byTaskId);
const messagesBySession = useAppStore((state) => state.messages.bySession);
const archivedState = useArchivedTaskState();
const selectedTaskId = useMemo(() => {
@@ -253,6 +268,7 @@ function useSidebarData(workspaceId: string | null) {
envIdBySessionId,
repositorySlugById,
taskPRsByTaskId,
messagesBySession,
titleById,
workflowNameById,
stepTitleById,
@@ -276,6 +292,7 @@ function useSidebarData(workspaceId: string | null) {
gitStatusByEnvId,
envIdBySessionId,
taskPRsByTaskId,
messagesBySession,
archivedState,
]);
@@ -45,6 +45,7 @@ export type TaskSwitcherItem = {
createdAt?: string;
isArchived?: boolean;
primarySessionId?: string | null;
hasPendingClarification?: boolean;
parentTaskTitle?: string;
parentTaskId?: string;
prInfo?: { number: number; state: string };
@@ -180,6 +181,7 @@ function TaskRow({
remoteExecutorName={task.remoteExecutorName}
taskId={task.id}
primarySessionId={task.primarySessionId ?? null}
hasPendingClarification={task.hasPendingClarification}
updatedAt={task.updatedAt}
repositories={task.repositories}
prInfo={task.prInfo}