fix(app): improve tab handling (#30669)

This commit is contained in:
Brendan Allan
2026-06-05 11:41:30 +08:00
committed by GitHub
parent 3003867c25
commit 5426478e46
12 changed files with 238 additions and 203 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ function DirectoryDataProvider(props: ParentProps<{ directory: string }>) {
createResource(
() => params.id,
(id) => sync.session.sync(id),
(id) => sync.session.sync(id).catch(() => {}),
)
return (
+1 -1
View File
@@ -67,7 +67,7 @@ export function getProjectAvatarSource(id?: string, icon?: { color?: string; url
export function projectForSession<T extends { id?: string; worktree: string; sandboxes?: string[] }>(
session: Session,
projects: T[],
byID: Map<string, T>,
byID: Map<string, T> = new Map(projects.flatMap((project) => (project.id ? [[project.id, project] as const] : []))),
) {
const direct = byID.get(session.projectID)
if (direct) return direct
@@ -418,23 +418,26 @@ export const useSessionCommands = (actions: SessionCommandContext) => {
}),
]
const fileCmds = () => [
fileCommand({
id: "file.open",
title: language.t("command.file.open"),
description: language.t("palette.search.placeholder"),
keybind: "mod+k,mod+p",
slash: "open",
onSelect: openFile,
}),
fileCommand({
id: "tab.close",
title: language.t("command.tab.close"),
keybind: "mod+w",
disabled: !closableTab(),
onSelect: closeTab,
}),
]
const fileCmds = () => {
const tab = closableTab()
return [
fileCommand({
id: "file.open",
title: language.t("command.file.open"),
description: language.t("palette.search.placeholder"),
keybind: "mod+k,mod+p",
slash: "open",
onSelect: openFile,
}),
tab &&
fileCommand({
id: "tab.close",
title: language.t("command.tab.close"),
keybind: "mod+w",
onSelect: closeTab,
}),
].filter((v) => !!v)
}
const contextCmds = () => [
contextCommand({