Skip to content

Commit bc9e8e6

Browse files
committed
working tsunami app in wave
1 parent 4203d80 commit bc9e8e6

5 files changed

Lines changed: 29 additions & 3 deletions

File tree

electron.vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default defineConfig({
7878
server: {
7979
open: false,
8080
watch: {
81-
ignored: ["dist/**", "**/*.go", "**/go.mod", "**/go.sum", "**/*.md", "**/*.json"],
81+
ignored: ["dist/**", "**/*.go", "**/go.mod", "**/go.sum", "**/*.md", "**/*.json", "emain/**"],
8282
},
8383
},
8484
css: {

emain/emain-util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ export function shFrameNavHandler(event: Electron.Event<Electron.WebContentsWill
107107
// allowed
108108
return;
109109
}
110+
if (event.frame.name != null && event.frame.name.startsWith("tsunami")) {
111+
// allowed
112+
return;
113+
}
110114
event.preventDefault();
111115
console.log("frame navigation canceled");
112116
}

frontend/app/view/tsunami/tsunami.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const TsunamiView = memo(({ model }: TsunamiViewProps) => {
134134

135135
if (shouldShowIframe) {
136136
const iframeUrl = `http://localhost:${shellProcFullStatus.tsunamiport}/?clientid=wave:${model.blockId}`;
137-
return <iframe src={iframeUrl} className="w-full h-full border-0" title="Tsunami Application" />;
137+
return <iframe src={iframeUrl} className="w-full h-full border-0" title="Tsunami Application" name={`tsunami:${model.blockId}`} />;
138138
}
139139

140140
const status = shellProcFullStatus?.shellprocstatus ?? "init";

pkg/blockcontroller/tsunamicontroller.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"runtime"
1515
"strings"
1616
"sync"
17+
"syscall"
1718

1819
"github.com/wavetermdev/waveterm/pkg/utilds"
1920
"github.com/wavetermdev/waveterm/pkg/wavebase"
@@ -300,7 +301,7 @@ func (c *TsunamiController) SendInput(input *BlockInputUnion) error {
300301
}
301302

302303
func runTsunamiAppBinary(ctx context.Context, appBinPath string) (*TsunamiAppProc, error) {
303-
cmd := exec.CommandContext(ctx, appBinPath, "--close-on-stdin")
304+
cmd := exec.Command(appBinPath, "--close-on-stdin")
304305

305306
stdoutPipe, err := cmd.StdoutPipe()
306307
if err != nil {
@@ -338,6 +339,22 @@ func runTsunamiAppBinary(ctx context.Context, appBinPath string) (*TsunamiAppPro
338339
// Start goroutine to handle cmd.Wait()
339340
go func() {
340341
tsunamiProc.WaitRtn = cmd.Wait()
342+
log.Printf("WAIT RETURN: %v\n", tsunamiProc.WaitRtn)
343+
if err := tsunamiProc.WaitRtn; err != nil {
344+
if ee, ok := err.(*exec.ExitError); ok {
345+
if ws, ok := ee.ProcessState.Sys().(syscall.WaitStatus); ok {
346+
if ws.Signaled() {
347+
sig := ws.Signal()
348+
log.Printf("tsunami proc killed by signal: %s (%d)", sig, int(sig))
349+
} else {
350+
log.Printf("tsunami proc exited with code %d", ee.ExitCode())
351+
}
352+
}
353+
} else {
354+
log.Printf("tsunami proc error: %v", err)
355+
}
356+
}
357+
341358
close(waitCh)
342359
}()
343360

@@ -354,6 +371,7 @@ func runTsunamiAppBinary(ctx context.Context, appBinPath string) (*TsunamiAppPro
354371
errChan <- fmt.Errorf("stderr buffer error: %w", err)
355372
return
356373
}
374+
log.Printf("[stderr-readline] %s\n", line)
357375

358376
port := build.ParseTsunamiPort(line)
359377
if port > 0 {

tsunami/build/build.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ type BuildOpts struct {
3939
MoveFileBack bool
4040
}
4141

42+
func (b BuildOpts) AppName() string {
43+
return filepath.Base(b.AppPath)
44+
}
45+
4246
type BuildEnv struct {
4347
GoVersion string
4448
TempDir string

0 commit comments

Comments
 (0)