diff --git a/.vscode/settings.json b/.vscode/settings.json index 5be93fed63..938048131c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,7 @@ "editor.tabSize": 4, "editor.insertSpaces": false, "prettier.useEditorConfig": true, + "diffEditor.renderSideBySide": false, "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, diff --git a/cmd/wsh/cmd/wshcmd-ai.go b/cmd/wsh/cmd/wshcmd-ai.go index 71f175089a..2f64a8fe56 100644 --- a/cmd/wsh/cmd/wshcmd-ai.go +++ b/cmd/wsh/cmd/wshcmd-ai.go @@ -135,6 +135,14 @@ func aiRun(cmd *cobra.Command, args []string) (rtnErr error) { return fmt.Errorf("reading from stdin: %w", err) } message.Write(data) + + // Also include any remaining arguments (excluding the "-" itself) + if len(args) > 1 { + if message.Len() > 0 { + message.WriteString(" ") + } + message.WriteString(strings.Join(args[1:], " ")) + } } else { message.WriteString(strings.Join(args, " ")) } diff --git a/cmd/wsh/cmd/wshcmd-connserver.go b/cmd/wsh/cmd/wshcmd-connserver.go index d9c7a8bc07..678ea77cc5 100644 --- a/cmd/wsh/cmd/wshcmd-connserver.go +++ b/cmd/wsh/cmd/wshcmd-connserver.go @@ -21,7 +21,6 @@ import ( "github.com/wavetermdev/waveterm/pkg/remote/fileshare/wshfs" "github.com/wavetermdev/waveterm/pkg/util/packetparser" "github.com/wavetermdev/waveterm/pkg/util/sigutil" - "github.com/wavetermdev/waveterm/pkg/util/utilfn" "github.com/wavetermdev/waveterm/pkg/wavebase" "github.com/wavetermdev/waveterm/pkg/wshrpc" "github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient" @@ -163,7 +162,9 @@ func serverRunRouter(jwtToken string) error { // just ignore and drain the rawCh (stdin) // when stdin is closed, shutdown defer wshutil.DoShutdown("", 0, true) - utilfn.DrainChannelSafe(rawCh, "serverRunRouter:stdin") + for range rawCh { + // ignore + } }() go func() { for msg := range termProxy.FromRemoteCh { diff --git a/pkg/util/utilfn/utilfn.go b/pkg/util/utilfn/utilfn.go index f5765e0078..f7d180e596 100644 --- a/pkg/util/utilfn/utilfn.go +++ b/pkg/util/utilfn/utilfn.go @@ -1057,15 +1057,16 @@ func GracefulClose(closer io.Closer, debugName, closerName string) bool { } // DrainChannelSafe will drain a channel until it is empty or until a timeout is reached. -// WARNING: This function will panic if the channel is not drained within the timeout. func DrainChannelSafe[T any](ch <-chan T, debugName string) { drainTimeoutCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) go func() { defer cancel() + outer: for { select { case <-drainTimeoutCtx.Done(): - panic(debugName + ": timeout draining channel") + log.Printf("[error] timeout draining channel: %s\n", debugName) + break outer case _, ok := <-ch: if !ok { return