feat(02-01): implement protocol types, SessionRegistry, and LabelStore

- Enrich Session with Workspace, Label, WaitingSince fields
- Protocol types: Request, Response, SessionInfo, SwitchArgs, LabelArgs
- SessionRegistry with WaitingSince transition tracking
- LabelStore with JSON file persistence
This commit is contained in:
Pierre Martin
2026-03-23 17:43:12 +01:00
parent c9a28df3dc
commit 5315e88494
3 changed files with 196 additions and 7 deletions

43
protocol.go Normal file
View File

@@ -0,0 +1,43 @@
package main
import (
"encoding/json"
"time"
)
// Request is the JSON message sent by a client to the daemon over the Unix socket.
type Request struct {
Action string `json:"action"` // "list", "switch", "label", "stop"
Args json.RawMessage `json:"args,omitempty"`
}
// Response is the JSON message sent back by the daemon.
type Response struct {
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
Sessions []SessionInfo `json:"sessions,omitempty"`
}
// SessionInfo is the wire format for a session in IPC responses.
type SessionInfo struct {
PID int `json:"pid"`
SessionID string `json:"session_id"`
Cwd string `json:"cwd"`
GitBranch string `json:"git_branch"`
State string `json:"state"`
Preview string `json:"preview"`
Workspace string `json:"workspace"`
Label string `json:"label,omitempty"`
WaitingSince *time.Time `json:"waiting_since,omitempty"`
}
// SwitchArgs carries the query for workspace switching.
type SwitchArgs struct {
Query string `json:"query"`
}
// LabelArgs carries the session ID and label for the label action.
type LabelArgs struct {
SessionID string `json:"session_id"`
Label string `json:"label"`
}