Skip to content

Commit 7582cc7

Browse files
dxllivcursoragent
andcommitted
fix(tui): hide npm in SRC column until package is materialized
Show — for catalog entries without a known source instead of assuming npm, since install method is chosen only at save time. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent ef8f079 commit 7582cc7

3 files changed

Lines changed: 89 additions & 8 deletions

File tree

go/tui/helpers.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,21 @@ func kv(label, value string) string {
794794
// keep rand used (for future sparkline noise simulation)
795795
var _ = rand.Float64
796796

797+
// catalogSourceLabel returns the SRC column value for a catalog row.
798+
// It reflects only a known, materialized source — not an assumed install method.
799+
func catalogSourceLabel(item bridge.CatalogEntry, localGitDirs map[string]bool) string {
800+
if item.LocalSource {
801+
if localGitDirs[item.ShortName] {
802+
return "git"
803+
}
804+
return "dev"
805+
}
806+
if item.Installed && item.InPackageJson {
807+
return "npm"
808+
}
809+
return "—"
810+
}
811+
797812
func (m *TuiModel) getInstallMethods(pkg *bridge.CatalogEntry) []InstallMethod {
798813
var methods []InstallMethod
799814

go/tui/helpers_test.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package tui
2+
3+
import (
4+
"testing"
5+
6+
"owd-cli/bridge"
7+
)
8+
9+
func TestCatalogSourceLabel(t *testing.T) {
10+
tests := []struct {
11+
name string
12+
item bridge.CatalogEntry
13+
localGitDirs map[string]bool
14+
want string
15+
}{
16+
{
17+
name: "not installed",
18+
item: bridge.CatalogEntry{
19+
ShortName: "module-foo",
20+
Installed: false,
21+
},
22+
want: "—",
23+
},
24+
{
25+
name: "installed via npm",
26+
item: bridge.CatalogEntry{
27+
ShortName: "module-foo",
28+
Installed: true,
29+
InPackageJson: true,
30+
},
31+
want: "npm",
32+
},
33+
{
34+
name: "local source with git",
35+
item: bridge.CatalogEntry{
36+
ShortName: "module-foo",
37+
Installed: true,
38+
LocalSource: true,
39+
},
40+
localGitDirs: map[string]bool{"module-foo": true},
41+
want: "git",
42+
},
43+
{
44+
name: "local source without git",
45+
item: bridge.CatalogEntry{
46+
ShortName: "module-foo",
47+
Installed: true,
48+
LocalSource: true,
49+
},
50+
localGitDirs: map[string]bool{},
51+
want: "dev",
52+
},
53+
{
54+
name: "installed in config but missing folder",
55+
item: bridge.CatalogEntry{
56+
ShortName: "module-foo",
57+
Installed: true,
58+
LocalSource: false,
59+
InPackageJson: false,
60+
},
61+
want: "—",
62+
},
63+
}
64+
65+
for _, tt := range tests {
66+
t.Run(tt.name, func(t *testing.T) {
67+
got := catalogSourceLabel(tt.item, tt.localGitDirs)
68+
if got != tt.want {
69+
t.Fatalf("catalogSourceLabel() = %q, want %q", got, tt.want)
70+
}
71+
})
72+
}
73+
}

go/tui/view.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,7 @@ func (m *TuiModel) renderCatalogRow(item bridge.CatalogEntry, selected bool, w,
392392
}
393393

394394
// ── SRC (npm / git / dev) ────────────────────────────────────
395-
source := "npm"
396-
if item.LocalSource {
397-
if m.localGitDirs[item.ShortName] {
398-
source = "git"
399-
} else {
400-
source = "dev"
401-
}
402-
}
395+
source := catalogSourceLabel(item, m.localGitDirs)
403396

404397
// ── SYNC column: git changes + update indicators ─────────────
405398
var syncParts []string

0 commit comments

Comments
 (0)