The open source coding agent.
TypeScript
fix(app): navigate to tabs when opening file
adamelmoreeac2d4c6999f
diff --git a/packages/app/src/components/dialog-select-file.tsx b/packages/app/src/components/dialog-select-file.tsxindex 83baa7a5e25..54ed48a9d98 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.tsxindex caa6d3ad18a..6de7ed3e7c3 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(() => <DialogSelectFile />),+ onSelect: () => dialog.show(() => <DialogSelectFile onOpenFile={() => showAllFiles()} />),},{id: "context.addSelection",@@ -1084,11 +1084,31 @@ export default function Page() {const pendingDiff = () => tree.pendingDiffconst 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()) returnsetFileTreeTab("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") returnsetFileTreeTab(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(() => <DialogSelectFile mode="files" />)}+ onClick={() =>+ dialog.show(() => <DialogSelectFile mode="files" onOpenFile={() => showAllFiles()} />)+ }aria-label={language.t("command.file.open")}/></TooltipKeybind>@@ -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)