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
6 changes: 5 additions & 1 deletion packages/app/src/pages/layout/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ type SessionStore = {
}

export const workspaceKey = (directory: string) => {
const value = directory.replaceAll("\\", "/")
let value = directory.replaceAll("\\", "/")
const wslMatch = value.match(/(?:^|\/+)(?:wsl(?:\.localhost|\$))\/[^/]+(\/.*)$/i)
if (wslMatch?.[1]) {
value = wslMatch[1]
}
const drive = value.match(/^([A-Za-z]:)\/+$/)
if (drive) return `${drive[1]}/`
if (/^\/+$/i.test(value)) return "/"
Expand Down
15 changes: 14 additions & 1 deletion packages/opencode/src/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ export namespace Session {
const parentTitlePrefix = "New session - "
const childTitlePrefix = "Child session - "

function normalizeSessionDirectory(directory: string) {
let value = directory.replaceAll("\\", "/")
const wslMatch = value.match(/(?:^|\/+)(?:wsl(?:\.localhost|\$))\/[^/]+(\/.*)$/i)
if (wslMatch?.[1]) {
value = wslMatch[1]
}
const drive = value.match(/^([A-Za-z]:)\/+$/)
if (drive) return `${drive[1]}/`
if (/^\/+$/i.test(value)) return "/"
return value.replace(/\/+$/, "")
}

function createDefaultTitle(isChild = false) {
return (isChild ? childTitlePrefix : parentTitlePrefix) + new Date().toISOString()
}
Expand Down Expand Up @@ -381,12 +393,13 @@ export namespace Session {
permission?: Permission.Ruleset
}) {
const ctx = yield* InstanceState.context
const directory = normalizeSessionDirectory(input.directory)
const result: Info = {
id: SessionID.descending(input.id),
slug: Slug.create(),
version: Installation.VERSION,
projectID: ctx.project.id,
directory: input.directory,
directory,
workspaceID: input.workspaceID,
parentID: input.parentID,
title: input.title ?? createDefaultTitle(!!input.parentID),
Expand Down
Loading