Skip to content

Commit a80d637

Browse files
committed
fix: display folder name instead of full path in sidebar
- Fix getFilename() to handle both / and \ for cross-platform support - Change tooltip to show folder name instead of worktree path - Remove duplicate getFilename function in dialog-edit-project
1 parent f510d17 commit a80d637

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

packages/app/src/components/dialog-edit-project.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ import { createMemo, createSignal, For, Show } from "solid-js"
77
import { createStore } from "solid-js/store"
88
import { useGlobalSDK } from "@/context/global-sdk"
99
import { type LocalProject, getAvatarColors } from "@/context/layout"
10+
import { getFilename } from "@opencode-ai/util/path"
1011
import { Avatar } from "@opencode-ai/ui/avatar"
1112

1213
const AVATAR_COLOR_KEYS = ["pink", "mint", "orange", "purple", "cyan", "lime"] as const
1314

14-
function getFilename(input: string) {
15-
const parts = input.split("/")
16-
return parts[parts.length - 1] || input
17-
}
18-
1915
export function DialogEditProject(props: { project: LocalProject }) {
2016
const dialog = useDialog()
2117
const globalSDK = useGlobalSDK()

packages/app/src/pages/layout.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { useDialog } from "@opencode-ai/ui/context/dialog"
5252
import { useTheme, type ColorScheme } from "@opencode-ai/ui/theme"
5353
import { DialogSelectProvider } from "@/components/dialog-select-provider"
5454
import { DialogEditProject } from "@/components/dialog-edit-project"
55+
import { DialogViewArchivedSessions } from "@/components/dialog-view-archived-sessions"
5556
import { DialogSelectServer } from "@/components/dialog-select-server"
5657
import { useCommand, type CommandOption } from "@/context/command"
5758
import { ConstrainDragXAxis } from "@/utils/solid-dnd"
@@ -800,6 +801,11 @@ export default function Layout(props: ParentProps) {
800801
<DropdownMenu.Trigger as={IconButton} icon="dot-grid" variant="ghost" />
801802
<DropdownMenu.Portal>
802803
<DropdownMenu.Content>
804+
<DropdownMenu.Item
805+
onSelect={() => dialog.show(() => <DialogViewArchivedSessions project={props.project} />)}
806+
>
807+
<DropdownMenu.ItemLabel>View archived sessions</DropdownMenu.ItemLabel>
808+
</DropdownMenu.Item>
803809
<DropdownMenu.Item
804810
onSelect={() => dialog.show(() => <DialogEditProject project={props.project} />)}
805811
>
@@ -868,7 +874,7 @@ export default function Layout(props: ParentProps) {
868874
</Collapsible>
869875
</Match>
870876
<Match when={true}>
871-
<Tooltip placement="right" value={props.project.worktree}>
877+
<Tooltip placement="right" value={getFilename(props.project.worktree)}>
872878
<ProjectVisual project={props.project} />
873879
</Tooltip>
874880
</Match>

packages/util/src/path.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export function getFilename(path: string | undefined) {
22
if (!path) return ""
3-
const trimmed = path.replace(/[\/]+$/, "")
4-
const parts = trimmed.split("/")
3+
const trimmed = path.replace(/[\/\\]+$/, "")
4+
const parts = trimmed.split(/[\/\\]/)
55
return parts[parts.length - 1] ?? ""
66
}
77

0 commit comments

Comments
 (0)