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
53 changes: 50 additions & 3 deletions packages/app/src/components/dialog-select-file.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Avatar } from "@opencode-ai/ui/avatar"
import { useDialog } from "@opencode-ai/ui/context/dialog"
import { Dialog } from "@opencode-ai/ui/dialog"
import { FileIcon } from "@opencode-ai/ui/file-icon"
Expand All @@ -11,13 +12,15 @@ import { createMemo, createSignal, Match, onCleanup, Show, Switch } from "solid-
import { formatKeybind, useCommand, type CommandOption } from "@/context/command"
import { useGlobalSDK } from "@/context/global-sdk"
import { useGlobalSync } from "@/context/global-sync"
import { useLayout } from "@/context/layout"
import { getAvatarColors, useLayout, type LocalProject } from "@/context/layout"
import { useFile } from "@/context/file"
import { useLanguage } from "@/context/language"
import { useServer } from "@/context/server"
import { useSettings } from "@/context/settings"
import { decode64 } from "@/utils/base64"
import { getRelativeTime } from "@/utils/time"

type EntryType = "command" | "file" | "session"
type EntryType = "command" | "file" | "project" | "session"

type Entry = {
id: string
Expand All @@ -40,6 +43,8 @@ export function DialogSelectFile(props: { mode?: DialogSelectFileMode; onOpenFil
const command = useCommand()
const language = useLanguage()
const layout = useLayout()
const server = useServer()
const settings = useSettings()
const file = useFile()
const dialog = useDialog()
const params = useParams()
Expand Down Expand Up @@ -87,6 +92,19 @@ export function DialogSelectFile(props: { mode?: DialogSelectFileMode; onOpenFil
path,
})

const projectItem = (project: LocalProject): Entry => ({
id: "project:" + project.worktree,
type: "project",
title: project.name || getFilename(project.worktree),
description: project.worktree,
category: language.t("palette.group.projects"),
path: project.worktree,
})

const projectList = createMemo(() => layout.projects.list())
const projectLookup = createMemo(() => new Map(projectList().map((p) => [p.worktree, p])))
const projects = createMemo(() => (settings.palette.projects() ? projectList().map(projectItem) : []))

const projectDirectory = createMemo(() => decode64(params.dir) ?? "")
const project = createMemo(() => {
const directory = projectDirectory()
Expand Down Expand Up @@ -274,7 +292,7 @@ export function DialogSelectFile(props: { mode?: DialogSelectFileMode; onOpenFil

const [files, nextSessions] = await Promise.all([file.searchFiles(query), Promise.resolve(sessions(query))])
const entries = files.map(fileItem)
return [...list(), ...nextSessions, ...entries]
return [...projects(), ...list(), ...nextSessions, ...entries]
}

const handleMove = (item: Entry | undefined) => {
Expand Down Expand Up @@ -305,6 +323,12 @@ export function DialogSelectFile(props: { mode?: DialogSelectFileMode; onOpenFil
return
}

if (item.type === "project" && item.path) {
server.projects.touch(item.path)
navigate(`/${base64Encode(item.path)}`)
return
}

if (item.type === "session") {
if (!item.directory || !item.sessionID) return
navigate(`/${base64Encode(item.directory)}/session/${item.sessionID}`)
Expand Down Expand Up @@ -368,6 +392,29 @@ export function DialogSelectFile(props: { mode?: DialogSelectFileMode; onOpenFil
</Show>
</div>
</Match>
<Match when={item.type === "project"}>
{(() => {
const project = projectLookup().get(item.path ?? "")
const icon = project?.icon as { override?: string; color?: string } | undefined
return (
<div class="w-full flex items-center justify-between rounded-md pl-1">
<div class="flex items-center gap-x-3 grow min-w-0">
<Avatar
fallback={item.title}
src={icon?.override}
{...getAvatarColors(icon?.color)}
size="small"
class="shrink-0"
/>
<div class="flex items-center gap-1.5 text-14-regular min-w-0">
<span class="text-text-strong whitespace-nowrap">{item.title}</span>
<span class="text-text-weak truncate min-w-0">{item.description}</span>
</div>
</div>
</div>
)
})()}
</Match>
<Match when={item.type === "session"}>
<div class="w-full flex items-center justify-between rounded-md pl-1">
<div class="flex items-center gap-x-3 grow min-w-0">
Expand Down
17 changes: 17 additions & 0 deletions packages/app/src/components/settings-general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,23 @@ export const SettingsGeneral: Component = () => {
</div>
</div>

{/* Command Palette Section */}
<div class="flex flex-col gap-1">
<h3 class="text-14-medium text-text-strong pb-2">{language.t("settings.palette.projects")}</h3>

<div class="bg-surface-raised-base px-4 rounded-lg">
<SettingsRow
title={language.t("settings.palette.projects")}
description={language.t("settings.palette.projects.description")}
>
<Switch
checked={settings.palette.projects()}
onChange={(checked) => settings.palette.setProjects(checked)}
/>
</SettingsRow>
</div>
</div>

{/* System notifications Section */}
<div class="flex flex-col gap-1">
<h3 class="text-14-medium text-text-strong pb-2">{language.t("settings.general.section.notifications")}</h3>
Expand Down
12 changes: 12 additions & 0 deletions packages/app/src/context/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export interface Settings {
}
notifications: NotificationSettings
sounds: SoundSettings
palette: {
projects: boolean
}
}

const defaultSettings: Settings = {
Expand Down Expand Up @@ -61,6 +64,9 @@ const defaultSettings: Settings = {
permissions: "staplebops-02",
errors: "nope-03",
},
palette: {
projects: true,
},
}

const monoFallback =
Expand Down Expand Up @@ -158,6 +164,12 @@ export const { use: useSettings, provider: SettingsProvider } = createSimpleCont
setStore("notifications", "errors", value)
},
},
palette: {
projects: createMemo(() => store.palette?.projects ?? defaultSettings.palette.projects),
setProjects(value: boolean) {
setStore("palette", "projects", value)
},
},
sounds: {
agent: createMemo(() => store.sounds?.agent ?? defaultSettings.sounds.agent),
setAgent(value: string) {
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const dict = {
"palette.empty": "لا توجد نتائج",
"palette.group.commands": "الأوامر",
"palette.group.files": "الملفات",
"palette.group.projects": "المشاريع",
"settings.palette.projects": "عرض المشاريع في لوحة الأوامر",
"settings.palette.projects.description": "تضمين المشاريع في نتائج بحث Cmd+P",

"dialog.provider.search.placeholder": "البحث عن موفرين",
"dialog.provider.empty": "لم يتم العثور على موفرين",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const dict = {
"palette.empty": "Nenhum resultado encontrado",
"palette.group.commands": "Comandos",
"palette.group.files": "Arquivos",
"palette.group.projects": "Projetos",
"settings.palette.projects": "Mostrar projetos na paleta de comandos",
"settings.palette.projects.description": "Incluir projetos nos resultados de busca do Cmd+P",

"dialog.provider.search.placeholder": "Buscar provedores",
"dialog.provider.empty": "Nenhum provedor encontrado",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const dict = {
"palette.empty": "Ingen resultater fundet",
"palette.group.commands": "Kommandoer",
"palette.group.files": "Filer",
"palette.group.projects": "Projekter",
"settings.palette.projects": "Vis projekter i kommandopaletten",
"settings.palette.projects.description": "Inkluder projekter i Cmd+P søgeresultater",

"dialog.provider.search.placeholder": "Søg udbydere",
"dialog.provider.empty": "Ingen udbydere fundet",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export const dict = {
"palette.empty": "Keine Ergebnisse gefunden",
"palette.group.commands": "Befehle",
"palette.group.files": "Dateien",
"palette.group.projects": "Projekte",
"settings.palette.projects": "Projekte in der Befehlspalette anzeigen",
"settings.palette.projects.description": "Projekte in Cmd+P Suchergebnisse einbeziehen",

"dialog.provider.search.placeholder": "Anbieter durchsuchen",
"dialog.provider.empty": "Keine Anbieter gefunden",
Expand Down
4 changes: 4 additions & 0 deletions packages/app/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export const dict = {
"palette.empty": "No results found",
"palette.group.commands": "Commands",
"palette.group.files": "Files",
"palette.group.projects": "Projects",

"settings.palette.projects": "Show projects in command palette",
"settings.palette.projects.description": "Include projects in Cmd+P search results",

"dialog.provider.search.placeholder": "Search providers",
"dialog.provider.empty": "No providers found",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const dict = {
"palette.empty": "No se encontraron resultados",
"palette.group.commands": "Comandos",
"palette.group.files": "Archivos",
"palette.group.projects": "Proyectos",
"settings.palette.projects": "Mostrar proyectos en la paleta de comandos",
"settings.palette.projects.description": "Incluir proyectos en los resultados de búsqueda de Cmd+P",

"dialog.provider.search.placeholder": "Buscar proveedores",
"dialog.provider.empty": "No se encontraron proveedores",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const dict = {
"palette.empty": "Aucun résultat trouvé",
"palette.group.commands": "Commandes",
"palette.group.files": "Fichiers",
"palette.group.projects": "Projets",
"settings.palette.projects": "Afficher les projets dans la palette de commandes",
"settings.palette.projects.description": "Inclure les projets dans les résultats de recherche Cmd+P",

"dialog.provider.search.placeholder": "Rechercher des fournisseurs",
"dialog.provider.empty": "Aucun fournisseur trouvé",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const dict = {
"palette.empty": "結果が見つかりません",
"palette.group.commands": "コマンド",
"palette.group.files": "ファイル",
"palette.group.projects": "プロジェクト",
"settings.palette.projects": "コマンドパレットにプロジェクトを表示",
"settings.palette.projects.description": "Cmd+Pの検索結果にプロジェクトを含める",

"dialog.provider.search.placeholder": "プロバイダーを検索",
"dialog.provider.empty": "プロバイダーが見つかりません",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export const dict = {
"palette.empty": "결과 없음",
"palette.group.commands": "명령어",
"palette.group.files": "파일",
"palette.group.projects": "프로젝트",
"settings.palette.projects": "명령 팔레트에 프로젝트 표시",
"settings.palette.projects.description": "Cmd+P 검색 결과에 프로젝트 포함",

"dialog.provider.search.placeholder": "공급자 검색",
"dialog.provider.empty": "공급자 없음",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/no.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export const dict = {
"palette.empty": "Ingen resultater funnet",
"palette.group.commands": "Kommandoer",
"palette.group.files": "Filer",
"palette.group.projects": "Prosjekter",
"settings.palette.projects": "Vis prosjekter i kommandopaletten",
"settings.palette.projects.description": "Inkluder prosjekter i Cmd+P søkeresultater",

"dialog.provider.search.placeholder": "Søk etter leverandører",
"dialog.provider.empty": "Ingen leverandører funnet",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const dict = {
"palette.empty": "Brak wyników",
"palette.group.commands": "Polecenia",
"palette.group.files": "Pliki",
"palette.group.projects": "Projekty",
"settings.palette.projects": "Pokaż projekty w palecie poleceń",
"settings.palette.projects.description": "Uwzględnij projekty w wynikach wyszukiwania Cmd+P",

"dialog.provider.search.placeholder": "Szukaj dostawców",
"dialog.provider.empty": "Nie znaleziono dostawców",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const dict = {
"palette.empty": "Ничего не найдено",
"palette.group.commands": "Команды",
"palette.group.files": "Файлы",
"palette.group.projects": "Проекты",
"settings.palette.projects": "Показывать проекты в палитре команд",
"settings.palette.projects.description": "Включить проекты в результаты поиска Cmd+P",

"dialog.provider.search.placeholder": "Поиск провайдеров",
"dialog.provider.empty": "Провайдеры не найдены",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/th.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const dict = {
"palette.empty": "ไม่พบผลลัพธ์",
"palette.group.commands": "คำสั่ง",
"palette.group.files": "ไฟล์",
"palette.group.projects": "โปรเจกต์",
"settings.palette.projects": "แสดงโปรเจกต์ในพาเลทคำสั่ง",
"settings.palette.projects.description": "รวมโปรเจกต์ในผลการค้นหา Cmd+P",

"dialog.provider.search.placeholder": "ค้นหาผู้ให้บริการ",
"dialog.provider.empty": "ไม่พบผู้ให้บริการ",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export const dict = {
"palette.empty": "未找到结果",
"palette.group.commands": "命令",
"palette.group.files": "文件",
"palette.group.projects": "项目",
"settings.palette.projects": "在命令面板中显示项目",
"settings.palette.projects.description": "在 Cmd+P 搜索结果中包含项目",

"dialog.provider.search.placeholder": "搜索提供商",
"dialog.provider.empty": "未找到提供商",
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/i18n/zht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export const dict = {
"palette.empty": "找不到結果",
"palette.group.commands": "命令",
"palette.group.files": "檔案",
"palette.group.projects": "專案",
"settings.palette.projects": "在指令面板中顯示專案",
"settings.palette.projects.description": "在 Cmd+P 搜尋結果中包含專案",

"dialog.provider.search.placeholder": "搜尋提供者",
"dialog.provider.empty": "找不到提供者",
Expand Down
Loading