From eac2d4c6999f79085ac72dd4812125674030ef16 Mon Sep 17 00:00:00 2001 From: adamelmore <2363879+adamdottv@users.noreply.github.com> Date: Tue, 27 Jan 2026 08:17:00 -0600 Subject: [PATCH] fix(app): navigate to tabs when opening file --- .../app/src/components/dialog-select-file.tsx | 3 +- packages/app/src/pages/session.tsx | 29 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/packages/app/src/components/dialog-select-file.tsx b/packages/app/src/components/dialog-select-file.tsx index 83baa7a5e..54ed48a9d 100644 --- a/packages/app/src/components/dialog-select-file.tsx +++ b/packages/app/src/components/dialog-select-file.tsx @@ -26,7 +26,7 @@ type Entry = { type DialogSelectFileMode = "all" | "files" -export function DialogSelectFile(props: { mode?: DialogSelectFileMode }) { +export function DialogSelectFile(props: { mode?: DialogSelectFileMode; onOpenFile?: (path: string) => void }) { const command = useCommand() const language = useLanguage() const layout = useLayout() @@ -164,6 +164,7 @@ export function DialogSelectFile(props: { mode?: DialogSelectFileMode }) { tabs().open(value) file.load(path) view().reviewPanel.open() + props.onOpenFile?.(path) } const handleSelect = (item: Entry | undefined) => { diff --git a/packages/app/src/pages/session.tsx b/packages/app/src/pages/session.tsx index caa6d3ad1..6de7ed3e7 100644 --- a/packages/app/src/pages/session.tsx +++ b/packages/app/src/pages/session.tsx @@ -650,7 +650,7 @@ export default function Page() { category: language.t("command.category.file"), keybind: "mod+p", slash: "open", - onSelect: () => dialog.show(() => ), + onSelect: () => dialog.show(() => showAllFiles()} />), }, { id: "context.addSelection", @@ -1084,11 +1084,31 @@ export default function Page() { const pendingDiff = () => tree.pendingDiff const setPendingDiff = (value: string | undefined) => setTree("pendingDiff", value) + const showAllFiles = () => { + if (!layout.fileTree.opened()) return + if (fileTreeTab() !== "changes") return + setFileTreeTab("all") + } + createEffect(() => { if (!layout.fileTree.opened()) return setFileTreeTab("changes") }) + createEffect( + on( + () => tabs().active(), + (active) => { + if (!active) return + if (!layout.fileTree.opened()) return + if (fileTreeTab() !== "changes") return + if (!file.pathFromTab(active)) return + showAllFiles() + }, + { defer: true }, + ), + ) + const setFileTreeTabValue = (value: string) => { if (value !== "changes" && value !== "all") return setFileTreeTab(value) @@ -1702,6 +1722,7 @@ export default function Page() { focusedComment={comments.focus()} onFocusedCommentChange={comments.setFocus} onViewFile={(path) => { + showAllFiles() const value = file.tab(path) tabs().open(value) file.load(path) @@ -2068,7 +2089,9 @@ export default function Page() { icon="plus-small" variant="ghost" iconSize="large" - onClick={() => dialog.show(() => )} + onClick={() => + dialog.show(() => showAllFiles()} />) + } aria-label={language.t("command.file.open")} /> @@ -2100,6 +2123,7 @@ export default function Page() { focusedComment={comments.focus()} onFocusedCommentChange={comments.setFocus} onViewFile={(path) => { + showAllFiles() const value = file.tab(path) tabs().open(value) file.load(path) @@ -2679,6 +2703,7 @@ export default function Page() { focusedComment={comments.focus()} onFocusedCommentChange={comments.setFocus} onViewFile={(path) => { + showAllFiles() const value = file.tab(path) tabs().open(value) file.load(path)