Skip to content
Open
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
32 changes: 32 additions & 0 deletions packages/app/src/components/titlebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { tabKey, useTabs } from "@/context/tabs"
import type { PromptSession } from "@/context/prompt"
import "./titlebar.css"
import { newTabTooltipKeybind } from "./command-tooltip-keybind"
import { useDirectoryPicker } from "@/components/directory-picker"
import { homeProjectDirectories } from "@/pages/layout/helpers"

type TauriDesktopWindow = {
startDragging?: () => Promise<void>
Expand Down Expand Up @@ -253,6 +255,7 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
{(_) => {
const layout = useLayout()
const global = useGlobal()
const pickDirectory = useDirectoryPicker()

const tabs = useTabs()
const tabsStore = tabs.store
Expand Down Expand Up @@ -373,6 +376,35 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
}
const toggleHome = () => tabs.toggleHome({ home: layout.route().type === "home", current: currentTab() })

const chooseProject = () => {
const conn = server.current
if (!conn) return
pickDirectory({
server: conn,
title: language.t("command.project.open"),
multiple: true,
onSelect: (result) => {
const directories = homeProjectDirectories(result)
const directory = directories[0]
if (!directory) return
const ctx = global.ensureServerCtx(conn)
directories.forEach((entry) => ctx.projects.open(entry))
ctx.projects.touch(directory)
void tabs.newDraft({ server: ServerConnection.key(conn), directory })
},
})
}

command.register("titlebar-project", () => [
{
id: "project.open",
title: language.t("command.project.open"),
category: language.t("command.category.project"),
keybind: "mod+o",
onSelect: chooseProject,
},
])

command.register("titlebar-home", () => [
{
id: "home.toggle",
Expand Down
11 changes: 11 additions & 0 deletions packages/app/src/pages/new-session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ export default function NewSessionPage() {
keybind: "ctrl+l",
onSelect: () => promptInputV2Controller.restoreFocus(),
},
{
id: "workspace.new",
title: language.t("workspace.new"),
category: language.t("command.category.workspace"),
keybind: "mod+shift+w",
disabled: !showWorkspaceBar(),
onSelect: () => {
setStore("worktree", "create")
promptInputV2Controller.restoreFocus()
},
},
])

createEffect(() => {
Expand Down
Loading