Skip to content

Commit 6f05306

Browse files
committed
fix: restore desktop icon visibility and plugin menu fallback
1 parent 6884e9f commit 6f05306

4 files changed

Lines changed: 42 additions & 10 deletions

File tree

retrotui/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"action": AppAction.DESKTOP_ICON_MANAGER,
7979
"art": ["\u250c\u2500\u2500\u2510", "\u2502DT\u2502", "\u2514\u2500\u2500\u2518"],
8080
"category": "Apps",
81-
"hide_key": "icons",
81+
"hide_key": "desktop",
8282
"position_key": "Icons",
8383
},
8484
{
@@ -121,7 +121,7 @@
121121
"action": AppAction.DESKTOP_ICON_MANAGER,
122122
"art": ["+--+", "|DT|", "+--+"],
123123
"category": "Apps",
124-
"hide_key": "icons",
124+
"hide_key": "desktop",
125125
"position_key": "Icons",
126126
},
127127
{

retrotui/plugins/loader.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ def _repo_examples_plugin_dir():
4444
return str(Path(__file__).resolve().parents[2] / "examples" / "plugins")
4545

4646

47+
def _cwd_examples_plugin_dir():
48+
"""Return cwd-local examples/plugins path when available."""
49+
return str((Path.cwd() / "examples" / "plugins").resolve())
50+
51+
4752
def _iter_plugin_dirs():
4853
"""Yield plugin directories in discovery priority order."""
4954
seen = set()
@@ -81,11 +86,11 @@ def _iter_plugin_dirs():
8186
# built-in plugins visible out of the box. User plugins still win on
8287
# duplicate ids because primary is yielded first.
8388
if primary and os.path.normcase(os.path.normpath(primary)) == os.path.normcase(os.path.normpath(_DEFAULT_PLUGIN_DIR)):
84-
bundled = _repo_examples_plugin_dir()
85-
norm = os.path.normcase(os.path.normpath(bundled))
86-
if bundled and norm not in seen:
87-
seen.add(norm)
88-
yield bundled
89+
for candidate in (_repo_examples_plugin_dir(), _cwd_examples_plugin_dir()):
90+
norm = os.path.normcase(os.path.normpath(candidate))
91+
if candidate and norm not in seen:
92+
seen.add(norm)
93+
yield candidate
8994

9095

9196
def discover_plugins():

tests/test_constants_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_desktop_icon_points_to_desktop_icon_manager(self):
5959
ascii_desktop.get("action"),
6060
self.constants.AppAction.DESKTOP_ICON_MANAGER,
6161
)
62-
self.assertEqual(unicode_desktop.get("hide_key"), "icons")
62+
self.assertEqual(unicode_desktop.get("hide_key"), "desktop")
6363
self.assertEqual(unicode_desktop.get("position_key"), "Icons")
6464

6565
def test_video_extensions_include_common_formats(self):

tests/test_plugin_loader_unittest.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def test_discover_plugins_uses_repo_examples_fallback_when_default_missing(self)
7373
self.loader._DEFAULT_PLUGIN_DIR = str(missing_default)
7474
self.loader.PLUGIN_DIR = str(missing_default)
7575

76-
with mock.patch.object(self.loader, "_repo_examples_plugin_dir", return_value=str(examples)):
76+
with (
77+
mock.patch.object(self.loader, "_repo_examples_plugin_dir", return_value=str(examples)),
78+
mock.patch.object(self.loader, "_cwd_examples_plugin_dir", return_value=str(root / "nope")),
79+
):
7780
manifests = self.loader.discover_plugins()
7881

7982
self.assertEqual(len(manifests), 1)
@@ -92,12 +95,36 @@ def test_discover_plugins_uses_repo_examples_when_default_exists_but_empty(self)
9295
self.loader._DEFAULT_PLUGIN_DIR = str(empty_default)
9396
self.loader.PLUGIN_DIR = str(empty_default)
9497

95-
with mock.patch.object(self.loader, "_repo_examples_plugin_dir", return_value=str(examples)):
98+
with (
99+
mock.patch.object(self.loader, "_repo_examples_plugin_dir", return_value=str(examples)),
100+
mock.patch.object(self.loader, "_cwd_examples_plugin_dir", return_value=str(root / "nope")),
101+
):
96102
manifests = self.loader.discover_plugins()
97103

98104
self.assertEqual(len(manifests), 1)
99105
self.assertEqual(manifests[0].get("plugin", {}).get("id"), "bundled")
100106

107+
def test_discover_plugins_uses_cwd_examples_fallback_when_repo_path_missing(self):
108+
tmpdir = make_repo_tmpdir(prefix="_tmp_plugin_loader_")
109+
self.addCleanup(tmpdir.cleanup)
110+
root = Path(tmpdir.name)
111+
examples = root / "examples" / "plugins"
112+
examples.mkdir(parents=True)
113+
self._create_plugin(examples, "cwd-bundled")
114+
115+
missing_default = root / "missing-default"
116+
self.loader._DEFAULT_PLUGIN_DIR = str(missing_default)
117+
self.loader.PLUGIN_DIR = str(missing_default)
118+
119+
with (
120+
mock.patch.object(self.loader, "_repo_examples_plugin_dir", return_value=str(root / "nope")),
121+
mock.patch.object(self.loader, "_cwd_examples_plugin_dir", return_value=str(examples)),
122+
):
123+
manifests = self.loader.discover_plugins()
124+
125+
self.assertEqual(len(manifests), 1)
126+
self.assertEqual(manifests[0].get("plugin", {}).get("id"), "cwd-bundled")
127+
101128

102129
if __name__ == "__main__":
103130
unittest.main()

0 commit comments

Comments
 (0)