fix: SSH terminal [Object Object] — Wails v3 Events.On receives event object, not raw data
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 1m6s
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 1m6s
Events.On callback gets a CustomEvent with .data property, not the base64 string directly. Added multi-format extraction with debug logging for unexpected shapes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
16d105e1fb
commit
8362a50460
@ -96,9 +96,23 @@ export function useTerminal(sessionId: string): UseTerminalReturn {
|
|||||||
fitAddon.fit();
|
fitAddon.fit();
|
||||||
|
|
||||||
// Subscribe to SSH output events for this session
|
// Subscribe to SSH output events for this session
|
||||||
cleanupEvent = Events.On(`ssh:data:${sessionId}`, (...args: unknown[]) => {
|
// Wails v3 Events.On callback receives a CustomEvent object with .data property
|
||||||
// Wails v3 events pass data as arguments
|
cleanupEvent = Events.On(`ssh:data:${sessionId}`, (event: any) => {
|
||||||
const b64data = typeof args[0] === "string" ? args[0] : String(args[0] ?? "");
|
// Extract the base64 string from the event
|
||||||
|
// event.data is the first argument passed to app.Event.Emit()
|
||||||
|
let b64data: string;
|
||||||
|
if (typeof event === "string") {
|
||||||
|
b64data = event;
|
||||||
|
} else if (event?.data && typeof event.data === "string") {
|
||||||
|
b64data = event.data;
|
||||||
|
} else if (Array.isArray(event?.data)) {
|
||||||
|
b64data = String(event.data[0] ?? "");
|
||||||
|
} else {
|
||||||
|
// Debug: log the actual shape so we can fix it
|
||||||
|
console.warn("ssh:data unexpected shape:", JSON.stringify(event)?.slice(0, 200));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const decoded = atob(b64data);
|
const decoded = atob(b64data);
|
||||||
terminal.write(decoded);
|
terminal.write(decoded);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user