Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { SelectUser } from "@superset/db/schema";
import type {
SelectTask,
SelectTaskStatus,
SelectUser,
} from "@superset/db/schema";
import { ScrollArea } from "@superset/ui/scroll-area";
import { Separator } from "@superset/ui/separator";
import { eq, or } from "@tanstack/db";
Expand All @@ -8,10 +12,8 @@ import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { useMemo } from "react";
import { apiTrpcClient } from "renderer/lib/api-trpc-client";
import { useCollections } from "renderer/routes/_authenticated/providers/CollectionsProvider";
import type { TaskWithStatus } from "../components/TasksView/hooks/useTasksTable";
import { Route as TasksLayoutRoute } from "../layout";
import { ActivitySection } from "./components/ActivitySection";
import { CommentInput } from "./components/CommentInput";
import { EditableTitle } from "./components/EditableTitle";
import { PropertiesSidebar } from "./components/PropertiesSidebar";
import { TaskDetailHeader } from "./components/TaskDetailHeader";
Expand All @@ -24,6 +26,12 @@ export const Route = createFileRoute(
component: TaskDetailPage,
});

type TaskDetailRecord = SelectTask & {
status: SelectTaskStatus;
assignee: SelectUser | null;
creator: SelectUser | null;
};

function TaskDetailPage() {
const { taskId } = Route.useParams();
const { tab, assignee, search } = TasksLayoutRoute.useSearch();
Expand Down Expand Up @@ -54,16 +62,20 @@ function TaskDetailPage() {
.leftJoin({ assignee: collections.users }, ({ tasks, assignee }) =>
eq(tasks.assigneeId, assignee.id),
)
.select(({ tasks, status, assignee }) => ({
.leftJoin({ creator: collections.users }, ({ tasks, creator }) =>
eq(tasks.creatorId, creator.id),
)
.select(({ tasks, status, assignee, creator }) => ({
...tasks,
status,
assignee: assignee ?? null,
creator: creator ?? null,
}))
.where(({ tasks }) => or(eq(tasks.id, taskId), eq(tasks.slug, taskId))),
[collections, taskId],
);

const task: TaskWithStatus | null = useMemo(() => {
const task: TaskDetailRecord | null = useMemo(() => {
if (!taskData || taskData.length === 0) return null;
const task = taskData[0];
return {
Expand All @@ -72,6 +84,10 @@ function TaskDetailPage() {
typeof task.assignee?.id === "string"
? (task.assignee as SelectUser)
: null,
creator:
typeof task.creator?.id === "string"
? (task.creator as SelectUser)
: null,
};
}, [taskData]);
const taskFallbackQuery = useQuery({
Expand Down Expand Up @@ -107,6 +123,7 @@ function TaskDetailPage() {
const handleDelete = () => {
navigate({ to: "/tasks", search: backSearch });
};
const creatorName = task?.creator?.name?.trim() ? task.creator.name : null;
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.

⚠️ Potential issue | 🟡 Minor

Use the trimmed creator name value, not the raw one.

Line 126 validates trim() but still returns the untrimmed name. This can produce whitespace actor names and a blank avatar fallback initial downstream.

💡 Proposed fix
-	const creatorName = task?.creator?.name?.trim() ? task.creator.name : null;
+	const creatorName = task?.creator?.name?.trim() || null;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const creatorName = task?.creator?.name?.trim() ? task.creator.name : null;
const creatorName = task?.creator?.name?.trim() || null;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/`$taskId/page.tsx
at line 126, The variable creatorName currently checks
task?.creator?.name?.trim() but returns the original untrimmed string; change
the assignment for creatorName to use the trimmed value (e.g., compute const
trimmed = task?.creator?.name?.trim(); and set creatorName = trimmed ? trimmed :
null) so downstream avatar/initial logic receives the trimmed name; update the
expression that defines creatorName accordingly (reference: creatorName and
task?.creator?.name).


if (!task) {
if (isTaskLoading || isTaskSyncing) {
Expand Down Expand Up @@ -144,19 +161,19 @@ function TaskDetailPage() {
onSave={handleSaveDescription}
/>

<Separator className="my-8" />
{creatorName ? (
<>
<Separator className="my-8" />

<h2 className="text-lg font-semibold mb-4">Activity</h2>

<ActivitySection
createdAt={new Date(task.createdAt)}
creatorName={task.assignee?.name ?? "Someone"}
creatorAvatarUrl={task.assignee?.image}
/>
<h2 className="text-lg font-semibold mb-4">Activity</h2>

<div className="mt-6">
<CommentInput />
</div>
<ActivitySection
createdAt={new Date(task.createdAt)}
creatorName={creatorName}
creatorAvatarUrl={task.creator?.image}
/>
</>
) : null}
</div>
</ScrollArea>
</div>
Expand Down
Loading