diff --git a/home/roles/development/default.nix b/home/roles/development/default.nix index 96bfa97..d1641d6 100644 --- a/home/roles/development/default.nix +++ b/home/roles/development/default.nix @@ -122,6 +122,119 @@ let } if entry.IsDir() {' + + # Statusline optimization: skip detached sessions and cache results + # Reduces Dolt CPU from ~70% to ~20% by avoiding beads queries for sessions nobody is watching + # Cache functions already exist in upstream, we just add the early-return + cache writes + # See: https://github.com/steveyegge/gastown/issues/TBD + substituteInPlace internal/cmd/statusline.go \ + --replace-fail \ + 'func runStatusLine(cmd *cobra.Command, args []string) error { + t := tmux.NewTmux() + + // Get session environment' \ + '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' \ + --replace-fail \ + '// Output + if len(parts) > 0 { + fmt.Print(strings.Join(parts, " | ") + " |") + } + + return nil +} + +// runMayorStatusLine' \ + '// Output + if len(parts) > 0 { + output := strings.Join(parts, " | ") + " |" + if statusLineSession != "" { + setStatusLineCache(statusLineSession, output) + } + fmt.Print(output) + } + + return nil +} + +// runMayorStatusLine' \ + --replace-fail \ + 'fmt.Print(strings.Join(parts, " | ") + " |") + return nil +} + +// runDeaconStatusLine outputs status for the deacon session.' \ + 'output := strings.Join(parts, " | ") + " |" + if statusLineSession != "" { + setStatusLineCache(statusLineSession, output) + } + fmt.Print(output) + return nil +} + +// runDeaconStatusLine outputs status for the deacon session.' \ + --replace-fail \ + 'fmt.Print(strings.Join(parts, " | ") + " |") + return nil +} + +// runWitnessStatusLine outputs status for a witness session. +// Shows: crew count, hook or mail preview' \ + 'output := strings.Join(parts, " | ") + " |" + if statusLineSession != "" { + setStatusLineCache(statusLineSession, output) + } + fmt.Print(output) + return nil +} + +// runWitnessStatusLine outputs status for a witness session. +// Shows: crew count, hook or mail preview' \ + --replace-fail \ + 'fmt.Print(strings.Join(parts, " | ") + " |") + return nil +} + +// runRefineryStatusLine outputs status for a refinery session.' \ + 'output := strings.Join(parts, " | ") + " |" + if statusLineSession != "" { + setStatusLineCache(statusLineSession, output) + } + fmt.Print(output) + return nil +} + +// runRefineryStatusLine outputs status for a refinery session.' \ + --replace-fail \ + 'fmt.Print(strings.Join(parts, " | ") + " |") + return nil +} + +// isSessionWorking detects' \ + 'output := strings.Join(parts, " | ") + " |" + if statusLineSession != "" { + setStatusLineCache(statusLineSession, output) + } + fmt.Print(output) + return nil +} + +// isSessionWorking detects' ''; meta = with lib; {