mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
Fix up resize input format
This commit is contained in:
parent
0b97181a04
commit
d64abdafad
1 changed files with 17 additions and 17 deletions
|
|
@ -128,8 +128,8 @@ func (s *Server) handleCreateSession(w http.ResponseWriter, r *http.Request) {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Command []string `json:"command"` // Rust API format
|
Command []string `json:"command"` // Rust API format
|
||||||
WorkingDir string `json:"workingDir"` // Rust API format
|
WorkingDir string `json:"workingDir"` // Rust API format
|
||||||
Width int `json:"width"` // Terminal width
|
Cols int `json:"cols"` // Terminal columns
|
||||||
Height int `json:"height"` // Terminal height
|
Rows int `json:"rows"` // Terminal rows
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
|
|
@ -146,13 +146,13 @@ func (s *Server) handleCreateSession(w http.ResponseWriter, r *http.Request) {
|
||||||
cwd := req.WorkingDir
|
cwd := req.WorkingDir
|
||||||
|
|
||||||
// Set default terminal dimensions if not provided
|
// Set default terminal dimensions if not provided
|
||||||
width := req.Width
|
cols := req.Cols
|
||||||
if width <= 0 {
|
if cols <= 0 {
|
||||||
width = 120 // Better default for modern terminals
|
cols = 120 // Better default for modern terminals
|
||||||
}
|
}
|
||||||
height := req.Height
|
rows := req.Rows
|
||||||
if height <= 0 {
|
if rows <= 0 {
|
||||||
height = 30 // Better default for modern terminals
|
rows = 30 // Better default for modern terminals
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expand ~ in working directory
|
// Expand ~ in working directory
|
||||||
|
|
@ -173,8 +173,8 @@ func (s *Server) handleCreateSession(w http.ResponseWriter, r *http.Request) {
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
Cmdline: cmdline,
|
Cmdline: cmdline,
|
||||||
Cwd: cwd,
|
Cwd: cwd,
|
||||||
Width: width,
|
Width: cols,
|
||||||
Height: height,
|
Height: rows,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|
@ -385,8 +385,8 @@ func (s *Server) handleResizeSession(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var req struct {
|
var req struct {
|
||||||
Width int `json:"width"`
|
Cols int `json:"cols"`
|
||||||
Height int `json:"height"`
|
Rows int `json:"rows"`
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
|
|
@ -394,12 +394,12 @@ func (s *Server) handleResizeSession(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Width <= 0 || req.Height <= 0 {
|
if req.Cols <= 0 || req.Rows <= 0 {
|
||||||
http.Error(w, "Width and height must be positive integers", http.StatusBadRequest)
|
http.Error(w, "Cols and rows must be positive integers", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := sess.Resize(req.Width, req.Height); err != nil {
|
if err := sess.Resize(req.Cols, req.Rows); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -408,8 +408,8 @@ func (s *Server) handleResizeSession(w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||||
"success": true,
|
"success": true,
|
||||||
"message": "Session resized successfully",
|
"message": "Session resized successfully",
|
||||||
"width": req.Width,
|
"cols": req.Cols,
|
||||||
"height": req.Height,
|
"rows": req.Rows,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue