fix session with split screens

This commit is contained in:
2026-05-24 06:37:59 +00:00
parent 330cf01985
commit 45e18b5423
9 changed files with 760 additions and 224 deletions
+7 -9
View File
@@ -57,19 +57,17 @@ func handleStaticJS(w http.ResponseWriter, r *http.Request) {
w.Write(data)
}
// handleIndex: clean URL, always creates a fresh session.
// The session-specific /s/<id> URL is available in the toolbar for sharing.
// handleIndex: always creates a fresh workspace and redirects to its stable URL.
// PTY sessions are started lazily by the frontend via WebSocket connections.
func handleIndex(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
id := randHex(16)
getOrCreate(id)
serveTerminalPage(w, id, isAuthed(r))
http.Redirect(w, r, "/s/"+randHex(16), http.StatusFound)
}
// handleShell: reconnects to a specific session by ID.
// handleShell: serves the terminal page for an existing (or new) workspace ID.
func handleShell(w http.ResponseWriter, r *http.Request) {
id := strings.TrimPrefix(r.URL.Path, "/s/")
if !validID(id) {
@@ -79,14 +77,14 @@ func handleShell(w http.ResponseWriter, r *http.Request) {
serveTerminalPage(w, id, isAuthed(r))
}
func serveTerminalPage(w http.ResponseWriter, id string, authed bool) {
func serveTerminalPage(w http.ResponseWriter, workspaceID string, authed bool) {
authedStr := "false"
if authed {
authedStr = "true"
}
html := strings.NewReplacer(
"[[SESSION_ID]]", id,
"[[AUTHED]]", authedStr,
"[[WORKSPACE_ID]]", workspaceID,
"[[AUTHED]]", authedStr,
).Replace(shellPageHTML)
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Write([]byte(html))