refactor(webui): separate presentation views and expand component gallery (#6179)
* refactor(webui): organize shared components with an internal gallery * refactor(webui): decouple views and expand component gallery * fix(docker): include channel sources in WebUI build * refactor(webui): cover all channel interfaces in gallery * docs(webui): remove manual paragraph wrapping
This commit is contained in:
1 parent
db804ef94a
commit
30e43aec82
109 files changed
+7874
-3459
No files matched your search
@@ -0,0 +1,70 @@
|
||||
"""Export channel setup contracts for the gateway-free component gallery."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[4]
|
||||
sys.path.insert(0, str(REPO_ROOT))
|
||||
|
||||
def render_fixtures() -> str:
|
||||
from nanobot.channels.registry import discover_plugins
|
||||
|
||||
plugins = discover_plugins()
|
||||
lines = [
|
||||
"// Generated by generate_channel_fixtures.py from channel setup contracts.",
|
||||
'import type { NanobotFeatureInfo } from "@/lib/types";',
|
||||
"",
|
||||
"export const channelFeatures: Record<string, NanobotFeatureInfo> = {",
|
||||
]
|
||||
for directory in sorted((REPO_ROOT / "nanobot/channels").iterdir()):
|
||||
entries = [directory / "webui" / name for name in ("index.ts", "index.tsx")]
|
||||
if not any(entry.is_file() for entry in entries):
|
||||
continue
|
||||
plugin = plugins[directory.name]
|
||||
assert plugin.setup is not None
|
||||
feature = {
|
||||
"name": plugin.name,
|
||||
"display_name": plugin.display_name,
|
||||
"webui": plugin.webui,
|
||||
"type": "channel",
|
||||
"enabled": False,
|
||||
"installed": True,
|
||||
"configured": False,
|
||||
"ready": False,
|
||||
"status": "not_enabled",
|
||||
"install_supported": True,
|
||||
"requires_restart": False,
|
||||
"runtime_status": "stopped",
|
||||
"config_values": {},
|
||||
"configured_fields": [],
|
||||
"setup": plugin.setup.to_public_dict(plugin.name),
|
||||
}
|
||||
serialized = json.dumps(feature, ensure_ascii=False, separators=(",", ": "))
|
||||
lines.append(f" {json.dumps(plugin.name)}: {serialized},")
|
||||
lines.extend(["};", ""])
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--check", action="store_true", help="Check the committed snapshot")
|
||||
args = parser.parse_args()
|
||||
target = Path(__file__).with_name("channel-fixtures.ts")
|
||||
content = render_fixtures()
|
||||
if args.check:
|
||||
if not target.is_file() or target.read_text(encoding="utf-8") != content:
|
||||
print("Channel fixtures are stale; run generate_channel_fixtures.py.", file=sys.stderr)
|
||||
return 1
|
||||
print("Channel setup fixtures match their Python contracts.")
|
||||
return 0
|
||||
target.write_text(content, encoding="utf-8", newline="\n")
|
||||
print(f"Updated {target.name}.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user