Skip to content
Merged
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
15 changes: 13 additions & 2 deletions packages/opencode/src/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ export namespace Session {

const OUTPUT_TOKEN_MAX = 32_000

const parentSessionTitlePrefix = "New session - "
const childSessionTitlePrefix = "Child session - "

function createDefaultTitle(isChild = false) {
return (isChild ? childSessionTitlePrefix : parentSessionTitlePrefix) + new Date().toISOString()
}

function isDefaultTitle(title: string) {
return title.startsWith(parentSessionTitlePrefix)
}

export const Info = z
.object({
id: Identifier.schema("session"),
Expand Down Expand Up @@ -154,7 +165,7 @@ export namespace Session {
id: Identifier.descending("session"),
version: Installation.VERSION,
parentID,
title: (parentID ? "Child session - " : "New Session - ") + new Date().toISOString(),
title: createDefaultTitle(!!parentID),
time: {
created: Date.now(),
updated: Date.now(),
Expand Down Expand Up @@ -632,7 +643,7 @@ export namespace Session {
const lastSummary = msgs.findLast((msg) => msg.info.role === "assistant" && msg.info.summary === true)
if (lastSummary) msgs = msgs.filter((msg) => msg.info.id >= lastSummary.info.id)

if (msgs.length === 1 && !session.parentID) {
if (msgs.length === 1 && !session.parentID && isDefaultTitle(session.title)) {
const small = (await Provider.getSmallModel(input.providerID)) ?? model
generateText({
maxOutputTokens: small.info.reasoning ? 1024 : 20,
Expand Down
Loading