Просмотр исходного кода

fix(desktop): homedir aware path on home

Adam 2 месяцев назад
Родитель
Сommit
a160eb76df
2 измененных файлов с 8 добавлено и 2 удалено
  1. 5 0
      packages/desktop/src/context/global-sync.tsx
  2. 3 2
      packages/desktop/src/pages/home.tsx

+ 5 - 0
packages/desktop/src/context/global-sync.tsx

@@ -55,12 +55,14 @@ export const { use: useGlobalSync, provider: GlobalSyncProvider } = createSimple
     const globalSDK = useGlobalSDK()
     const globalSDK = useGlobalSDK()
     const [globalStore, setGlobalStore] = createStore<{
     const [globalStore, setGlobalStore] = createStore<{
       ready: boolean
       ready: boolean
+      path: Path
       project: Project[]
       project: Project[]
       provider: ProviderListResponse
       provider: ProviderListResponse
       provider_auth: ProviderAuthResponse
       provider_auth: ProviderAuthResponse
       children: Record<string, State>
       children: Record<string, State>
     }>({
     }>({
       ready: false,
       ready: false,
+      path: { state: "", config: "", worktree: "", directory: "", home: "" },
       project: [],
       project: [],
       provider: { all: [], connected: [], default: {} },
       provider: { all: [], connected: [], default: {} },
       provider_auth: {},
       provider_auth: {},
@@ -224,6 +226,9 @@ export const { use: useGlobalSync, provider: GlobalSyncProvider } = createSimple
 
 
     async function bootstrap() {
     async function bootstrap() {
       return Promise.all([
       return Promise.all([
+        globalSDK.client.path.get().then((x) => {
+          setGlobalStore("path", x.data!)
+        }),
         globalSDK.client.project.list().then(async (x) => {
         globalSDK.client.project.list().then(async (x) => {
           setGlobalStore(
           setGlobalStore(
             "project",
             "project",

+ 3 - 2
packages/desktop/src/pages/home.tsx

@@ -1,5 +1,5 @@
 import { useGlobalSync } from "@/context/global-sync"
 import { useGlobalSync } from "@/context/global-sync"
-import { For, Match, Show, Switch } from "solid-js"
+import { createMemo, For, Match, Show, Switch } from "solid-js"
 import { Button } from "@opencode-ai/ui/button"
 import { Button } from "@opencode-ai/ui/button"
 import { Logo } from "@opencode-ai/ui/logo"
 import { Logo } from "@opencode-ai/ui/logo"
 import { useLayout } from "@/context/layout"
 import { useLayout } from "@/context/layout"
@@ -14,6 +14,7 @@ export default function Home() {
   const layout = useLayout()
   const layout = useLayout()
   const platform = usePlatform()
   const platform = usePlatform()
   const navigate = useNavigate()
   const navigate = useNavigate()
+  const homedir = createMemo(() => sync.data.path.home)
 
 
   function openProject(directory: string) {
   function openProject(directory: string) {
     layout.projects.open(directory)
     layout.projects.open(directory)
@@ -61,7 +62,7 @@ export default function Home() {
                     class="text-14-mono text-left justify-between px-3"
                     class="text-14-mono text-left justify-between px-3"
                     onClick={() => openProject(project.worktree)}
                     onClick={() => openProject(project.worktree)}
                   >
                   >
-                    {project.worktree}
+                    {project.worktree.replace(homedir(), "~")}
                     <div class="text-14-regular text-text-weak">
                     <div class="text-14-regular text-text-weak">
                       {DateTime.fromMillis(project.time.updated ?? project.time.created).toRelative()}
                       {DateTime.fromMillis(project.time.updated ?? project.time.created).toRelative()}
                     </div>
                     </div>