Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/wsh/cmd/wshcmd-ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ func aiRun(cmd *cobra.Command, args []string) (rtnErr error) {
if message.Len() == 0 {
return fmt.Errorf("message is empty")
}
if message.Len() > 10*1024 {
return fmt.Errorf("current max message size is 10k")
if message.Len() > 50*1024 {
return fmt.Errorf("current max message size is 50k")
}

messageData := wshrpc.AiMessageData{
Expand Down
2 changes: 1 addition & 1 deletion cmd/wsh/cmd/wshcmd-rcfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var rcfilesCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
err := wshutil.InstallRcFiles()
if err != nil {
WriteStderr(err.Error())
WriteStderr("%s\n", err.Error())
return
}
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/wsh/cmd/wshcmd-setbg.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func setBgRun(cmd *cobra.Command, args []string) (rtnErr error) {
if err != nil {
return fmt.Errorf("error formatting metadata: %v", err)
}
WriteStdout(string(jsonBytes) + "\n")
WriteStdout("%s\n", string(jsonBytes))
return nil
}

Expand Down
34 changes: 13 additions & 21 deletions frontend/app/view/preview/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ import "./preview.scss";
const MaxFileSize = 1024 * 1024 * 10; // 10MB
const MaxCSVSize = 1024 * 1024 * 1; // 1MB

// TODO drive this using config
const BOOKMARKS: { label: string; path: string }[] = [
{ label: "Home", path: "~" },
{ label: "Desktop", path: "~/Desktop" },
{ label: "Downloads", path: "~/Downloads" },
{ label: "Documents", path: "~/Documents" },
{ label: "Root", path: "/" },
];

type SpecializedViewProps = {
model: PreviewModel;
parentRef: React.RefObject<HTMLDivElement>;
Expand Down Expand Up @@ -185,27 +194,10 @@ export class PreviewModel implements ViewModel {
elemtype: "iconbutton",
icon: "folder-open",
longClick: (e: React.MouseEvent<any>) => {
const menuItems: ContextMenuItem[] = [];
menuItems.push({
label: "Go to Home",
click: () => this.goHistory("~"),
});
menuItems.push({
label: "Go to Desktop",
click: () => this.goHistory("~/Desktop"),
});
menuItems.push({
label: "Go to Downloads",
click: () => this.goHistory("~/Downloads"),
});
menuItems.push({
label: "Go to Documents",
click: () => this.goHistory("~/Documents"),
});
menuItems.push({
label: "Go to Root",
click: () => this.goHistory("/"),
});
const menuItems: ContextMenuItem[] = BOOKMARKS.map((bookmark) => ({
label: `Go to ${bookmark.label} (${bookmark.path})`,
click: () => this.goHistory(bookmark.path),
}));
ContextMenuModel.showContextMenu(menuItems, e);
},
};
Expand Down
1 change: 0 additions & 1 deletion frontend/app/view/waveai/waveai.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ const ChatWindow = memo(
const handleNewMessage = useCallback(
throttle(100, (messagesLen: number) => {
if (osRef.current?.osInstance()) {
console.log("handleNewMessage", messagesLen, isUserScrolling.current);
const { viewport } = osRef.current.osInstance().elements();
if (prevMessagesLenRef.current !== messagesLen || !isUserScrolling.current) {
viewport.scrollTo({
Expand Down
1 change: 1 addition & 0 deletions frontend/types/gotypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ declare global {
"conn:askbeforewshinstall"?: boolean;
"conn:overrideconfig"?: boolean;
"conn:wshpath"?: string;
"conn:shellpath"?: string;
"display:hidden"?: boolean;
"display:order"?: number;
"term:*"?: boolean;
Expand Down
8 changes: 4 additions & 4 deletions pkg/blockcontroller/blockcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,18 +369,18 @@ func (bc *BlockController) setupAndStartShellProcess(rc *RunShellOpts, blockMeta
cmdOpts.Env[wshutil.WaveJwtTokenVarName] = jwtStr
}
if !conn.WshEnabled.Load() {
shellProc, err = shellexec.StartRemoteShellProcNoWsh(rc.TermSize, cmdStr, cmdOpts, conn)
shellProc, err = shellexec.StartRemoteShellProcNoWsh(ctx, rc.TermSize, cmdStr, cmdOpts, conn)
if err != nil {
return nil, err
}
} else {
shellProc, err = shellexec.StartRemoteShellProc(rc.TermSize, cmdStr, cmdOpts, conn)
shellProc, err = shellexec.StartRemoteShellProc(ctx, rc.TermSize, cmdStr, cmdOpts, conn)
if err != nil {
conn.SetWshError(err)
conn.WshEnabled.Store(false)
log.Printf("error starting remote shell proc with wsh: %v", err)
log.Print("attempting install without wsh")
shellProc, err = shellexec.StartRemoteShellProcNoWsh(rc.TermSize, cmdStr, cmdOpts, conn)
shellProc, err = shellexec.StartRemoteShellProcNoWsh(ctx, rc.TermSize, cmdStr, cmdOpts, conn)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -408,7 +408,7 @@ func (bc *BlockController) setupAndStartShellProcess(rc *RunShellOpts, blockMeta
if len(blockMeta.GetStringList(waveobj.MetaKey_TermLocalShellOpts)) > 0 {
cmdOpts.ShellOpts = append([]string{}, blockMeta.GetStringList(waveobj.MetaKey_TermLocalShellOpts)...)
}
shellProc, err = shellexec.StartShellProc(rc.TermSize, cmdStr, cmdOpts)
shellProc, err = shellexec.StartLocalShellProc(rc.TermSize, cmdStr, cmdOpts)
if err != nil {
return nil, err
}
Expand Down
51 changes: 40 additions & 11 deletions pkg/genconn/quote.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ package genconn
import "regexp"

var (
safePattern = regexp.MustCompile(`^[a-zA-Z0-9_/.-]+$`)

needsEscape = map[byte]bool{
'"': true,
'\\': true,
'$': true,
'`': true,
}
safePattern = regexp.MustCompile(`^[a-zA-Z0-9_/.-]+$`)
psSafePattern = regexp.MustCompile(`^[a-zA-Z0-9_.-]+$`)
)

// TODO: fish quoting is slightly different
// specifically \` will cause an inconsistency between fish and bash/zsh :/
// might need a specific fish quoting function, and an explicit fish shell detection
func HardQuote(s string) string {
if s == "" {
return "\"\""
Expand All @@ -29,10 +26,42 @@ func HardQuote(s string) string {
buf = append(buf, '"')

for i := 0; i < len(s); i++ {
if needsEscape[s[i]] {
buf = append(buf, '\\')
switch s[i] {
case '"', '\\', '$', '`':
buf = append(buf, '\\', s[i])
case '\n':
buf = append(buf, '\\', '\n')
default:
buf = append(buf, s[i])
}
buf = append(buf, s[i])
}

buf = append(buf, '"')
return string(buf)
}

func HardQuotePowerShell(s string) string {
if s == "" {
return "\"\""
}

if psSafePattern.MatchString(s) {
return s
}

buf := make([]byte, 0, len(s)+5)
buf = append(buf, '"')

for i := 0; i < len(s); i++ {
c := s[i]
// In PowerShell, backtick (`) is the escape character
switch c {
case '"', '`', '$':
buf = append(buf, '`')
case '\n':
buf = append(buf, '`', 'n') // PowerShell uses `n for newline
}
buf = append(buf, c)
}

buf = append(buf, '"')
Expand Down
2 changes: 2 additions & 0 deletions pkg/genconn/ssh-impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package genconn
import (
"fmt"
"io"
"log"
"sync"

"golang.org/x/crypto/ssh"
Expand Down Expand Up @@ -41,6 +42,7 @@ type SSHProcessController struct {

// MakeSSHCmdClient creates a new instance of SSHCmdClient
func MakeSSHCmdClient(client *ssh.Client, cmdSpec CommandSpec) (*SSHProcessController, error) {
log.Printf("SSH-NEWSESSION (cmdclient)\n")
session, err := client.NewSession()
if err != nil {
return nil, fmt.Errorf("failed to create SSH session: %w", err)
Expand Down
Loading
Loading