summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTimo Clasen <[email protected]>2025-08-06 00:15:50 +0200
committerGitHub <[email protected]>2025-08-05 17:15:50 -0500
commit49aa48ce5850eb97e4a145a1ee93794283a95790 (patch)
tree7ad4a7c90aabb653093228c122190c35498db532
parent857a3cd52221b820dbfd34dae8ff1d42bbb8c108 (diff)
downloadopencode-49aa48ce5850eb97e4a145a1ee93794283a95790.tar.gz
opencode-49aa48ce5850eb97e4a145a1ee93794283a95790.zip
fix: prevent title regeneration on auto compact (#1628)
-rw-r--r--packages/opencode/src/session/index.ts15
1 files changed, 13 insertions, 2 deletions
diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts
index 8e75e749b..89ae5a573 100644
--- a/packages/opencode/src/session/index.ts
+++ b/packages/opencode/src/session/index.ts
@@ -48,6 +48,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"),
@@ -153,7 +164,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(),
@@ -631,7 +642,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,