synapse-cli-agent 0.1.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- synapse/__init__.py +13 -0
- synapse/__main__.py +6 -0
- synapse/app/__init__.py +1 -0
- synapse/app/agent.py +492 -0
- synapse/app/agent_md.py +107 -0
- synapse/cli.py +750 -0
- synapse/commands/__init__.py +1 -0
- synapse/commands/compression.py +573 -0
- synapse/commands/helpers.py +22 -0
- synapse/commands/mcp.py +406 -0
- synapse/commands/model.py +173 -0
- synapse/commands/result.py +34 -0
- synapse/commands/sessions.py +443 -0
- synapse/commands/slash_cmds.py +521 -0
- synapse/commands/slash_complete.py +816 -0
- synapse/commands/theme.py +99 -0
- synapse/config.py +27 -0
- synapse/content/__init__.py +1 -0
- synapse/content/input_history.py +122 -0
- synapse/content/multimodal.py +733 -0
- synapse/content/prompts.py +249 -0
- synapse/content/skills_catalog.py +128 -0
- synapse/integrations/__init__.py +1 -0
- synapse/integrations/checkpoint_seed.py +281 -0
- synapse/integrations/codex_history.py +375 -0
- synapse/integrations/codex_import.py +393 -0
- synapse/integrations/codex_sessions.py +629 -0
- synapse/integrations/describe_image.py +370 -0
- synapse/integrations/http_clients.py +199 -0
- synapse/integrations/llm_openai_compat.py +90 -0
- synapse/integrations/llm_openai_websocket.py +187 -0
- synapse/integrations/mcp_client.py +646 -0
- synapse/integrations/vision_middleware.py +62 -0
- synapse/models/__init__.py +5 -0
- synapse/models/config.py +240 -0
- synapse/models/helpers.py +206 -0
- synapse/models/profile.py +59 -0
- synapse/models/registry.py +722 -0
- synapse/models_registry.py +7 -0
- synapse/observability/__init__.py +1 -0
- synapse/observability/startup_trace.py +127 -0
- synapse/runtime/__init__.py +1 -0
- synapse/runtime/async_runtime.py +176 -0
- synapse/runtime/backends.py +458 -0
- synapse/runtime/context_compact.py +249 -0
- synapse/runtime/execute_capture.py +48 -0
- synapse/runtime/fs_permissions.py +79 -0
- synapse/runtime/harness.py +57 -0
- synapse/runtime/hitl.py +197 -0
- synapse/runtime/interaction_ledger.py +82 -0
- synapse/runtime/middleware.py +802 -0
- synapse/runtime/model_request_compression_middleware.py +745 -0
- synapse/runtime/pathing.py +146 -0
- synapse/runtime/safety.py +184 -0
- synapse/runtime/steer.py +240 -0
- synapse/runtime/subagents.py +207 -0
- synapse/runtime/tool_ignore.py +221 -0
- synapse/runtime/tool_output_eval.py +118 -0
- synapse/runtime/tool_output_middleware.py +585 -0
- synapse/runtime/tool_output_usage_middleware.py +60 -0
- synapse/sessions/__init__.py +31 -0
- synapse/sessions/cancel_repair.py +208 -0
- synapse/sessions/session_recap.py +174 -0
- synapse/sessions/store.py +695 -0
- synapse/sessions/transcript.py +754 -0
- synapse/settings/__init__.py +5 -0
- synapse/settings/config_paths.py +184 -0
- synapse/settings/schema.py +464 -0
- synapse/tool_output/__init__.py +59 -0
- synapse/tool_output/detection.py +170 -0
- synapse/tool_output/metrics.py +32 -0
- synapse/tool_output/models.py +173 -0
- synapse/tool_output/pipeline.py +330 -0
- synapse/tool_output/repository.py +721 -0
- synapse/tool_output/transformers.py +648 -0
- synapse/tools/__init__.py +5 -0
- synapse/tools/session_tools.py +204 -0
- synapse/ui/__init__.py +10 -0
- synapse/ui/bottombar/__init__.py +73 -0
- synapse/ui/bottombar/components/__init__.py +143 -0
- synapse/ui/bottombar/components/key_hints.py +30 -0
- synapse/ui/bottombar/components/mcp.py +64 -0
- synapse/ui/bottombar/components/mode.py +24 -0
- synapse/ui/bottombar/components/model.py +28 -0
- synapse/ui/bottombar/components/thread.py +29 -0
- synapse/ui/bottombar/context.py +36 -0
- synapse/ui/bottombar/core.py +74 -0
- synapse/ui/dialogs/__init__.py +25 -0
- synapse/ui/dialogs/base.py +362 -0
- synapse/ui/dialogs/codex_session_list.py +84 -0
- synapse/ui/dialogs/compression_diagnostics.py +210 -0
- synapse/ui/dialogs/git_explore.py +702 -0
- synapse/ui/dialogs/mcp_panel.py +407 -0
- synapse/ui/dialogs/model_picker.py +128 -0
- synapse/ui/dialogs/safety_panel.py +63 -0
- synapse/ui/dialogs/session_list.py +98 -0
- synapse/ui/dialogs/theme_designer.py +863 -0
- synapse/ui/dialogs/theme_picker.py +113 -0
- synapse/ui/git_explore/__init__.py +31 -0
- synapse/ui/git_explore/engine.py +82 -0
- synapse/ui/git_explore/provider.py +242 -0
- synapse/ui/git_explore/unified.py +85 -0
- synapse/ui/rendering.py +350 -0
- synapse/ui/sink.py +70 -0
- synapse/ui/steer_widget.py +367 -0
- synapse/ui/stream.py +1207 -0
- synapse/ui/stream_events.py +421 -0
- synapse/ui/stream_runtime.py +252 -0
- synapse/ui/theme.py +1154 -0
- synapse/ui/timeline.py +621 -0
- synapse/ui/topbar/__init__.py +97 -0
- synapse/ui/topbar/components/__init__.py +150 -0
- synapse/ui/topbar/components/branch.py +41 -0
- synapse/ui/topbar/components/title.py +24 -0
- synapse/ui/topbar/components/tool_output.py +24 -0
- synapse/ui/topbar/components/usage.py +24 -0
- synapse/ui/topbar/components/workspace.py +32 -0
- synapse/ui/topbar/context.py +32 -0
- synapse/ui/topbar/core.py +979 -0
- synapse/ui/topbar/git_changes_popover.py +178 -0
- synapse/ui/topbar/git_chrome.py +475 -0
- synapse/ui/topbar/tool_output_popover.py +84 -0
- synapse/ui/topbar/widget.py +474 -0
- synapse/ui/tui.py +5717 -0
- synapse/ui/turn_rail.py +71 -0
- synapse/ui/user_turn.py +83 -0
- synapse/ui/welcome.py +261 -0
- synapse_cli_agent-0.1.13.dist-info/METADATA +412 -0
- synapse_cli_agent-0.1.13.dist-info/RECORD +131 -0
- synapse_cli_agent-0.1.13.dist-info/WHEEL +4 -0
- synapse_cli_agent-0.1.13.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""Extensible topbar package.
|
|
2
|
+
|
|
3
|
+
Public layout/registry API lives in ``core``; built-in components live under
|
|
4
|
+
``components/`` and are registered via ``DEFAULT_COMPONENT_INSTALLERS``.
|
|
5
|
+
|
|
6
|
+
Add a component
|
|
7
|
+
---------------
|
|
8
|
+
1. Create ``components/foo.py`` with ``install(registry, ctx)``.
|
|
9
|
+
2. Append ``foo.install`` to ``DEFAULT_COMPONENT_INSTALLERS`` in
|
|
10
|
+
``components/__init__.py``.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from synapse.ui.topbar.components import (
|
|
16
|
+
DEFAULT_COMPONENT_INSTALLERS,
|
|
17
|
+
install_default_components,
|
|
18
|
+
install_default_regions,
|
|
19
|
+
)
|
|
20
|
+
from synapse.ui.topbar.context import TopBarContext
|
|
21
|
+
from synapse.ui.topbar.core import (
|
|
22
|
+
DEFAULT_COL_GAP,
|
|
23
|
+
DEFAULT_REGION_GAP,
|
|
24
|
+
PackedRegion,
|
|
25
|
+
TopBarAlign,
|
|
26
|
+
TopBarComponent,
|
|
27
|
+
TopBarLayout,
|
|
28
|
+
TopBarRegion,
|
|
29
|
+
TopBarRegionSpec,
|
|
30
|
+
TopBarRegistry,
|
|
31
|
+
align_in_width,
|
|
32
|
+
center_in_width,
|
|
33
|
+
display_width,
|
|
34
|
+
join_region_parts,
|
|
35
|
+
layout_from_registry,
|
|
36
|
+
locate_component_span,
|
|
37
|
+
normalize_region_id,
|
|
38
|
+
pack_layout_from_registry,
|
|
39
|
+
pack_region_list,
|
|
40
|
+
pack_topbar_regions,
|
|
41
|
+
render_packed_line,
|
|
42
|
+
render_region_text,
|
|
43
|
+
truncate_to_width,
|
|
44
|
+
)
|
|
45
|
+
from synapse.ui.topbar.git_changes_popover import GitChangesPopover
|
|
46
|
+
from synapse.ui.topbar.git_chrome import (
|
|
47
|
+
GitBranchChrome,
|
|
48
|
+
GitChangedFile,
|
|
49
|
+
format_branch_chrome_plain,
|
|
50
|
+
format_changed_file_plain,
|
|
51
|
+
probe_git_branch_chrome,
|
|
52
|
+
probe_git_changed_files,
|
|
53
|
+
render_branch_chrome,
|
|
54
|
+
render_changed_file_row,
|
|
55
|
+
)
|
|
56
|
+
from synapse.ui.topbar.tool_output_popover import ToolOutputPopover
|
|
57
|
+
from synapse.ui.topbar.widget import TopBar
|
|
58
|
+
|
|
59
|
+
__all__ = [
|
|
60
|
+
"DEFAULT_COL_GAP",
|
|
61
|
+
"DEFAULT_COMPONENT_INSTALLERS",
|
|
62
|
+
"DEFAULT_REGION_GAP",
|
|
63
|
+
"GitBranchChrome",
|
|
64
|
+
"GitChangedFile",
|
|
65
|
+
"GitChangesPopover",
|
|
66
|
+
"PackedRegion",
|
|
67
|
+
"TopBar",
|
|
68
|
+
"TopBarAlign",
|
|
69
|
+
"TopBarComponent",
|
|
70
|
+
"TopBarContext",
|
|
71
|
+
"TopBarLayout",
|
|
72
|
+
"TopBarRegion",
|
|
73
|
+
"TopBarRegionSpec",
|
|
74
|
+
"TopBarRegistry",
|
|
75
|
+
"ToolOutputPopover",
|
|
76
|
+
"align_in_width",
|
|
77
|
+
"center_in_width",
|
|
78
|
+
"display_width",
|
|
79
|
+
"format_branch_chrome_plain",
|
|
80
|
+
"format_changed_file_plain",
|
|
81
|
+
"install_default_components",
|
|
82
|
+
"install_default_regions",
|
|
83
|
+
"join_region_parts",
|
|
84
|
+
"layout_from_registry",
|
|
85
|
+
"locate_component_span",
|
|
86
|
+
"normalize_region_id",
|
|
87
|
+
"pack_layout_from_registry",
|
|
88
|
+
"pack_region_list",
|
|
89
|
+
"pack_topbar_regions",
|
|
90
|
+
"probe_git_branch_chrome",
|
|
91
|
+
"probe_git_changed_files",
|
|
92
|
+
"render_branch_chrome",
|
|
93
|
+
"render_changed_file_row",
|
|
94
|
+
"render_packed_line",
|
|
95
|
+
"render_region_text",
|
|
96
|
+
"truncate_to_width",
|
|
97
|
+
]
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""Built-in topbar components.
|
|
2
|
+
|
|
3
|
+
Extension pattern
|
|
4
|
+
-----------------
|
|
5
|
+
1. Add ``components/my_widget.py`` with::
|
|
6
|
+
|
|
7
|
+
ID = "my_widget"
|
|
8
|
+
|
|
9
|
+
def install(registry, ctx) -> None:
|
|
10
|
+
registry.register_fn(ID, render, region=..., order=..., priority=...)
|
|
11
|
+
|
|
12
|
+
2. Append ``my_widget.install`` to :data:`DEFAULT_COMPONENT_INSTALLERS` below.
|
|
13
|
+
|
|
14
|
+
No other topbar core files need to change.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from collections.abc import Callable
|
|
20
|
+
from typing import TYPE_CHECKING
|
|
21
|
+
|
|
22
|
+
from synapse.ui.topbar.components import branch, title, tool_output, usage, workspace
|
|
23
|
+
from synapse.ui.topbar.core import (
|
|
24
|
+
DEFAULT_COL_GAP,
|
|
25
|
+
TopBarAlign,
|
|
26
|
+
TopBarRegion,
|
|
27
|
+
TopBarRegistry,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
from synapse.ui.topbar.context import TopBarContext
|
|
32
|
+
|
|
33
|
+
ComponentInstaller = Callable[[TopBarRegistry, "TopBarContext"], None]
|
|
34
|
+
|
|
35
|
+
# Order here is install order only (layout uses each component's region/order).
|
|
36
|
+
# To add a component: create a module, then append its ``install`` here.
|
|
37
|
+
DEFAULT_COMPONENT_INSTALLERS: list[ComponentInstaller] = [
|
|
38
|
+
workspace.install,
|
|
39
|
+
title.install,
|
|
40
|
+
branch.install,
|
|
41
|
+
tool_output.install,
|
|
42
|
+
usage.install,
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def install_default_regions(
|
|
47
|
+
registry: TopBarRegistry,
|
|
48
|
+
*,
|
|
49
|
+
left_bg: str | None = None,
|
|
50
|
+
center_bg: str | None = None,
|
|
51
|
+
right_bg: str | None = None,
|
|
52
|
+
left_fg: str | None = None,
|
|
53
|
+
center_fg: str | None = None,
|
|
54
|
+
right_fg: str | None = None,
|
|
55
|
+
) -> None:
|
|
56
|
+
"""Ensure classic left / center / right region slots exist.
|
|
57
|
+
|
|
58
|
+
Optional ``*_bg`` / ``*_fg`` paint each region as a distinct color band
|
|
59
|
+
(Rich styles: ``fg on bg``). Omit to keep the widget-level topbar chrome.
|
|
60
|
+
"""
|
|
61
|
+
registry.register_region(
|
|
62
|
+
TopBarRegion.LEFT.value,
|
|
63
|
+
order=10,
|
|
64
|
+
flex=0,
|
|
65
|
+
align=TopBarAlign.LEFT,
|
|
66
|
+
priority=40,
|
|
67
|
+
gap_after=DEFAULT_COL_GAP,
|
|
68
|
+
fg=left_fg,
|
|
69
|
+
bg=left_bg,
|
|
70
|
+
)
|
|
71
|
+
registry.register_region(
|
|
72
|
+
TopBarRegion.CENTER.value,
|
|
73
|
+
order=20,
|
|
74
|
+
flex=1,
|
|
75
|
+
align=TopBarAlign.CENTER,
|
|
76
|
+
priority=10,
|
|
77
|
+
min_width=4,
|
|
78
|
+
gap_after=DEFAULT_COL_GAP,
|
|
79
|
+
fg=center_fg,
|
|
80
|
+
bg=center_bg,
|
|
81
|
+
)
|
|
82
|
+
registry.register_region(
|
|
83
|
+
"tool_output",
|
|
84
|
+
order=25,
|
|
85
|
+
flex=0,
|
|
86
|
+
min_width=0,
|
|
87
|
+
max_width=18,
|
|
88
|
+
align=TopBarAlign.CENTER,
|
|
89
|
+
priority=20,
|
|
90
|
+
gap_after=DEFAULT_COL_GAP,
|
|
91
|
+
)
|
|
92
|
+
registry.register_region(
|
|
93
|
+
TopBarRegion.RIGHT.value,
|
|
94
|
+
order=30,
|
|
95
|
+
flex=0,
|
|
96
|
+
align=TopBarAlign.RIGHT,
|
|
97
|
+
priority=100,
|
|
98
|
+
gap_after=0,
|
|
99
|
+
fg=right_fg,
|
|
100
|
+
bg=right_bg,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def install_default_components(
|
|
105
|
+
registry: TopBarRegistry,
|
|
106
|
+
ctx: TopBarContext | None = None,
|
|
107
|
+
/,
|
|
108
|
+
*,
|
|
109
|
+
workspace: Callable[[], str] | None = None,
|
|
110
|
+
title: Callable[[], str] | None = None,
|
|
111
|
+
branch: Callable | None = None,
|
|
112
|
+
usage: Callable[[], str] | None = None,
|
|
113
|
+
tool_output: Callable[[], str] | None = None,
|
|
114
|
+
workspace_mark: str = "≡",
|
|
115
|
+
branch_mark: str = "⎇",
|
|
116
|
+
installers: list[ComponentInstaller] | None = None,
|
|
117
|
+
) -> None:
|
|
118
|
+
"""Install default regions + component modules.
|
|
119
|
+
|
|
120
|
+
Prefer passing :class:`TopBarContext`. Keyword providers remain for tests
|
|
121
|
+
and call sites that have not migrated yet.
|
|
122
|
+
"""
|
|
123
|
+
from synapse.ui.topbar.context import TopBarContext as _Ctx
|
|
124
|
+
|
|
125
|
+
if ctx is None:
|
|
126
|
+
if workspace is None or title is None or branch is None or usage is None:
|
|
127
|
+
raise TypeError(
|
|
128
|
+
"install_default_components requires ctx= or workspace/title/branch/usage="
|
|
129
|
+
)
|
|
130
|
+
ctx = _Ctx(
|
|
131
|
+
workspace=workspace,
|
|
132
|
+
title=title,
|
|
133
|
+
branch=branch,
|
|
134
|
+
usage=usage,
|
|
135
|
+
tool_output=tool_output or (lambda: ""),
|
|
136
|
+
workspace_mark=workspace_mark,
|
|
137
|
+
branch_mark=branch_mark,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
install_default_regions(registry)
|
|
141
|
+
for install in installers or DEFAULT_COMPONENT_INSTALLERS:
|
|
142
|
+
install(registry, ctx)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
__all__ = [
|
|
146
|
+
"DEFAULT_COMPONENT_INSTALLERS",
|
|
147
|
+
"ComponentInstaller",
|
|
148
|
+
"install_default_components",
|
|
149
|
+
"install_default_regions",
|
|
150
|
+
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Topbar component: git branch chrome (left, after workspace)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from rich.text import Text
|
|
6
|
+
|
|
7
|
+
from synapse.ui.topbar.context import TopBarContext
|
|
8
|
+
from synapse.ui.topbar.core import TopBarRegion, TopBarRegistry
|
|
9
|
+
|
|
10
|
+
ID = "branch"
|
|
11
|
+
REGION = TopBarRegion.LEFT
|
|
12
|
+
ORDER = 20 # immediately right of workspace
|
|
13
|
+
PRIORITY = 50
|
|
14
|
+
MIN_WIDTH = 6
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def install(registry: TopBarRegistry, ctx: TopBarContext) -> None:
|
|
18
|
+
"""Register the git branch status component.
|
|
19
|
+
|
|
20
|
+
``ctx.branch`` may return plain text or a pre-styled ``rich.text.Text``
|
|
21
|
+
(dirty/ahead/behind colors). Plain strings get the default branch mark.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def render() -> str | Text:
|
|
25
|
+
raw = ctx.branch()
|
|
26
|
+
if isinstance(raw, Text):
|
|
27
|
+
return raw if raw.plain.strip() else ""
|
|
28
|
+
name = str(raw or "").strip()
|
|
29
|
+
if not name:
|
|
30
|
+
return ""
|
|
31
|
+
mark = (ctx.branch_mark or "").strip()
|
|
32
|
+
return f"{mark} {name}" if mark else name
|
|
33
|
+
|
|
34
|
+
registry.register_fn(
|
|
35
|
+
ID,
|
|
36
|
+
render,
|
|
37
|
+
region=REGION,
|
|
38
|
+
order=ORDER,
|
|
39
|
+
priority=PRIORITY,
|
|
40
|
+
min_width=MIN_WIDTH,
|
|
41
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Topbar component: session title (center)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from synapse.ui.topbar.context import TopBarContext
|
|
6
|
+
from synapse.ui.topbar.core import TopBarRegion, TopBarRegistry
|
|
7
|
+
|
|
8
|
+
ID = "title"
|
|
9
|
+
REGION = TopBarRegion.CENTER
|
|
10
|
+
ORDER = 10
|
|
11
|
+
PRIORITY = 10 # shrink first when narrow
|
|
12
|
+
MIN_WIDTH = 4
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def install(registry: TopBarRegistry, ctx: TopBarContext) -> None:
|
|
16
|
+
"""Register the session title component."""
|
|
17
|
+
registry.register_fn(
|
|
18
|
+
ID,
|
|
19
|
+
lambda: (ctx.title() or "").strip(),
|
|
20
|
+
region=REGION,
|
|
21
|
+
order=ORDER,
|
|
22
|
+
priority=PRIORITY,
|
|
23
|
+
min_width=MIN_WIDTH,
|
|
24
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Topbar component: effective tool-output compression savings."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from synapse.ui.topbar.context import TopBarContext
|
|
6
|
+
from synapse.ui.topbar.core import TopBarRegistry
|
|
7
|
+
|
|
8
|
+
ID = "tool_output"
|
|
9
|
+
REGION = "tool_output"
|
|
10
|
+
ORDER = 10
|
|
11
|
+
PRIORITY = 45
|
|
12
|
+
MIN_WIDTH = 0
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def install(registry: TopBarRegistry, ctx: TopBarContext) -> None:
|
|
16
|
+
"""Register the compact tool-output savings label in its own region."""
|
|
17
|
+
registry.register_fn(
|
|
18
|
+
ID,
|
|
19
|
+
lambda: ctx.tool_output() or "",
|
|
20
|
+
region=REGION,
|
|
21
|
+
order=ORDER,
|
|
22
|
+
priority=PRIORITY,
|
|
23
|
+
min_width=MIN_WIDTH,
|
|
24
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Topbar component: token usage (right)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from synapse.ui.topbar.context import TopBarContext
|
|
6
|
+
from synapse.ui.topbar.core import TopBarRegion, TopBarRegistry
|
|
7
|
+
|
|
8
|
+
ID = "usage"
|
|
9
|
+
REGION = TopBarRegion.RIGHT
|
|
10
|
+
ORDER = 10
|
|
11
|
+
PRIORITY = 60 # keep when narrow
|
|
12
|
+
MIN_WIDTH = 8
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def install(registry: TopBarRegistry, ctx: TopBarContext) -> None:
|
|
16
|
+
"""Register the in/cache/out + occupancy usage component."""
|
|
17
|
+
registry.register_fn(
|
|
18
|
+
ID,
|
|
19
|
+
lambda: ctx.usage() or "",
|
|
20
|
+
region=REGION,
|
|
21
|
+
order=ORDER,
|
|
22
|
+
priority=PRIORITY,
|
|
23
|
+
min_width=MIN_WIDTH,
|
|
24
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Topbar component: workspace path (left)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from synapse.ui.topbar.context import TopBarContext
|
|
6
|
+
from synapse.ui.topbar.core import TopBarRegion, TopBarRegistry
|
|
7
|
+
|
|
8
|
+
ID = "workspace"
|
|
9
|
+
REGION = TopBarRegion.LEFT
|
|
10
|
+
ORDER = 10
|
|
11
|
+
PRIORITY = 40
|
|
12
|
+
MIN_WIDTH = 8
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def install(registry: TopBarRegistry, ctx: TopBarContext) -> None:
|
|
16
|
+
"""Register the workspace label component."""
|
|
17
|
+
|
|
18
|
+
def render() -> str:
|
|
19
|
+
label = (ctx.workspace() or "").strip()
|
|
20
|
+
if not label:
|
|
21
|
+
return ""
|
|
22
|
+
mark = (ctx.workspace_mark or "").strip()
|
|
23
|
+
return f"{mark} {label}" if mark else label
|
|
24
|
+
|
|
25
|
+
registry.register_fn(
|
|
26
|
+
ID,
|
|
27
|
+
render,
|
|
28
|
+
region=REGION,
|
|
29
|
+
order=ORDER,
|
|
30
|
+
priority=PRIORITY,
|
|
31
|
+
min_width=MIN_WIDTH,
|
|
32
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Host context passed into topbar component installers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Callable
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
|
|
8
|
+
from rich.text import Text
|
|
9
|
+
|
|
10
|
+
# Providers may return plain text or pre-styled Rich Text.
|
|
11
|
+
LabelFn = Callable[[], str]
|
|
12
|
+
RichLabelFn = Callable[[], str | Text]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _empty_label() -> str:
|
|
16
|
+
return ""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(slots=True)
|
|
20
|
+
class TopBarContext:
|
|
21
|
+
"""Data sources for built-in (and custom) topbar components.
|
|
22
|
+
|
|
23
|
+
App/host fills these callables; each component module only reads what it needs.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
workspace: LabelFn
|
|
27
|
+
title: LabelFn
|
|
28
|
+
branch: RichLabelFn
|
|
29
|
+
usage: LabelFn
|
|
30
|
+
tool_output: RichLabelFn = _empty_label
|
|
31
|
+
workspace_mark: str = "≡"
|
|
32
|
+
branch_mark: str = "⎇"
|