Skip to content

Commit 6e3b835

Browse files
committed
refactor(plugin): replace server URL retrieval with PTYServer instance
1 parent a2f6cb9 commit 6e3b835

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/plugin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ptyWrite } from './plugin/pty/tools/write.ts'
66
import { ptyRead } from './plugin/pty/tools/read.ts'
77
import { ptyList } from './plugin/pty/tools/list.ts'
88
import { ptyKill } from './plugin/pty/tools/kill.ts'
9-
import { getServerUrl, startWebServer } from './web/server/server.ts'
9+
import { PTYServer } from './web/server/server.ts'
1010

1111
interface SessionDeletedEvent {
1212
type: 'session.deleted'
@@ -21,11 +21,12 @@ const ptyServerUrlCommand = 'pty-server-url'
2121
export const PTYPlugin = async ({ client, directory }: PluginContext): Promise<PluginResult> => {
2222
initPermissions(client, directory)
2323
initManager(client)
24+
const ptyServer = await PTYServer.createServer()
2425

2526
return {
2627
'command.execute.before': async (input) => {
2728
if (input.command === ptyServerUrlCommand) {
28-
const serverUrl = getServerUrl()
29+
const serverUrl = ptyServer.server.url.toString()
2930
client.session.prompt({
3031
path: { id: input.sessionID },
3132
body: {
@@ -54,7 +55,7 @@ export const PTYPlugin = async ({ client, directory }: PluginContext): Promise<P
5455
if (!input.command) {
5556
input.command = {}
5657
}
57-
const serverUrl = await startWebServer()
58+
const serverUrl = ptyServer.server.url.toString()
5859
input.command[ptyServerUrlCommand] = {
5960
template: `${serverUrl}`,
6061
description: 'print link to PTY web server',

0 commit comments

Comments
 (0)