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
3 changes: 3 additions & 0 deletions packages/app/src/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ function HomeDesign() {
if (conn) setSelection({ server: ServerConnection.key(conn) })
})

createEffect(() => {
document.title = "OpenCode"
})
createEffect(() => {
const pending = pendingHomeNavigation
if (!pending || pending.server !== server.key) return
Expand Down
15 changes: 15 additions & 0 deletions packages/app/src/pages/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { IconButton } from "@opencode-ai/ui/icon-button"
import { Tooltip } from "@opencode-ai/ui/tooltip"
import { DropdownMenu } from "@opencode-ai/ui/dropdown-menu"
import { Dialog } from "@opencode-ai/ui/dialog"
import { first } from "@opencode-ai/ui/utils/first"
import { getFilename } from "@opencode-ai/core/util/path"
import { Session, type Message } from "@opencode-ai/sdk/v2/client"
import { usePlatform } from "@/context/platform"
Expand Down Expand Up @@ -638,6 +639,12 @@ export default function Layout(props: ParentProps) {
return result
})

const currentSession = createMemo(() => {
const id = params.id
if (!id) return
return currentSessions().find((s) => s.id === id)
})

type PrefetchQueue = {
inflight: Set<string>
pending: string[]
Expand Down Expand Up @@ -886,6 +893,14 @@ export default function Layout(props: ParentProps) {

warm(sessions, index)
})
createEffect(() => {
const project = currentProject()
const session = currentSession()
const projectName = project ? displayName(project) : getFilename(currentDir() ?? "")
const letter = first(projectName).toUpperCase()
const title = session?.title
document.title = title ? `${letter}|${title} - ${projectName}` : `${letter}|${projectName}`
})

function navigateSessionByOffset(offset: number) {
const sessions = currentSessions()
Expand Down
1 change: 1 addition & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"./icons/app": "./src/components/app-icons/types.ts",
"./fonts/*": "./src/assets/fonts/*",
"./audio/*": "./src/assets/audio/*",
"./utils/*": "./src/utils/*.ts",
"./v2/*.css": "./src/v2/components/*.css",
"./v2/*": "./src/v2/components/*.tsx",
"./v2/styles/*": "./src/v2/styles/*"
Expand Down
10 changes: 10 additions & 0 deletions packages/ui/src/utils/first.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const segmenter =
typeof Intl !== "undefined" && "Segmenter" in Intl
? new Intl.Segmenter(undefined, { granularity: "grapheme" })
: undefined

export function first(value: string) {
if (!value) return ""
if (!segmenter) return Array.from(value)[0] ?? ""
return segmenter.segment(value)[Symbol.iterator]().next().value?.segment ?? Array.from(value)[0] ?? ""
}
12 changes: 1 addition & 11 deletions packages/ui/src/v2/components/avatar-v2.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import { first } from "../../utils/first"
import { type ComponentProps, splitProps, Show } from "solid-js"
import "./avatar-v2.css"

const segmenter =
typeof Intl !== "undefined" && "Segmenter" in Intl
? new Intl.Segmenter(undefined, { granularity: "grapheme" })
: undefined

function first(value: string) {
if (!value) return ""
if (!segmenter) return Array.from(value)[0] ?? ""
return segmenter.segment(value)[Symbol.iterator]().next().value?.segment ?? Array.from(value)[0] ?? ""
}

export interface AvatarProps extends ComponentProps<"div"> {
fallback: string
src?: string
Expand Down
12 changes: 1 addition & 11 deletions packages/ui/src/v2/components/project-avatar-v2.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import { first } from "../../utils/first"
import { type ComponentProps, splitProps, Show } from "solid-js"
import "./project-avatar-v2.css"

const segmenter =
typeof Intl !== "undefined" && "Segmenter" in Intl
? new Intl.Segmenter(undefined, { granularity: "grapheme" })
: undefined

function first(value: string) {
if (!value) return ""
if (!segmenter) return Array.from(value)[0] ?? ""
return segmenter.segment(value)[Symbol.iterator]().next().value?.segment ?? Array.from(value)[0] ?? ""
}

export const PROJECT_AVATAR_VARIANTS = [
"orange",
"yellow",
Expand Down
Loading