fix: make patch list registry-only

This commit is contained in:
Nikhil Sonti
2026-05-02 14:04:52 -07:00
parent ecc6bac070
commit d28526fffe

View File

@@ -3,7 +3,6 @@ package cmd
import (
"fmt"
"github.com/browseros-ai/BrowserOS/packages/browseros/tools/patch/internal/engine"
"github.com/browseros-ai/BrowserOS/packages/browseros/tools/patch/internal/ui"
"github.com/spf13/cobra"
)
@@ -13,7 +12,7 @@ func init() {
Use: "list",
Aliases: []string{"ls"},
Annotations: map[string]string{"group": "Workspace:"},
Short: "List registered workspaces and their sync state",
Short: "List registered workspaces",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if len(appState.Registry.Workspaces) == 0 {
@@ -21,27 +20,15 @@ func init() {
fmt.Println("No workspaces registered. Run `browseros-patch add <name> <path>`.")
})
}
info, err := repoInfo()
if err != nil {
return err
}
rows := make([][]string, 0, len(appState.Registry.Workspaces))
statuses := make([]*engine.WorkspaceStatus, 0, len(appState.Registry.Workspaces))
for _, ws := range appState.Registry.Workspaces {
status, err := engine.InspectWorkspace(cmd.Context(), ws, info)
if err != nil {
return err
}
statuses = append(statuses, status)
rows = append(rows, []string{
ws.Name,
status.SyncState,
fmt.Sprintf("%d/%d/%d", len(status.UpToDate), len(status.NeedsUpdate), len(status.Orphaned)),
ws.Path,
})
}
return renderResult(map[string]any{"workspaces": statuses}, func() {
fmt.Println(ui.RenderTable([]string{"NAME", "STATE", "PATCHES", "PATH"}, rows))
return renderResult(map[string]any{"workspaces": appState.Registry.Workspaces}, func() {
fmt.Println(ui.RenderTable([]string{"NAME", "PATH"}, rows))
})
},
}