GeezerVison is showing github.com — Revert "fix(app): terminal issues" · ayaz/opencode@9f4fc5b
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/pty/index.ts +4-5Lines changed: 4 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,9 +39,8 @@ export namespace Pty { | 39 | 39 | return next | 40 | 40 | } | 41 | 41 |
| 42 | | - const token = (ws: unknown) => { | 43 | | - if (!ws || typeof ws !== "object") return ws | 44 | | - const data = (ws as { data?: unknown }).data | | 42 | + const token = (ws: Socket) => { | | 43 | + const data = ws.data | 45 | 44 | if (data === undefined) return | 46 | 45 | if (data === null) return | 47 | 46 | if (typeof data !== "object") return data | @@ -318,7 +317,7 @@ export namespace Pty { | 318 | 317 | } | 319 | 318 | } | 320 | 319 |
| 321 | | - export function connect(id: string, ws: Socket, cursor?: number, identity?: unknown) { | | 320 | + export function connect(id: string, ws: Socket, cursor?: number) { | 322 | 321 | const session = state().get(id) | 323 | 322 | if (!session) { | 324 | 323 | ws.close() | @@ -338,7 +337,7 @@ export namespace Pty { | 338 | 337 | } | 339 | 338 |
| 340 | 339 | owners.set(ws, id) | 341 | | - session.subscribers.set(ws, { id: socketId, token: token(identity ?? ws) }) | | 340 | + session.subscribers.set(ws, { id: socketId, token: token(ws) }) | 342 | 341 |
| 343 | 342 | const cleanup = () => { | 344 | 343 | session.subscribers.delete(ws) | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/server/routes/pty.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -182,7 +182,7 @@ export const PtyRoutes = lazy(() => | 182 | 182 | ws.close() | 183 | 183 | return | 184 | 184 | } | 185 | | - handler = Pty.connect(id, socket, cursor, ws) | | 185 | + handler = Pty.connect(id, socket, cursor) | 186 | 186 | }, | 187 | 187 | onMessage(event) { | 188 | 188 | if (typeof event.data !== "string") return | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/test/pty/pty-output-isolation.test.ts -48Lines changed: 0 additions & 48 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -98,54 +98,6 @@ describe("pty", () => { | 98 | 98 | }) | 99 | 99 | }) | 100 | 100 |
| 101 | | - test("does not leak when identity token is only on websocket wrapper", async () => { | 102 | | - await using dir = await tmpdir({ git: true }) | 103 | | - | 104 | | - await Instance.provide({ | 105 | | - directory: dir.path, | 106 | | - fn: async () => { | 107 | | - const a = await Pty.create({ command: "cat", title: "a" }) | 108 | | - try { | 109 | | - const outA: string[] = [] | 110 | | - const outB: string[] = [] | 111 | | - const text = (data: string | Uint8Array | ArrayBuffer) => { | 112 | | - if (typeof data === "string") return data | 113 | | - if (data instanceof ArrayBuffer) return Buffer.from(new Uint8Array(data)).toString("utf8") | 114 | | - return Buffer.from(data).toString("utf8") | 115 | | - } | 116 | | - | 117 | | - const raw: Parameters<typeof Pty.connect>[1] = { | 118 | | - readyState: 1, | 119 | | - send: (data) => { | 120 | | - outA.push(text(data)) | 121 | | - }, | 122 | | - close: () => { | 123 | | - // no-op | 124 | | - }, | 125 | | - } | 126 | | - | 127 | | - const wrap = { data: { events: { connection: "a" } } } | 128 | | - | 129 | | - Pty.connect(a.id, raw, undefined, wrap) | 130 | | - outA.length = 0 | 131 | | - | 132 | | - // Simulate Bun reusing the raw socket object before the next onOpen, | 133 | | - // while the connection token only exists on the wrapper socket. | 134 | | - raw.send = (data) => { | 135 | | - outB.push(text(data)) | 136 | | - } | 137 | | - | 138 | | - Pty.write(a.id, "AAA\n") | 139 | | - await Bun.sleep(100) | 140 | | - | 141 | | - expect(outB.join("")).not.toContain("AAA") | 142 | | - } finally { | 143 | | - await Pty.remove(a.id) | 144 | | - } | 145 | | - }, | 146 | | - }) | 147 | | - }) | 148 | | - | 149 | 101 | test("does not leak output when socket data mutates in-place", async () => { | 150 | 102 | await using dir = await tmpdir({ git: true }) | 151 | 103 |
| |
|