Browse Source

fix(app): terminal clone needs remount

adamelmore 4 weeks ago
parent
commit
3fdd6ec120
2 changed files with 20 additions and 7 deletions
  1. 11 6
      packages/app/src/context/terminal.tsx
  2. 9 1
      packages/app/src/pages/session.tsx

+ 11 - 6
packages/app/src/context/terminal.tsx

@@ -150,13 +150,18 @@ function createTerminalSession(sdk: ReturnType<typeof useSDK>, dir: string, sess
           return undefined
         })
       if (!clone?.data) return
-      setStore("all", index, {
-        ...pty,
-        ...clone.data,
+
+      const active = store.active === pty.id
+
+      batch(() => {
+        setStore("all", index, {
+          ...pty,
+          ...clone.data,
+        })
+        if (active) {
+          setStore("active", clone.data.id)
+        }
       })
-      if (store.active === pty.id) {
-        setStore("active", clone.data.id)
-      }
     },
     open(id: string) {
       setStore("active", id)

+ 9 - 1
packages/app/src/pages/session.tsx

@@ -2474,7 +2474,15 @@ export default function Page() {
                           display: terminal.active() === pty.id ? "block" : "none",
                         }}
                       >
-                        <Terminal pty={pty} onCleanup={terminal.update} onConnectError={() => terminal.clone(pty.id)} />
+                        <Show when={pty.id} keyed>
+                          {() => (
+                            <Terminal
+                              pty={pty}
+                              onCleanup={terminal.update}
+                              onConnectError={() => terminal.clone(pty.id)}
+                            />
+                          )}
+                        </Show>
                       </div>
                     )}
                   </For>