GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Revert "fix(app): terminal issues" · ayaz/opencode@9f4fc5b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/opencode
    • src
      • pty
        • index.ts
      • server/routes
        • pty.ts
    • test/pty
      • pty-output-isolation.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/src/pty/index.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/pty/index.ts
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ export namespace Pty {
3939
return next
4040
}
4141

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
4544
if (data === undefined) return
4645
if (data === null) return
4746
if (typeof data !== "object") return data
@@ -318,7 +317,7 @@ export namespace Pty {
318317
}
319318
}
320319

321-
export function connect(id: string, ws: Socket, cursor?: number, identity?: unknown) {
320+
export function connect(id: string, ws: Socket, cursor?: number) {
322321
const session = state().get(id)
323322
if (!session) {
324323
ws.close()
@@ -338,7 +337,7 @@ export namespace Pty {
338337
}
339338

340339
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) })
342341

343342
const cleanup = () => {
344343
session.subscribers.delete(ws)
Collapse file

‎packages/opencode/src/server/routes/pty.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/server/routes/pty.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export const PtyRoutes = lazy(() =>
182182
ws.close()
183183
return
184184
}
185-
handler = Pty.connect(id, socket, cursor, ws)
185+
handler = Pty.connect(id, socket, cursor)
186186
},
187187
onMessage(event) {
188188
if (typeof event.data !== "string") return
Collapse file

‎packages/opencode/test/pty/pty-output-isolation.test.ts‎

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 numberDiff line numberDiff line change
@@ -98,54 +98,6 @@ describe("pty", () => {
9898
})
9999
})
100100

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-
149101
test("does not leak output when socket data mutates in-place", async () => {
150102
await using dir = await tmpdir({ git: true })
151103

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.