opencode-agent[bot] 3 месяцев назад
Родитель
Сommit
c813927bb6

+ 13 - 12
packages/opencode/src/cli/cmd/run/stream.transport.ts

@@ -607,9 +607,9 @@ function createLayer(input: StreamInput) {
               messages(
               messages(
                 input.sessionID,
                 input.sessionID,
                 input.replay
                 input.replay
-                  ? (input.replayLimit === undefined
-                      ? undefined
-                      : Math.max(input.replayLimit, SUBAGENT_BOOTSTRAP_LIMIT))
+                  ? input.replayLimit === undefined
+                    ? undefined
+                    : Math.max(input.replayLimit, SUBAGENT_BOOTSTRAP_LIMIT)
                   : SUBAGENT_BOOTSTRAP_LIMIT,
                   : SUBAGENT_BOOTSTRAP_LIMIT,
               ),
               ),
               Effect.promise(() =>
               Effect.promise(() =>
@@ -645,15 +645,16 @@ function createLayer(input: StreamInput) {
                 limits: input.limits(),
                 limits: input.limits(),
               })
               })
             : undefined
             : undefined
-          const replay = history && input.replayLimit !== undefined && messagesList.length > input.replayLimit
-            ? replaySession({
-                messages: messagesList.slice(-input.replayLimit),
-                permissions: sessionPermissions,
-                questions: sessionQuestions,
-                thinking: input.thinking,
-                limits: input.limits(),
-              })
-            : history
+          const replay =
+            history && input.replayLimit !== undefined && messagesList.length > input.replayLimit
+              ? replaySession({
+                  messages: messagesList.slice(-input.replayLimit),
+                  permissions: sessionPermissions,
+                  questions: sessionQuestions,
+                  thinking: input.thinking,
+                  limits: input.limits(),
+                })
+              : history
 
 
           replayedParts.clear()
           replayedParts.clear()
           if (history) {
           if (history) {

+ 4 - 1
packages/opencode/test/cli/run/session-replay.test.ts

@@ -106,7 +106,10 @@ function runningToolMessage(id: string): SessionMessages[number] {
 describe("run session replay", () => {
 describe("run session replay", () => {
   test("replays persisted user and assistant history into scrollback commits", () => {
   test("replays persisted user and assistant history into scrollback commits", () => {
     const out = replaySession({
     const out = replaySession({
-      messages: [userMessage("msg-user-1", "Hello, whats the weather today?"), assistantMessage("msg-1", "What city or ZIP code should I check?")],
+      messages: [
+        userMessage("msg-user-1", "Hello, whats the weather today?"),
+        assistantMessage("msg-1", "What city or ZIP code should I check?"),
+      ],
       permissions: [],
       permissions: [],
       questions: [],
       questions: [],
       thinking: true,
       thinking: true,

+ 22 - 15
packages/opencode/test/cli/run/stream.transport.test.ts

@@ -374,7 +374,14 @@ function footer(fn?: (commit: StreamCommit) => void) {
     },
     },
   }
   }
 
 
-  return { api, commits, events, get idleCalls() { return idleCalls } }
+  return {
+    api,
+    commits,
+    events,
+    get idleCalls() {
+      return idleCalls
+    },
+  }
 }
 }
 
 
 function sdk(
 function sdk(
@@ -932,16 +939,16 @@ describe("run stream transport", () => {
         messages: async ({ sessionID }) => {
         messages: async ({ sessionID }) => {
           if (sessionID === "session-1") {
           if (sessionID === "session-1") {
             return ok([
             return ok([
-                assistantMessage({
-                  sessionID: "session-1",
-                  id: "msg-1",
-                  parts: [
-                    runningTool({
-                      sessionID: "session-1",
-                      messageID: "msg-1",
-                      id: "task-1",
-                      callID: "call-1",
-                      tool: "task",
+              assistantMessage({
+                sessionID: "session-1",
+                id: "msg-1",
+                parts: [
+                  runningTool({
+                    sessionID: "session-1",
+                    messageID: "msg-1",
+                    id: "task-1",
+                    callID: "call-1",
+                    tool: "task",
                     body: {
                     body: {
                       description: "Explore run.ts",
                       description: "Explore run.ts",
                       subagent_type: "explore",
                       subagent_type: "explore",
@@ -949,10 +956,10 @@ describe("run stream transport", () => {
                     metadata: {
                     metadata: {
                       sessionId: "child-1",
                       sessionId: "child-1",
                     },
                     },
-                    }),
-                  ],
-                }),
-              ])
+                  }),
+                ],
+              }),
+            ])
           }
           }
 
 
           return sessionID === "child-1"
           return sessionID === "child-1"