-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
68 lines (51 loc) · 1.72 KB
/
Copy pathmain.py
File metadata and controls
68 lines (51 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""ArrowCode entry point.
Launches the Textual app. If no config exists yet (or no API keys are
saved), the Setup screen is shown first; otherwise we boot straight into
the Dashboard.
"""
from __future__ import annotations
import asyncio
import os
import sys
from pathlib import Path
# Make the repo root importable no matter where the script is invoked from.
REPO_ROOT = Path(__file__).resolve().parent
if str(REPO_ROOT) not in sys.path:
sys.path.insert(0, str(REPO_ROOT))
from textual.app import App, ComposeResult
from core.config import get_config
from ui.setup_screen import SetupScreen
from ui.dashboard import DashboardScreen
class ArrowCodeApp(App):
"""ArrowCode Textual application."""
TITLE = "ArrowCode"
SUB_TITLE = "24/7 autonomous multi-model engineering orchestrator"
CSS = """
Screen {
background: #1a1b26;
color: #c0caf5;
}
"""
def __init__(self) -> None:
super().__init__()
self.cfg = get_config()
def on_mount(self) -> None:
if not self.cfg.is_setup or not self.cfg.available_providers():
# First launch: push Setup, then Dashboard after Save.
self.push_screen(SetupScreen(), self._after_setup)
else:
self.push_screen(DashboardScreen())
def _after_setup(self, _result=None) -> None:
# SetupScreen pops itself; we just push the dashboard.
self.push_screen(DashboardScreen())
def main() -> None:
"""Create the Textual app and run it."""
# Some asyncio plumbing on certain Python builds.
try:
asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
except Exception:
pass
app = ArrowCodeApp()
app.run()
if __name__ == "__main__":
main()