detached 025a25b

Merge pull request #158 from bnema/fix/ignore-manifestless-extension-dirs

fix(extensions): ignore directories without manifests
commit
025a25b5f7e58fbdc2775c23103ff40cebd2b4c4
author
bnema · · 2026-08-28 18:45 UTC
committer
GitHub · · 2026-08-28 18:45 UTC
merge of
c3476a8 + 5acf657 · diff against the first parent
signature
GPG UnverifiedB5690EEEBB952194 The key is unknown
refs
tag: v0.25.1
2 files · +37 -1
M packages/agent/extensions/manager.go +5 -1
@@ -289,11 +289,15 @@ func (m *Manager) Discover(ctx context.Context) []error {
289289 if !e.IsDir() || strings.HasPrefix(e.Name(), ".") {
290290 continue
291291 }
292+ extDir := filepath.Join(dir, e.Name())
293+ if _, err := os.Stat(filepath.Join(extDir, "extension.json")); errors.Is(err, os.ErrNotExist) {
294+ continue
295+ }
292296 if seenDirs[e.Name()] {
293297 continue // higher-priority location already queued
294298 }
295299 seenDirs[e.Name()] = true
296- jobs = append(jobs, loadJob{dir: filepath.Join(dir, e.Name())})
300+ jobs = append(jobs, loadJob{dir: extDir})
297301 }
298302 }
299303
@@ -289,11 +289,15 @@ func (m *Manager) Discover(ctx context.Context) []error {
289 if !e.IsDir() || strings.HasPrefix(e.Name(), ".") {289 if !e.IsDir() || strings.HasPrefix(e.Name(), ".") {
290 continue290 continue
291 }291 }
292+ extDir := filepath.Join(dir, e.Name())
293+ if _, err := os.Stat(filepath.Join(extDir, "extension.json")); errors.Is(err, os.ErrNotExist) {
294+ continue
295+ }
292 if seenDirs[e.Name()] {296 if seenDirs[e.Name()] {
293 continue // higher-priority location already queued297 continue // higher-priority location already queued
294 }298 }
295 seenDirs[e.Name()] = true299 seenDirs[e.Name()] = true
296- jobs = append(jobs, loadJob{dir: filepath.Join(dir, e.Name())})300+ jobs = append(jobs, loadJob{dir: extDir})
297 }301 }
298 }302 }
299 303
M packages/agent/extensions/manager_test.go +32 -0
@@ -103,6 +103,38 @@ func (s *stubHooks) ClearExtensionChrome(name string) {
103103 s.chromeClears = append(s.chromeClears, name)
104104 }
105105
106+func TestDiscoverIgnoresDirectoriesWithoutManifest(t *testing.T) {
107+ home := t.TempDir()
108+ cwd := t.TempDir()
109+
110+ orphanedDataDir := filepath.Join(cwd, ".zut", "extensions", "example", "projects")
111+ if err := os.MkdirAll(orphanedDataDir, 0o700); err != nil {
112+ t.Fatal(err)
113+ }
114+ if err := os.WriteFile(filepath.Join(orphanedDataDir, "state.json"), []byte(`{}`), 0o600); err != nil {
115+ t.Fatal(err)
116+ }
117+
118+ globalExtDir := filepath.Join(home, "extensions", "example")
119+ if err := os.MkdirAll(globalExtDir, 0o755); err != nil {
120+ t.Fatal(err)
121+ }
122+ if err := os.WriteFile(filepath.Join(globalExtDir, "extension.json"), []byte(`{"name":"example"}`), 0o644); err != nil {
123+ t.Fatal(err)
124+ }
125+ if err := os.WriteFile(filepath.Join(globalExtDir, "theme.json"), []byte(`{"name":"Example"}`), 0o644); err != nil {
126+ t.Fatal(err)
127+ }
128+
129+ mgr := New(home, cwd, "0.0.0-test", "", "", nil)
130+ if errs := mgr.Discover(context.Background()); len(errs) > 0 {
131+ t.Fatalf("discover errors = %v, want none", errs)
132+ }
133+ if _, ok := mgr.ext["example"]; !ok {
134+ t.Fatal("global extension was shadowed by a project directory without a manifest")
135+ }
136+}
137+
106138 // writeMockExtension creates a minimal extension on disk that uses a
107139 // shell script (or batch file on windows) to drive the protocol. The
108140 // script reads commands from stdin and emits hard-coded responses,
@@ -103,6 +103,38 @@ func (s *stubHooks) ClearExtensionChrome(name string) {
103 s.chromeClears = append(s.chromeClears, name)103 s.chromeClears = append(s.chromeClears, name)
104 }104 }
105 105
106+func TestDiscoverIgnoresDirectoriesWithoutManifest(t *testing.T) {
107+ home := t.TempDir()
108+ cwd := t.TempDir()
109+
110+ orphanedDataDir := filepath.Join(cwd, ".zut", "extensions", "example", "projects")
111+ if err := os.MkdirAll(orphanedDataDir, 0o700); err != nil {
112+ t.Fatal(err)
113+ }
114+ if err := os.WriteFile(filepath.Join(orphanedDataDir, "state.json"), []byte(`{}`), 0o600); err != nil {
115+ t.Fatal(err)
116+ }
117+
118+ globalExtDir := filepath.Join(home, "extensions", "example")
119+ if err := os.MkdirAll(globalExtDir, 0o755); err != nil {
120+ t.Fatal(err)
121+ }
122+ if err := os.WriteFile(filepath.Join(globalExtDir, "extension.json"), []byte(`{"name":"example"}`), 0o644); err != nil {
123+ t.Fatal(err)
124+ }
125+ if err := os.WriteFile(filepath.Join(globalExtDir, "theme.json"), []byte(`{"name":"Example"}`), 0o644); err != nil {
126+ t.Fatal(err)
127+ }
128+
129+ mgr := New(home, cwd, "0.0.0-test", "", "", nil)
130+ if errs := mgr.Discover(context.Background()); len(errs) > 0 {
131+ t.Fatalf("discover errors = %v, want none", errs)
132+ }
133+ if _, ok := mgr.ext["example"]; !ok {
134+ t.Fatal("global extension was shadowed by a project directory without a manifest")
135+ }
136+}
137+
106 // writeMockExtension creates a minimal extension on disk that uses a138 // writeMockExtension creates a minimal extension on disk that uses a
107 // shell script (or batch file on windows) to drive the protocol. The139 // shell script (or batch file on windows) to drive the protocol. The
108 // script reads commands from stdin and emits hard-coded responses,140 // script reads commands from stdin and emits hard-coded responses,

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close