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 @@ -4,7 +4,7 @@ import { ChevronDownIcon } from "@radix-ui/react-icons";
import { Button, DropdownMenu, Flex, Text } from "@radix-ui/themes";
import { SHORTCUTS } from "@renderer/constants/keyboard-shortcuts";
import { handleExternalAppAction } from "@utils/handleExternalAppAction";
import { useCallback } from "react";
import { useCallback, useState } from "react";
import { useHotkeys } from "react-hotkeys-hook";

const THUMBNAIL_ICON_SIZE = 20;
Expand All @@ -20,6 +20,7 @@ export function ExternalAppsOpener({
label = "Open",
}: ExternalAppsOpenerProps) {
const { detectedApps, defaultApp, isLoading } = useExternalApps();
const [dropdownOpen, setDropdownOpen] = useState(false);

const handleOpenDefault = useCallback(async () => {
if (!defaultApp || !targetPath) return;
Expand Down Expand Up @@ -81,7 +82,17 @@ export function ExternalAppsOpener({
const isReady = !isLoading && detectedApps.length > 0;

return (
<DropdownMenu.Root>
<DropdownMenu.Root open={dropdownOpen} onOpenChange={setDropdownOpen}>
{dropdownOpen && (
<div
className="no-drag"
style={{
position: "fixed",
inset: 0,
zIndex: 1,
}}
/>
)}
<Flex className="no-drag">
<Button
size="1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { FilePicker } from "@features/command/components/FilePicker";
import { PanelLayout } from "@features/panels";
import { usePanelLayoutStore } from "@features/panels/store/panelLayoutStore";
import {
getLeafPanel,
parseTabId,
} from "@features/panels/store/panelStoreHelpers";
import { useCwd } from "@features/sidebar/hooks/useCwd";
import { useTaskData } from "@features/task-detail/hooks/useTaskData";
import { useTaskStore } from "@features/tasks/stores/taskStore";
Expand Down Expand Up @@ -30,6 +35,28 @@ export function TaskDetail({ task: initialTask }: TaskDetailProps) {

const effectiveRepoPath = useCwd(taskId);

const activeRelativePath = usePanelLayoutStore((state) => {
const layout = state.getLayout(taskId);
if (!layout) return null;

const panelId = layout.focusedPanelId;
if (!panelId) return null;

const panel = getLeafPanel(layout.panelTree, panelId);
if (!panel) return null;

const parsed = parseTabId(panel.content.activeTabId);
if (parsed.type === "file") {
return parsed.value;
}
return null;
});

const openTargetPath =
activeRelativePath && effectiveRepoPath
? [effectiveRepoPath, activeRelativePath].join("/").replace(/\/+/g, "/")
: effectiveRepoPath;

const [filePickerOpen, setFilePickerOpen] = useState(false);

const { enableScope, disableScope } = useHotkeysContext();
Expand Down Expand Up @@ -60,12 +87,10 @@ export function TaskDetail({ task: initialTask }: TaskDetailProps) {
{task.title}
</Text>
</Flex>
{effectiveRepoPath && (
<ExternalAppsOpener targetPath={effectiveRepoPath} />
)}
{openTargetPath && <ExternalAppsOpener targetPath={openTargetPath} />}
</Flex>
),
[task.title, effectiveRepoPath],
[task.title, openTargetPath],
);

useSetHeaderContent(headerContent);
Expand Down
Loading