فهرست منبع

fix: don't let --continue access subagent session (#2091)

Aiden Cline 6 ماه پیش
والد
کامیت
a2db58f125
2فایلهای تغییر یافته به همراه22 افزوده شده و 10 حذف شده
  1. 11 5
      packages/opencode/src/cli/cmd/run.ts
  2. 11 5
      packages/opencode/src/cli/cmd/tui.ts

+ 11 - 5
packages/opencode/src/cli/cmd/run.ts

@@ -67,11 +67,17 @@ export const RunCommand = cmd({
     await bootstrap({ cwd: process.cwd() }, async () => {
       const session = await (async () => {
         if (args.continue) {
-          const list = Session.list()
-          const first = await list.next()
-          await list.return()
-          if (first.done) return
-          return first.value
+          const it = Session.list()
+          try {
+            for await (const s of it) {
+              if (s.parentID === undefined) {
+                return s
+              }
+            }
+            return
+          } finally {
+            await it.return()
+          }
         }
 
         if (args.session) return Session.get(args.session)

+ 11 - 5
packages/opencode/src/cli/cmd/tui.ts

@@ -82,11 +82,17 @@ export const TuiCommand = cmd({
       const result = await bootstrap({ cwd }, async (app) => {
         const sessionID = await (async () => {
           if (args.continue) {
-            const list = Session.list()
-            const first = await list.next()
-            await list.return()
-            if (first.done) return
-            return first.value.id
+            const it = Session.list()
+            try {
+              for await (const s of it) {
+                if (s.parentID === undefined) {
+                  return s.id
+                }
+              }
+              return
+            } finally {
+              await it.return()
+            }
           }
           if (args.session) {
             return args.session