Some checks failed
CI / check (push) Failing after 17m48s
- Remove 'index 0000000..1111111' lines that made patches appear as new files - Fix hunk line counts in several patches - Add missing leading spaces to blank context lines - Temporarily disable statusline optimization patch (needs regenerating) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
136 lines
3.4 KiB
Diff
136 lines
3.4 KiB
Diff
diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go
|
|
--- a/internal/cmd/statusline.go
|
|
+++ b/internal/cmd/statusline.go
|
|
@@ -6,6 +6,7 @@ import (
|
|
"os"
|
|
"path/filepath"
|
|
"sort"
|
|
"strings"
|
|
+ "time"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/steveyegge/gastown/internal/beads"
|
|
@@ -15,6 +16,43 @@ import (
|
|
"github.com/steveyegge/gastown/internal/workspace"
|
|
)
|
|
|
|
+// statusLineCacheTTL is how long cached status output remains valid.
|
|
+const statusLineCacheTTL = 10 * time.Second
|
|
+
|
|
+// statusLineCachePath returns the cache file path for a session.
|
|
+func statusLineCachePath(session string) string {
|
|
+ return filepath.Join(os.TempDir(), fmt.Sprintf("gt-status-%s", session))
|
|
+}
|
|
+
|
|
+// getStatusLineCache returns cached status if fresh, empty string otherwise.
|
|
+func getStatusLineCache(session string) string {
|
|
+ path := statusLineCachePath(session)
|
|
+ info, err := os.Stat(path)
|
|
+ if err != nil {
|
|
+ return ""
|
|
+ }
|
|
+ if time.Since(info.ModTime()) > statusLineCacheTTL {
|
|
+ return ""
|
|
+ }
|
|
+ data, err := os.ReadFile(path)
|
|
+ if err != nil {
|
|
+ return ""
|
|
+ }
|
|
+ return string(data)
|
|
+}
|
|
+
|
|
+// setStatusLineCache writes status to cache file.
|
|
+func setStatusLineCache(session, status string) {
|
|
+ path := statusLineCachePath(session)
|
|
+ _ = os.WriteFile(path, []byte(status), 0644)
|
|
+}
|
|
+
|
|
var (
|
|
statusLineSession string
|
|
)
|
|
@@ -32,6 +70,20 @@ func init() {
|
|
func runStatusLine(cmd *cobra.Command, args []string) error {
|
|
t := tmux.NewTmux()
|
|
|
|
+ // Optimization: skip expensive beads queries for detached sessions
|
|
+ if statusLineSession != "" {
|
|
+ if !t.IsSessionAttached(statusLineSession) {
|
|
+ fmt.Print("○ |")
|
|
+ return nil
|
|
+ }
|
|
+ // Check cache for attached sessions too
|
|
+ if cached := getStatusLineCache(statusLineSession); cached != "" {
|
|
+ fmt.Print(cached)
|
|
+ return nil
|
|
+ }
|
|
+ }
|
|
+
|
|
// Get session environment
|
|
var rigName, polecat, crew, issue, role string
|
|
|
|
@@ -149,7 +201,12 @@ func runWorkerStatusLine(t *tmux.Tmux, session, rigName, polecat, crew, issue st
|
|
|
|
// Output
|
|
if len(parts) > 0 {
|
|
- fmt.Print(strings.Join(parts, " | ") + " |")
|
|
+ output := strings.Join(parts, " | ") + " |"
|
|
+ if statusLineSession != "" {
|
|
+ setStatusLineCache(statusLineSession, output)
|
|
+ }
|
|
+ fmt.Print(output)
|
|
}
|
|
|
|
return nil
|
|
@@ -389,7 +446,12 @@ func runMayorStatusLine(t *tmux.Tmux) error {
|
|
}
|
|
}
|
|
|
|
- fmt.Print(strings.Join(parts, " | ") + " |")
|
|
+ output := strings.Join(parts, " | ") + " |"
|
|
+ if statusLineSession != "" {
|
|
+ setStatusLineCache(statusLineSession, output)
|
|
+ }
|
|
+ fmt.Print(output)
|
|
return nil
|
|
}
|
|
|
|
@@ -458,7 +520,12 @@ func runDeaconStatusLine(t *tmux.Tmux) error {
|
|
}
|
|
}
|
|
|
|
- fmt.Print(strings.Join(parts, " | ") + " |")
|
|
+ output := strings.Join(parts, " | ") + " |"
|
|
+ if statusLineSession != "" {
|
|
+ setStatusLineCache(statusLineSession, output)
|
|
+ }
|
|
+ fmt.Print(output)
|
|
return nil
|
|
}
|
|
|
|
@@ -526,7 +593,12 @@ func runWitnessStatusLine(t *tmux.Tmux, rigName string) error {
|
|
}
|
|
}
|
|
|
|
- fmt.Print(strings.Join(parts, " | ") + " |")
|
|
+ output := strings.Join(parts, " | ") + " |"
|
|
+ if statusLineSession != "" {
|
|
+ setStatusLineCache(statusLineSession, output)
|
|
+ }
|
|
+ fmt.Print(output)
|
|
return nil
|
|
}
|
|
|
|
@@ -617,7 +689,12 @@ func runRefineryStatusLine(t *tmux.Tmux, rigName string) error {
|
|
}
|
|
}
|
|
|
|
- fmt.Print(strings.Join(parts, " | ") + " |")
|
|
+ output := strings.Join(parts, " | ") + " |"
|
|
+ if statusLineSession != "" {
|
|
+ setStatusLineCache(statusLineSession, output)
|
|
+ }
|
|
+ fmt.Print(output)
|
|
return nil
|
|
}
|
|
|