From 3acf9d2796ab3fc91da81b0d6e8dab5f1981057b Mon Sep 17 00:00:00 2001 From: rust Date: Sat, 31 Jan 2026 13:59:11 -0800 Subject: [PATCH] fix(gastown): regenerate statusline optimization patch with correct line numbers The patch file had malformed hunk headers with incorrect line numbers and counts, causing it to fail to apply against the locked gastown rev (177094a2). This was NOT a flake.lock issue - gastown source was properly locked. Changes: - Regenerated patch from scratch against locked gastown revision - Re-enabled the patch in default.nix (was commented out with TODO) - Updated comment to accurately describe the optimization The optimization skips expensive beads queries for detached tmux sessions and caches status line output with a 10-second TTL, reducing Dolt CPU usage from ~70% to ~20%. Closes: hq-0h1p9m Co-Authored-By: Claude Opus 4.5 --- home/roles/development/default.nix | 6 +++--- .../gastown-statusline-optimization.patch | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/home/roles/development/default.nix b/home/roles/development/default.nix index ccad3ca..14ff066 100644 --- a/home/roles/development/default.nix +++ b/home/roles/development/default.nix @@ -55,9 +55,9 @@ let ./gastown-fix-town-root-detection.patch # Fix copyDir to handle symlinks (broken symlinks cause "no such file" errors) ./gastown-fix-copydir-symlinks.patch - # TODO: Statusline optimization patch needs regenerating against current gastown source - # Reduces Dolt CPU from ~70% to ~20% by avoiding beads queries for sessions nobody is watching - # ./gastown-statusline-optimization.patch + # Statusline optimization: skip expensive beads queries for detached sessions + # Reduces Dolt CPU from ~70% to ~20% by caching and early-exit + ./gastown-statusline-optimization.patch ]; meta = with lib; { diff --git a/home/roles/development/gastown-statusline-optimization.patch b/home/roles/development/gastown-statusline-optimization.patch index b74f7ca..c981f71 100644 --- a/home/roles/development/gastown-statusline-optimization.patch +++ b/home/roles/development/gastown-statusline-optimization.patch @@ -1,8 +1,8 @@ diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go +index 2edf1be8..00253eea 100644 --- a/internal/cmd/statusline.go +++ b/internal/cmd/statusline.go @@ -6,6 +6,7 @@ import ( - "os" "path/filepath" "sort" "strings" @@ -10,10 +10,10 @@ diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go "github.com/spf13/cobra" "github.com/steveyegge/gastown/internal/beads" -@@ -15,6 +16,43 @@ import ( +@@ -14,6 +15,37 @@ import ( + "github.com/steveyegge/gastown/internal/tmux" "github.com/steveyegge/gastown/internal/workspace" ) - +// statusLineCacheTTL is how long cached status output remains valid. +const statusLineCacheTTL = 10 * time.Second + @@ -45,10 +45,10 @@ diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go + _ = os.WriteFile(path, []byte(status), 0644) +} + + var ( statusLineSession string - ) -@@ -32,6 +70,20 @@ func init() { +@@ -34,6 +66,19 @@ func init() { func runStatusLine(cmd *cobra.Command, args []string) error { t := tmux.NewTmux() @@ -68,7 +68,7 @@ diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go // 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 +@@ -150,7 +195,11 @@ func runWorkerStatusLine(t *tmux.Tmux, session, rigName, polecat, crew, issue st // Output if len(parts) > 0 { @@ -81,7 +81,7 @@ diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go } return nil -@@ -389,7 +446,12 @@ func runMayorStatusLine(t *tmux.Tmux) error { +@@ -389,7 +438,11 @@ func runMayorStatusLine(t *tmux.Tmux) error { } } @@ -94,7 +94,7 @@ diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go return nil } -@@ -458,7 +520,12 @@ func runDeaconStatusLine(t *tmux.Tmux) error { +@@ -458,7 +511,11 @@ func runDeaconStatusLine(t *tmux.Tmux) error { } } @@ -107,7 +107,7 @@ diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go return nil } -@@ -526,7 +593,12 @@ func runWitnessStatusLine(t *tmux.Tmux, rigName string) error { +@@ -526,7 +583,11 @@ func runWitnessStatusLine(t *tmux.Tmux, rigName string) error { } } @@ -120,7 +120,7 @@ diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go return nil } -@@ -617,7 +689,12 @@ func runRefineryStatusLine(t *tmux.Tmux, rigName string) error { +@@ -617,7 +678,11 @@ func runRefineryStatusLine(t *tmux.Tmux, rigName string) error { } }