Skip to content

Commit 2aaf22d

Browse files
authored
feat(canvas): open New task in channels space from channels sidebar
The New task button in the channels sidebar now opens the new-task screen at /website/new instead of jumping to /code, keeping the channels chrome. The route renders the same shared TaskInput (with the same prefill) as the /code/ index, so the page stays single-source. openTaskInput gains a `space` option; SidebarNavSection passes space: "website" when it renders inside the channels space. Generated-By: PostHog Code Task-Id: 93824635-f0b3-4b9d-bf15-f31a4e505939
1 parent 27cec42 commit 2aaf22d

6 files changed

Lines changed: 66 additions & 2 deletions

File tree

packages/ui/src/features/sidebar/components/SidebarNavSection.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export function SidebarNavSection() {
5454
const inChannels = useRouterState({
5555
select: (s) => s.location.pathname.startsWith("/website"),
5656
});
57+
const goNewTask = () =>
58+
openTaskInput(inChannels ? { space: "website" } : undefined);
5759
const goHome = inChannels ? navigateToWebsiteHome : navigateToHome;
5860
const goSkills = inChannels ? navigateToWebsiteSkills : navigateToSkills;
5961
const goMcpServers = inChannels
@@ -100,7 +102,7 @@ export function SidebarNavSection() {
100102
return (
101103
<Flex direction="column" className="shrink-0 gap-px px-2 py-2">
102104
<Box mb="2">
103-
<NewTaskItem isActive={isHomeActive} onClick={openTaskInput} />
105+
<NewTaskItem isActive={isHomeActive} onClick={goNewTask} />
104106
</Box>
105107

106108
{homeTabEnabled && (

packages/ui/src/router/navigationBridge.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export function navigateToMcpServers(): void {
100100
// sidebar keeps the channels chrome instead of switching back to Code. The
101101
// SidebarNavSection picks the right variant based on the active space.
102102

103+
export function navigateToWebsiteNew(): void {
104+
void getRouterOrNull()?.navigate({ to: "/website/new" });
105+
}
106+
103107
export function navigateToWebsiteHome(): void {
104108
void getRouterOrNull()?.navigate({ to: "/website/home" });
105109
}

packages/ui/src/router/routeTree.gen.ts

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { TaskInput } from "@posthog/ui/features/task-detail/components/TaskInput";
2+
import { useAppView } from "@posthog/ui/router/useAppView";
3+
import { createFileRoute } from "@tanstack/react-router";
4+
5+
// Channels-space mirror of the /code/ new-task screen. Renders the same shared
6+
// TaskInput (reading the same prefill) so the page stays single-source; only
7+
// the route entry is duplicated so opening it from the channels sidebar keeps
8+
// the channels chrome. (Per-channel new tasks live at /website/$channelId/new.)
9+
export const Route = createFileRoute("/website/new")({
10+
component: WebsiteNewTaskRoute,
11+
});
12+
13+
function WebsiteNewTaskRoute() {
14+
const view = useAppView();
15+
16+
return (
17+
<TaskInput
18+
initialPrompt={view.initialPrompt}
19+
initialPromptKey={view.taskInputRequestId}
20+
initialCloudRepository={view.initialCloudRepository}
21+
initialModel={view.initialModel}
22+
initialMode={view.initialMode}
23+
reportAssociation={view.reportAssociation}
24+
/>
25+
);
26+
}

packages/ui/src/router/useAppView.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ function deriveFromMatches(matches: Match[]): AppView {
4949
}
5050
case "/code/tasks/pending/$key":
5151
return { type: "task-pending", pendingTaskKey: last.params.key };
52+
// Channels-space new-task screen — same task-input view (and prefill merge
53+
// below) as the /code/ index, so the New task item highlights identically.
54+
case "/website/new":
55+
return { type: "task-input" };
5256
case "/folders/$folderId":
5357
return { type: "folder-settings", folderId: last.params.folderId };
5458
case "/code/home":

packages/ui/src/router/useOpenTask.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export interface TaskInputNavigationOptions {
5555
initialModel?: string;
5656
initialMode?: string;
5757
reportAssociation?: { reportId: string; title: string };
58+
// Which space's new-task screen to open. Both render the same TaskInput; the
59+
// channels variant keeps the channels chrome instead of switching to Code.
60+
space?: "code" | "website";
5861
}
5962

6063
/**
@@ -90,7 +93,11 @@ export function openTaskInput(
9093
: undefined,
9194
},
9295
});
93-
nav.navigateToCode();
96+
if (options.space === "website") {
97+
nav.navigateToWebsiteNew();
98+
} else {
99+
nav.navigateToCode();
100+
}
94101
}
95102

96103
export function useOpenTaskInput(): typeof openTaskInput {

0 commit comments

Comments
 (0)