|
1 | 1 | import { FilePicker } from "@features/command/components/FilePicker"; |
2 | 2 | import { PanelLayout } from "@features/panels"; |
| 3 | +import { usePanelLayoutStore } from "@features/panels/store/panelLayoutStore"; |
| 4 | +import { |
| 5 | + getLeafPanel, |
| 6 | + parseTabId, |
| 7 | +} from "@features/panels/store/panelStoreHelpers"; |
3 | 8 | import { useCwd } from "@features/sidebar/hooks/useCwd"; |
4 | 9 | import { useTaskData } from "@features/task-detail/hooks/useTaskData"; |
5 | 10 | import { useTaskStore } from "@features/tasks/stores/taskStore"; |
@@ -30,6 +35,28 @@ export function TaskDetail({ task: initialTask }: TaskDetailProps) { |
30 | 35 |
|
31 | 36 | const effectiveRepoPath = useCwd(taskId); |
32 | 37 |
|
| 38 | + const activeRelativePath = usePanelLayoutStore((state) => { |
| 39 | + const layout = state.getLayout(taskId); |
| 40 | + if (!layout) return null; |
| 41 | + |
| 42 | + const panelId = layout.focusedPanelId; |
| 43 | + if (!panelId) return null; |
| 44 | + |
| 45 | + const panel = getLeafPanel(layout.panelTree, panelId); |
| 46 | + if (!panel) return null; |
| 47 | + |
| 48 | + const parsed = parseTabId(panel.content.activeTabId); |
| 49 | + if (parsed.type === "file" || parsed.type === "diff") { |
| 50 | + return parsed.value; |
| 51 | + } |
| 52 | + return null; |
| 53 | + }); |
| 54 | + |
| 55 | + const openTargetPath = |
| 56 | + activeRelativePath && effectiveRepoPath |
| 57 | + ? `${effectiveRepoPath}/${activeRelativePath}` |
| 58 | + : effectiveRepoPath; |
| 59 | + |
33 | 60 | const [filePickerOpen, setFilePickerOpen] = useState(false); |
34 | 61 |
|
35 | 62 | const { enableScope, disableScope } = useHotkeysContext(); |
@@ -60,12 +87,10 @@ export function TaskDetail({ task: initialTask }: TaskDetailProps) { |
60 | 87 | {task.title} |
61 | 88 | </Text> |
62 | 89 | </Flex> |
63 | | - {effectiveRepoPath && ( |
64 | | - <ExternalAppsOpener targetPath={effectiveRepoPath} /> |
65 | | - )} |
| 90 | + {openTargetPath && <ExternalAppsOpener targetPath={openTargetPath} />} |
66 | 91 | </Flex> |
67 | 92 | ), |
68 | | - [task.title, effectiveRepoPath], |
| 93 | + [task.title, openTargetPath], |
69 | 94 | ); |
70 | 95 |
|
71 | 96 | useSetHeaderContent(headerContent); |
|
0 commit comments