Skip to content
Closed
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
72 changes: 42 additions & 30 deletions apps/code/src/renderer/components/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useTasks } from "@features/tasks/hooks/useTasks";
import { TourOverlay } from "@features/tour/components/TourOverlay";
import { useTourStore } from "@features/tour/stores/tourStore";
import { createFirstTaskTour } from "@features/tour/tours/createFirstTaskTour";
import { WorkView } from "@features/work/components/WorkView";
import { useFeatureFlag } from "@hooks/useFeatureFlag";
import { useIntegrations } from "@hooks/useIntegrations";
import { Box, Flex } from "@radix-ui/themes";
Expand All @@ -45,6 +46,8 @@ export function MainLayout() {
taskInputReportAssociation,
taskInputCloudRepository,
} = useNavigationStore();
const mode = useNavigationStore((s) => s.mode);
const isCodeMode = mode === "code";
const {
isOpen: commandMenuOpen,
setOpen: setCommandMenuOpen,
Expand Down Expand Up @@ -105,46 +108,55 @@ export function MainLayout() {
<MainSidebar />

<Box flexGrow="1" overflow="hidden">
{view.type === "task-input" && (
<TaskInput
initialPrompt={view.initialPrompt}
initialPromptKey={view.taskInputRequestId}
initialCloudRepository={
view.initialCloudRepository ?? taskInputCloudRepository
}
reportAssociation={
view.reportAssociation ?? taskInputReportAssociation
}
/>
)}
{isCodeMode ? (
<>
{view.type === "task-input" && (
<TaskInput
initialPrompt={view.initialPrompt}
initialPromptKey={view.taskInputRequestId}
initialCloudRepository={
view.initialCloudRepository ?? taskInputCloudRepository
}
reportAssociation={
view.reportAssociation ?? taskInputReportAssociation
}
/>
)}

{view.type === "task-detail" && view.data && (
<TaskDetail key={view.data.id} task={view.data} />
)}
{view.type === "task-detail" && view.data && (
<TaskDetail key={view.data.id} task={view.data} />
)}

{view.type === "folder-settings" && <FolderSettingsView />}

{view.type === "folder-settings" && <FolderSettingsView />}
{view.type === "inbox" && <InboxView />}

{view.type === "inbox" && <InboxView />}
{view.type === "archived" && <ArchivedTasksView />}

{view.type === "archived" && <ArchivedTasksView />}
{view.type === "command-center" && <CommandCenterView />}

{view.type === "command-center" && <CommandCenterView />}
{view.type === "skills" && <SkillsView />}

{view.type === "skills" && <SkillsView />}
{view.type === "mcp-servers" && <McpServersView />}

{view.type === "mcp-servers" && <McpServersView />}
{view.type === "setup" && <SetupView />}
{view.type === "setup" && <SetupView />}
</>
) : (
<WorkView />
)}
</Box>
</Flex>

<SpaceSwitcher
tasks={visualTaskOrder}
activeTaskId={activeTaskId}
allTasks={tasks ?? []}
isOnNewTask={view.type === "task-input"}
onNavigateToTask={navigateToTask}
onNewTask={navigateToTaskInput}
/>
{isCodeMode && (
<SpaceSwitcher
tasks={visualTaskOrder}
activeTaskId={activeTaskId}
allTasks={tasks ?? []}
isOnNewTask={view.type === "task-input"}
onNavigateToTask={navigateToTask}
onNewTask={navigateToTaskInput}
/>
)}
<CommandMenu open={commandMenuOpen} onOpenChange={setCommandMenuOpen} />
<KeyboardShortcutsSheet
open={shortcutsSheetOpen}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface PromptInputProps {
onCancel?: () => void;
onAttachFiles?: (files: File[]) => void;
onEmptyChange?: (isEmpty: boolean) => void;
onTextChange?: (text: string) => void;
onFocus?: () => void;
onBlur?: () => void;
// manual submit override (for flows like new-task that submit outside the editor hook)
Expand Down Expand Up @@ -90,6 +91,7 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
onCancel,
onAttachFiles,
onEmptyChange,
onTextChange,
onFocus,
onBlur,
onSubmitClick,
Expand Down Expand Up @@ -138,6 +140,7 @@ export const PromptInput = forwardRef<EditorHandle, PromptInputProps>(
onBashCommand,
onBashModeChange,
onEmptyChange,
onTextChange,
onFocus,
onBlur,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface UseTiptapEditorOptions {
onBashCommand?: (command: string) => void;
onBashModeChange?: (isBashMode: boolean) => void;
onEmptyChange?: (isEmpty: boolean) => void;
onTextChange?: (text: string) => void;
onFocus?: () => void;
onBlur?: () => void;
}
Expand Down Expand Up @@ -198,6 +199,7 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
onBashCommand,
onBashModeChange,
onEmptyChange,
onTextChange,
onFocus,
onBlur,
} = options;
Expand All @@ -214,6 +216,7 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
onBashCommand,
onBashModeChange,
onEmptyChange,
onTextChange,
onFocus,
onBlur,
});
Expand All @@ -223,6 +226,7 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
onBashCommand,
onBashModeChange,
onEmptyChange,
onTextChange,
onFocus,
onBlur,
};
Expand Down Expand Up @@ -496,6 +500,7 @@ export function useTiptapEditor(options: UseTiptapEditorOptions) {
},
onUpdate: ({ editor: e }) => {
const text = e.getText();
callbackRefs.current.onTextChange?.(text);
const newBashMode = enableBashMode && text.trimStart().startsWith("!");

if (newBashMode !== prevBashModeRef.current) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Box, Flex } from "@radix-ui/themes";
import { type AppMode, useNavigationStore } from "@stores/navigationStore";

