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
16 changes: 16 additions & 0 deletions packages/app/src/pages/layout/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import {
displayName,
effectiveWorkspaceOrder,
errorMessage,
getProjectAvatarSource,
hasProjectPermissions,
latestRootSession,
OPENCODE_PROJECT_ID,
} from "./helpers"
import { pathKey } from "@/utils/path-key"

Expand Down Expand Up @@ -217,6 +219,20 @@ describe("layout workspace helpers", () => {
expect(displayName({ worktree: "/tmp/app", name: "My App" })).toBe("My App")
})

test("uses the opencode favicon as the default project icon", () => {
expect(getProjectAvatarSource(OPENCODE_PROJECT_ID)).toBe("https://opencode.ai/favicon.svg")
})

test("allows custom project icons to override the opencode favicon", () => {
expect(getProjectAvatarSource(OPENCODE_PROJECT_ID, { override: "data:image/png;base64,abc" })).toBe(
"data:image/png;base64,abc",
)
})

test("allows color avatars to override the opencode favicon", () => {
expect(getProjectAvatarSource(OPENCODE_PROJECT_ID, { color: "pink" })).toBeUndefined()
})

test("extracts api error message and fallback", () => {
expect(errorMessage({ data: { message: "boom" } }, "fallback")).toBe("boom")
expect(errorMessage(new Error("broken"), "fallback")).toBe("broken")
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/pages/layout/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export const childSessionOnPath = (sessions: Session[] | undefined, rootID: stri
export const displayName = (project: { name?: string; worktree: string }) =>
project.name || getFilename(project.worktree)

const OPENCODE_PROJECT_ID = "4b0ea68d7af9a6031a7ffda7ad66e0cb83315750"
export const OPENCODE_PROJECT_ID = "4b0ea68d7af9a6031a7ffda7ad66e0cb83315750"

export function getProjectAvatarSource(id?: string, icon?: { color?: string; url?: string; override?: string }) {
if (id === OPENCODE_PROJECT_ID) return "https://opencode.ai/favicon.svg"
if (icon?.override) return icon.override
if (icon?.color) return undefined
if (id === OPENCODE_PROJECT_ID) return "https://opencode.ai/favicon.svg"
return icon?.url
}

Expand Down
Loading