Skip to content

Commit 87a791f

Browse files
committed
fix(desktop): new session not selecting tab
1 parent ada7cca commit 87a791f

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

packages/desktop/src/context/session.tsx

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,14 @@ export const { use: useSession, provider: SessionProvider } = createSimpleContex
201201
sdk.client.pty.create({ body: { title: `Terminal ${store.terminals.all.length + 1}` } }).then((pty) => {
202202
const id = pty.data?.id
203203
if (!id) return
204-
batch(() => {
205-
setStore("terminals", "all", [
206-
...store.terminals.all,
207-
{
208-
id,
209-
title: pty.data?.title ?? "Terminal",
210-
// rows: pty.data?.rows ?? 24,
211-
// cols: pty.data?.cols ?? 80,
212-
// buffer: "",
213-
// scrollY: 0,
214-
},
215-
])
216-
setStore("terminals", "active", id)
217-
})
204+
setStore("terminals", "all", [
205+
...store.terminals.all,
206+
{
207+
id,
208+
title: pty.data?.title ?? "Terminal",
209+
},
210+
])
211+
setStore("terminals", "active", id)
218212
})
219213
},
220214
update(pty: Partial<LocalPTY> & { id: string }) {
@@ -224,6 +218,21 @@ export const { use: useSession, provider: SessionProvider } = createSimpleContex
224218
body: { title: pty.title, size: pty.cols && pty.rows ? { rows: pty.rows, cols: pty.cols } : undefined },
225219
})
226220
},
221+
async clone(id: string) {
222+
const index = store.terminals.all.findIndex((x) => x.id === id)
223+
const pty = store.terminals.all[index]
224+
if (!pty) return
225+
const clone = await sdk.client.pty.create({
226+
body: {
227+
title: pty.title,
228+
},
229+
})
230+
if (!clone.data) return
231+
setStore("terminals", "all", index, {
232+
...pty,
233+
...clone.data,
234+
})
235+
},
227236
open(id: string) {
228237
setStore("terminals", "active", id)
229238
},

0 commit comments

Comments
 (0)