const MODES: { value: AppMode; label: string }[] = [
{ value: "code", label: "Code" },
{ value: "work", label: "Work" },
];

export function ModeSwitcher() {
const mode = useNavigationStore((s) => s.mode);
const setMode = useNavigationStore((s) => s.setMode);

return (
<Box p="2" className="shrink-0 border-(--gray-6) border-b">
<Flex
align="center"
gap="1"
className="rounded-(--radius-2) bg-(--gray-3) p-1"
>
{MODES.map((m) => {
const isActive = mode === m.value;
return (
<button
key={m.value}
type="button"
onClick={() => setMode(m.value)}
className={`flex-1 cursor-pointer rounded-(--radius-1) py-1 text-center font-medium text-[13px] transition-colors ${
isActive
? "bg-(--color-panel-solid) text-(--gray-12) shadow-sm"
: "text-(--gray-11) hover:text-(--gray-12)"
}`}
>
{m.label}
</button>
);
})}
</Flex>
</Box>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { ModelSelector } from "./ModelSelector";
import { PlanStatusBar } from "./PlanStatusBar";
import { ReasoningLevelSelector } from "./ReasoningLevelSelector";
import { RawLogsView } from "./raw-logs/RawLogsView";
import { TryInPostHogWorkBanner } from "./TryInPostHogWorkBanner";

interface SessionViewProps {
events: AcpMessage[];
Expand Down Expand Up @@ -250,9 +251,27 @@ export function SessionView({
);

const [isDraggingFile, setIsDraggingFile] = useState(false);
const [showPostHogWorkBanner, setShowPostHogWorkBanner] = useState(false);
const [postHogWorkBannerDismissed, setPostHogWorkBannerDismissed] =
useState(false);
const editorRef = useRef<PromptInputHandle>(null);
const dragCounterRef = useRef(0);

const handlePromptTextChange = useCallback(
(text: string) => {
if (postHogWorkBannerDismissed) return;
if (/pineapple/i.test(text)) {
setShowPostHogWorkBanner(true);
}
},
[postHogWorkBannerDismissed],
);
Comment on lines +260 to +268
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.

P1 The banner stays visible after the trigger word is deleted from the input. Once "pineapple" is typed the banner appears, but if the user then edits the text to remove it the banner remains — there is no branch that sets showPostHogWorkBanner back to false. The same issue exists in TaskInput.tsx.

Suggested change
const handlePromptTextChange = useCallback(
(text: string) => {
if (postHogWorkBannerDismissed) return;
if (/pineapple/i.test(text)) {
setShowPostHogWorkBanner(true);
}
},
[postHogWorkBannerDismissed],
);
const handlePromptTextChange = useCallback(
(text: string) => {
if (postHogWorkBannerDismissed) return;
setShowPostHogWorkBanner(/pineapple/i.test(text));
},
[postHogWorkBannerDismissed],
);
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/sessions/components/SessionView.tsx
Line: 260-268

Comment:
The banner stays visible after the trigger word is deleted from the input. Once "pineapple" is typed the banner appears, but if the user then edits the text to remove it the banner remains — there is no branch that sets `showPostHogWorkBanner` back to `false`. The same issue exists in `TaskInput.tsx`.

```suggestion
  const handlePromptTextChange = useCallback(
    (text: string) => {
      if (postHogWorkBannerDismissed) return;
      setShowPostHogWorkBanner(/pineapple/i.test(text));
    },
    [postHogWorkBannerDismissed],
  );
```

How can I resolve this? If you propose a fix, please make it concise.


const handleDismissPostHogWorkBanner = useCallback(() => {
Comment on lines 253 to +270
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.

P2 Duplicated banner logic violates OnceAndOnlyOnce

The same four state values (showPostHogWorkBanner, postHogWorkBannerDismissed) plus handlePromptTextChange and handleDismissPostHogWorkBanner — including the hardcoded /pineapple/i trigger — are copied verbatim into TaskInput.tsx. Any change to the trigger word or show/hide logic must be made in two places. Extracting a usePostHogWorkBanner() hook would keep this in one place.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/sessions/components/SessionView.tsx
Line: 253-270

Comment:
**Duplicated banner logic violates OnceAndOnlyOnce**

The same four state values (`showPostHogWorkBanner`, `postHogWorkBannerDismissed`) plus `handlePromptTextChange` and `handleDismissPostHogWorkBanner` — including the hardcoded `/pineapple/i` trigger — are copied verbatim into `TaskInput.tsx`. Any change to the trigger word or show/hide logic must be made in two places. Extracting a `usePostHogWorkBanner()` hook would keep this in one place.

How can I resolve this? If you propose a fix, please make it concise.

setShowPostHogWorkBanner(false);
setPostHogWorkBannerDismissed(true);
}, []);

const firstPendingPermission = useMemo(() => {
const entries = Array.from(pendingPermissions.entries());
if (entries.length === 0) return null;
Expand Down Expand Up @@ -615,8 +634,14 @@ export function SessionView({
: { maxWidth: CHAT_CONTENT_MAX_WIDTH }
}
>
{showPostHogWorkBanner && (
<TryInPostHogWorkBanner
onDismiss={handleDismissPostHogWorkBanner}
/>
)}
<PromptInput
ref={editorRef}
onTextChange={handlePromptTextChange}
sessionId={sessionId}
placeholder="Type a message... @ to mention files, ! for bash mode, / for skills"
disabled={!isRunning && !handoffInProgress}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Briefcase, X } from "@phosphor-icons/react";
import { Box, Button, Flex, IconButton, Text } from "@radix-ui/themes";

interface TryInPostHogWorkBannerProps {
onDismiss: () => void;
}

export function TryInPostHogWorkBanner({
onDismiss,
}: TryInPostHogWorkBannerProps) {
return (
<Box className="mb-3 rounded-(--radius-3) border border-(--gray-5) bg-(--gray-2) px-4 py-3">
<Flex align="center" gap="4">
<Flex
align="center"
justify="center"
className="size-9 shrink-0 rounded-(--radius-2) border border-(--gray-5) bg-(--gray-1)"
>
<Briefcase size={18} className="text-(--gray-11)" />
</Flex>
<Box className="min-w-0 flex-1">
<Text
as="div"
weight="medium"
className="text-(--gray-12) text-[13px]"
>
Try this in PostHog Work
</Text>
<Text as="div" className="text-(--gray-11) text-[12px]">
Looks like you're trying to generate shareholder value. Try
continuing this task in PostHog Work.
</Text>
</Box>
<Button size="2" variant="solid" color="gray" highContrast>
<Text className="px-2 text-[12px]">Try in PostHog Work</Text>
</Button>
Comment on lines +34 to +36
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.

P1 "Try in PostHog Work" button is non-functional

The primary CTA button has no onClick handler, so clicking it does nothing. For a feature explicitly described as an "entry point to PostHog Work," this means the banner shows up but the main action it advertises can never be triggered.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/sessions/components/TryInPostHogWorkBanner.tsx
Line: 34-36

Comment:
**"Try in PostHog Work" button is non-functional**

The primary CTA button has no `onClick` handler, so clicking it does nothing. For a feature explicitly described as an "entry point to PostHog Work," this means the banner shows up but the main action it advertises can never be triggered.

How can I resolve this? If you propose a fix, please make it concise.

<IconButton
size="1"
variant="ghost"
color="gray"
onClick={onDismiss}
aria-label="Dismiss"
>
<X size={14} />
</IconButton>
</Flex>
</Box>
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useArchivedTaskIds } from "@features/archive/hooks/useArchivedTaskIds";
import { SidebarUsageBar } from "@features/billing/components/SidebarUsageBar";
import { ModeSwitcher } from "@features/mode-switcher/components/ModeSwitcher";
import { ArchiveIcon } from "@phosphor-icons/react";
import { Box, Flex } from "@radix-ui/themes";
import { useNavigationStore } from "@stores/navigationStore";
Expand All @@ -13,14 +14,18 @@ export const SidebarContent: React.FC = () => {
const navigateToArchived = useNavigationStore(
(state) => state.navigateToArchived,
);
const mode = useNavigationStore((state) => state.mode);
const isCodeMode = mode === "code";

return (
<Flex direction="column" height="100%">
<ModeSwitcher />
<Box flexGrow="1" overflow="hidden">
<SidebarMenu />
{isCodeMode && <SidebarMenu />}
</Box>
<UpdateBanner />
<SidebarUsageBar />
{archivedTaskIds.size > 0 && (
{isCodeMode && archivedTaskIds.size > 0 && (
<Box className="shrink-0 border-gray-6 border-t">
<button
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type { EditorHandle } from "@features/message-editor/types";
import { resolveAndAttachDroppedFiles } from "@features/message-editor/utils/persistFile";
import { DropZoneOverlay } from "@features/sessions/components/DropZoneOverlay";
import { ReasoningLevelSelector } from "@features/sessions/components/ReasoningLevelSelector";
import { TryInPostHogWorkBanner } from "@features/sessions/components/TryInPostHogWorkBanner";
import { UnifiedModelSelector } from "@features/sessions/components/UnifiedModelSelector";
import { getCurrentModeFromConfigOptions } from "@features/sessions/stores/sessionStore";
import type { AgentAdapter } from "@features/settings/stores/settingsStore";
Expand Down Expand Up @@ -101,6 +102,24 @@ export function TaskInput({

const [editorIsEmpty, setEditorIsEmpty] = useState(true);
const [isDraggingFile, setIsDraggingFile] = useState(false);
const [showPostHogWorkBanner, setShowPostHogWorkBanner] = useState(false);
const [postHogWorkBannerDismissed, setPostHogWorkBannerDismissed] =
useState(false);

const handlePromptTextChange = useCallback(
(text: string) => {
if (postHogWorkBannerDismissed) return;
if (/pineapple/i.test(text)) {
setShowPostHogWorkBanner(true);
}
},
[postHogWorkBannerDismissed],
);

const handleDismissPostHogWorkBanner = useCallback(() => {
setShowPostHogWorkBanner(false);
setPostHogWorkBannerDismissed(true);
}, []);
const [isCreatingBranch, setIsCreatingBranch] = useState(false);
const [selectedBranch, setSelectedBranch] = useState<string | null>(null);
const [cloudRepoSearchQuery, setCloudRepoSearchQuery] = useState("");
Expand Down Expand Up @@ -741,8 +760,14 @@ export function TaskInput({
</Flex>

<Flex direction="column" gap="0">
{showPostHogWorkBanner && (
<TryInPostHogWorkBanner
onDismiss={handleDismissPostHogWorkBanner}
/>
)}
<PromptInput
ref={editorRef}
onTextChange={handlePromptTextChange}
sessionId={promptSessionId}
placeholder={`What do you want to ship? ${hints}`}
editorHeight="large"
Expand Down
5 changes: 5 additions & 0 deletions apps/code/src/renderer/features/work/components/WorkView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Box } from "@radix-ui/themes";

export function WorkView() {
return <Box className="h-full w-full" />;
}
Loading
Loading