Add wave:term component with direct SSE output + /api/terminput input path#2974
Add wave:term component with direct SSE output + /api/terminput input path#2974
wave:term component with direct SSE output + /api/terminput input path#2974Conversation
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
wave:term component with direct SSE output + /api/terminput input path
| } | ||
| } | ||
|
|
||
| const TsunamiTerm = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(function TsunamiTerm( |
There was a problem hiding this comment.
CRITICAL: Missing displayName for React.forwardRef component
According to the project's coding guidelines, when using React.memo() or React.forwardRef(), you must add a displayName for the component. This helps with debugging and React DevTools.
Add after the component definition:
TsunamiTerm.displayName = "TsunamiTerm";
Code Review SummaryStatus: No New Issues Found | Recommendation: Merge This PR adds a new Tsunami terminal component (
All previously identified issues have already been commented on. No new critical issues were found during this review. Other Observations (not in diff)
Files Reviewed (11 files)
|
Deploying waveterm with
|
| Latest commit: |
b5e358e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8f5d475e.waveterm.pages.dev |
| Branch Preview URL: | https://copilot-add-new-tsunami-comp.waveterm.pages.dev |
…abs paths for env vars, dont pass position back for refs
| ); | ||
|
|
||
| return ( | ||
| <div {...outerProps} id={id} ref={setOuterRef as React.RefCallback<HTMLDivElement>} onFocus={handleFocus} onBlur={handleBlur}> |
There was a problem hiding this comment.
WARNING: Potential ref forwarding issue
The setOuterRef callback casts to React.RefCallback<HTMLDivElement>, but it expects TsunamiTermElem (which extends HTMLDivElement with custom methods). This cast may cause type safety issues. Consider using React.RefCallback<TsunamiTermElem> or handling the type more explicitly.
| terminalRef.current = terminal; | ||
|
|
||
| const onDataDisposable = terminal.onData((data) => { | ||
| if (id == null || id === "") { |
There was a problem hiding this comment.
SUGGESTION: Inconsistent null check pattern
The code uses id == null || id === "" here and on line 100, but the project guidelines prefer id == null without the explicit empty string check (since == null catches both null and undefined). Consider simplifying to just check if the id is truthy: if (!id) return;
| const { op, params } = termOp; | ||
| if (op === "termwrite") { | ||
| const data64 = params?.[0]; | ||
| if (typeof data64 === "string" && data64 !== "") { |
There was a problem hiding this comment.
SUGGESTION: Redundant empty string check
The check data64 !== "" is redundant since the parent condition already checks typeof data64 === "string". An empty string is still a valid string type. If you want to skip empty strings, the check is fine, but consider if this is the intended behavior.
This PR introduces a standalone Tsunami terminal element (
wave:term) and routes terminal IO outside the normal render/event loop for lower-latency streaming. It adds imperative terminal output (TermWrite) over SSE and terminal input/resize delivery over a dedicated/api/terminputendpoint.Frontend: new
wave:termelementtsunami/frontend/src/element/tsunamiterm.tsx.@xterm/xtermwith@xterm/addon-fit.<div>(style/class/ref target), with xterm auto-fit to that container.Frontend: terminal transport wiring
wave:termintsunami/frontend/src/vdom.tsx.termwriteintsunami/frontend/src/model/tsunami-model.tsx, dispatched to the terminal component via a local custom event.onDataandonResizenow POST directly to/api/terminputas JSON payloads:iddata64(base64 terminal input)termsize(rows,cols) for resize updatesBackend: new terminal IO APIs
/api/terminputhandler intsunami/engine/serverhandlers.go.tsunami/rpctypes/protocoltypes.go:TermInputPacket,TermWritePacket,TermSizetsunami/engine/clientimpl.go:SendTermWrite(id, data64)-> emits SSE eventtermwriteSetTermInputHandler(...)andHandleTermInput(...)tsunami/app/defaultclient.go:TermWrite(id, data64) errorSetTermInputHandler(func(TermInputPacket))Example usage
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.