GitHub Action 2 месяцев назад
Родитель
Сommit
dac73572e0

+ 10 - 6
packages/opencode/src/server/routes/session.ts

@@ -276,12 +276,16 @@ export const SessionRoutes = lazy(() =>
         const sessionID = c.req.valid("param").sessionID
         const sessionID = c.req.valid("param").sessionID
         const updates = c.req.valid("json")
         const updates = c.req.valid("json")
 
 
-        const updatedSession = await Session.update(sessionID, (session) => {
-          if (updates.title !== undefined) {
-            session.title = updates.title
-          }
-          if (updates.time?.archived !== undefined) session.time.archived = updates.time.archived
-        }, { touch: false })
+        const updatedSession = await Session.update(
+          sessionID,
+          (session) => {
+            if (updates.title !== undefined) {
+              session.title = updates.title
+            }
+            if (updates.time?.archived !== undefined) session.time.archived = updates.time.archived
+          },
+          { touch: false },
+        )
 
 
         return c.json(updatedSession)
         return c.json(updatedSession)
       },
       },

+ 16 - 8
packages/opencode/src/session/index.ts

@@ -255,11 +255,15 @@ export namespace Session {
     }
     }
     const { ShareNext } = await import("@/share/share-next")
     const { ShareNext } = await import("@/share/share-next")
     const share = await ShareNext.create(id)
     const share = await ShareNext.create(id)
-    await update(id, (draft) => {
-      draft.share = {
-        url: share.url,
-      }
-    }, { touch: false })
+    await update(
+      id,
+      (draft) => {
+        draft.share = {
+          url: share.url,
+        }
+      },
+      { touch: false },
+    )
     return share
     return share
   })
   })
 
 
@@ -267,9 +271,13 @@ export namespace Session {
     // Use ShareNext to remove the share (same as share function uses ShareNext to create)
     // Use ShareNext to remove the share (same as share function uses ShareNext to create)
     const { ShareNext } = await import("@/share/share-next")
     const { ShareNext } = await import("@/share/share-next")
     await ShareNext.remove(id)
     await ShareNext.remove(id)
-    await update(id, (draft) => {
-      draft.share = undefined
-    }, { touch: false })
+    await update(
+      id,
+      (draft) => {
+        draft.share = undefined
+      },
+      { touch: false },
+    )
   })
   })
 
 
   export async function update(id: string, editor: (session: Info) => void, options?: { touch?: boolean }) {
   export async function update(id: string, editor: (session: Info) => void, options?: { touch?: boolean }) {

+ 15 - 11
packages/opencode/src/session/prompt.ts

@@ -1806,16 +1806,20 @@ NOTE: At any point in time through this workflow you should feel free to ask the
     })
     })
     const text = await result.text.catch((err) => log.error("failed to generate title", { error: err }))
     const text = await result.text.catch((err) => log.error("failed to generate title", { error: err }))
     if (text)
     if (text)
-      return Session.update(input.session.id, (draft) => {
-        const cleaned = text
-          .replace(/<think>[\s\S]*?<\/think>\s*/g, "")
-          .split("\n")
-          .map((line) => line.trim())
-          .find((line) => line.length > 0)
-        if (!cleaned) return
-
-        const title = cleaned.length > 100 ? cleaned.substring(0, 97) + "..." : cleaned
-        draft.title = title
-      }, { touch: false })
+      return Session.update(
+        input.session.id,
+        (draft) => {
+          const cleaned = text
+            .replace(/<think>[\s\S]*?<\/think>\s*/g, "")
+            .split("\n")
+            .map((line) => line.trim())
+            .find((line) => line.length > 0)
+          if (!cleaned) return
+
+          const title = cleaned.length > 100 ? cleaned.substring(0, 97) + "..." : cleaned
+          draft.title = title
+        },
+        { touch: false },
+      )
   }
   }
 }
 }