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
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ import {
MenuLabel,
} from "@posthog/quill";
import { trpcClient } from "@renderer/trpc";
import type { RefObject } from "react";

interface FolderPickerProps {
value: string;
onChange: (path: string) => void;
placeholder?: string;
size?: "1" | "2";
anchor?: RefObject<HTMLElement | null>;
}

export function FolderPicker({
value,
onChange,
placeholder = "Select folder...",
anchor,
}: FolderPickerProps) {
const {
getRecentFolders,
Expand Down Expand Up @@ -85,6 +88,7 @@ export function FolderPicker({
}
/>
<DropdownMenuContent
anchor={anchor}
align="start"
side="bottom"
sideOffset={6}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ComboboxList,
ComboboxTrigger,
} from "@posthog/quill";
import type { RefObject } from "react";

interface GitHubRepoPickerProps {
value: string | null;
Expand All @@ -18,6 +19,7 @@ interface GitHubRepoPickerProps {
placeholder?: string;
size?: "1" | "2";
disabled?: boolean;
anchor?: RefObject<HTMLElement | null>;
}

export function GitHubRepoPicker({
Expand All @@ -27,6 +29,7 @@ export function GitHubRepoPicker({
isLoading,
placeholder = "Select repository...",
disabled = false,
anchor,
}: GitHubRepoPickerProps) {
if (isLoading) {
return (
Expand Down Expand Up @@ -68,7 +71,12 @@ export function GitHubRepoPicker({
</Button>
}
/>
<ComboboxContent side="bottom" sideOffset={6} className="min-w-[280px]">
<ComboboxContent
anchor={anchor}
side="bottom"
sideOffset={6}
className="min-w-[280px]"
>
<ComboboxInput placeholder="Search repositories..." />
<ComboboxEmpty>No repositories found.</ComboboxEmpty>
<ComboboxList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { useTRPC } from "@renderer/trpc";
import { toast } from "@renderer/utils/toast";
import { useMutation, useQuery } from "@tanstack/react-query";
import { useEffect, useRef, useState } from "react";
import { type RefObject, useEffect, useRef, useState } from "react";

interface BranchSelectorProps {
repoPath: string | null;
Expand All @@ -34,6 +34,7 @@ interface BranchSelectorProps {
onCloudPickerOpen?: () => void;
onCloudBranchCommit?: () => void;
taskId?: string;
anchor?: RefObject<HTMLElement | null>;
}

export function BranchSelector({
Expand All @@ -51,9 +52,10 @@ export function BranchSelector({
onCloudPickerOpen,
onCloudBranchCommit,
taskId,
anchor,
}: BranchSelectorProps) {
const [open, setOpen] = useState(false);
const anchorRef = useRef<HTMLButtonElement>(null);
const localAnchorRef = useRef<HTMLButtonElement>(null);
const trpc = useTRPC();
const { actions } = useGitInteractionStore();

Expand Down Expand Up @@ -149,7 +151,7 @@ export function BranchSelector({
<ComboboxTrigger
render={
<Button
ref={anchorRef}
ref={localAnchorRef}
variant="outline"
size="sm"
disabled={isDisabled}
Expand All @@ -171,7 +173,7 @@ export function BranchSelector({
}
/>
<ComboboxContent
anchor={anchorRef}
anchor={anchor ?? localAnchorRef}
side="bottom"
sideOffset={6}
className="min-w-[240px]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export function TaskInput({

const editorRef = useRef<EditorHandle>(null);
const containerRef = useRef<HTMLDivElement>(null);
const buttonGroupRef = useRef<HTMLDivElement>(null);
const dragCounterRef = useRef(0);

const [editorIsEmpty, setEditorIsEmpty] = useState(true);
Expand Down Expand Up @@ -404,7 +405,6 @@ export function TaskInput({
position: "relative",
height: "100%",
width: "100%",
overflow: "hidden",
}}
onDragEnter={handleDragEnter}
onDragLeave={handleDragLeave}
Expand Down Expand Up @@ -459,11 +459,7 @@ export function TaskInput({
zIndex: 1,
}}
>
<Flex
gap="2"
align="center"
style={{ minWidth: 0, overflow: "hidden" }}
>
<Flex gap="2" align="center" style={{ minWidth: 0 }}>
<WorkspaceModeSelect
value={workspaceMode}
onChange={setWorkspaceMode}
Expand All @@ -479,7 +475,7 @@ export function TaskInput({
disabled={isCreatingTask}
/>
)}
<ButtonGroup>
<ButtonGroup ref={buttonGroupRef}>
{workspaceMode === "cloud" ? (
<GitHubRepoPicker
value={selectedRepository}
Expand All @@ -489,13 +485,15 @@ export function TaskInput({
placeholder="Select repository..."
size="1"
disabled={isCreatingTask}
anchor={buttonGroupRef}
/>
) : (
<FolderPicker
value={selectedDirectory}
onChange={setSelectedDirectory}
placeholder="Select repository..."
size="1"
anchor={buttonGroupRef}
/>
)}
<BranchSelector
Expand All @@ -521,6 +519,7 @@ export function TaskInput({
cloudBranchesFetchingMore={cloudBranchesFetchingMore}
onCloudPickerOpen={resumeCloudBranchesLoading}
onCloudBranchCommit={pauseCloudBranchesLoading}
anchor={buttonGroupRef}
/>
</ButtonGroup>
{cloudRegion === "dev" && (
Expand Down
Loading