Knowledge Hubบทที่ 15
Updates · อัปเดตใหม่

maw workboard · pty backend เป็นฐานต่อยอด

เรื่องใหม่จาก inbox review รอบถัดมา: ใช้ backend ที่ออกแบบดีเป็นฐานต่อยอด ไม่เขียนทับ · A new inbox-reviewed lesson: a well-designed backend lets others extend it without replacing it.

Source and publishing rule

บทนี้มาจาก Discord #road-to-dev messages 1514871469019103332, 1514871510320418916, และ 1514871678558277713 เวลา 2026-06-12T05:58Z ถึง 05:59Z.

The durable part is not the praise. The durable part is the architecture lesson: build a collaborative workboard as a thin layer on maw-js pty capabilities.

What changed

SomBo reported building a collaborative workboard with terminal, microphone, image pinning, and screen sharing on top of maw-js. The key discovery: the backend had already solved the hard terminal-sharing parts.

Workboard จึงไม่ต้อง rewrite terminal sharing เอง แค่ต่อ viewer บาง ๆ เข้ากับ backend เดิม แล้วเพิ่ม collaboration surface รอบ ๆ terminal.

Backend capabilities to reuse

Backend pieceReusable capability
pty.tsMulti-viewer terminal streaming.
pty.tsScrollback replay for late joiners.
Grouped session handlingWeb viewers do not force the real terminal to resize or collapse.
/ws/ptyThin viewer connection point for real-time terminal sharing.
mpr-plugin shapedefinePlugin, channels, and serve hooks keep the package boundary clean.

Design lesson

A good backend is measured by how quickly another person can build on it without touching the original.

That is the reusable standard from this update. The backend is not only successful when its own UI works; it is successful when a new UI can attach cleanly.

Race-control lesson

The multi-viewer bug SomBo hit came from fighting the attaching mutex in pty.ts. The mutex was not arbitrary friction; it existed to protect against race conditions.

Rule: before bypassing a backend guard, identify what race or invariant the guard protects. Use the shared upstream path instead of competing with it.

Security pattern carried forward

DEVBOY distilled the ssh-share design lesson as relay without trusting the relay: the terminal link puts the key in the URL #hash, so the server can relay without seeing plaintext.

The workboard should preserve that capability-style thinking. Sharing a link is powerful; use read-only/default-safe modes when the viewer does not need control.

Implementation checklist

Reuse /ws/pty

Attach a viewer instead of reimplementing terminal transport.

Keep layers additive

Mic, images, and screen sharing are collaboration layers around the terminal, not replacements for sshx.

Respect mutexes

Backend locks usually encode a race that the UI has not seen yet.

Package as plugin

Use the existing plugin shape so the workboard remains removable and testable.