refactor(session): centralize fallback title policy (#39890)

This commit is contained in:
Kit Langton 2026-07-31 10:56:38 -04:00 committed by GitHub
commit 7aaf4e7750
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 145 additions and 93 deletions

View file

@ -6,6 +6,7 @@ import { Agent } from "../agent"
import { Database } from "../database/database"
import { Bus } from "../bus"
import { makeLocationNode } from "@opencode-ai/util/effect/app-node"
import { isExactRootFallback } from "@opencode-ai/util/session-title-fallback"
import { App } from "../app"
import { llmClient } from "../effect/app-node-platform"
import { SessionEvent } from "./event"
@ -39,7 +40,10 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/Se
const truncate = (value: string) => (value.length <= MAX_LENGTH ? value : `${value.slice(0, MAX_LENGTH - 3)}...`)
const isUntitled = (session: SessionSchema.Info) =>
session.title === undefined || session.title === `New session - ${DateTime.formatIso(session.time.created)}`
isExactRootFallback({
title: session.title,
time: { created: DateTime.toEpochMillis(session.time.created) },
})
const make = (dependencies: Dependencies) => {
const generateForFirstPrompt = Effect.fn("SessionTitle.generateForFirstPrompt")(function* (