Skip to content
Open
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
23 changes: 23 additions & 0 deletions packages/app/src/pages/session/use-session-commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import { DialogSelectMcp } from "@/components/dialog-select-mcp"
import { DialogFork } from "@/components/dialog-fork"
import { showToast } from "@opencode-ai/ui/toast"
import { findLast } from "@opencode-ai/util/array"
import { base64Encode } from "@opencode-ai/util/encode"
import { extractPromptFromParts } from "@/utils/prompt"
import { UserMessage } from "@opencode-ai/sdk/v2"
import { canAddSelectionContext } from "@/pages/session/session-command-helpers"
import { DialogSelectDirectory } from "@/components/dialog-select-directory"

export type SessionCommandContext = {
navigateMessageByOffset: (offset: number) => void
Expand Down Expand Up @@ -87,6 +89,10 @@ export const useSessionCommands = (actions: SessionCommandContext) => {
const navigateMessageByOffset = actions.navigateMessageByOffset
const setActiveMessage = actions.setActiveMessage
const focusInput = actions.focusInput
const openDir = (dir: string) => {
layout.projects.open(dir)
navigate(`/${base64Encode(dir)}/session`)
}

const sessionCommand = withCategory(language.t("command.category.session"))
const fileCommand = withCategory(language.t("command.category.file"))
Expand All @@ -106,6 +112,23 @@ export const useSessionCommands = (actions: SessionCommandContext) => {
slash: "new",
onSelect: () => navigate(`/${params.dir}/session`),
}),
sessionCommand({
id: "project.cd",
title: language.t("command.project.open"),
description: language.t("dialog.directory.search.placeholder"),
slash: "cd",
onSelect: () => {
dialog.show(() => (
<DialogSelectDirectory
title="/cd"
onSelect={(result) => {
if (!result || Array.isArray(result)) return
openDir(result)
}}
/>
))
},
}),
])

const fileCommands = createMemo(() => [
Expand Down
Loading