lightfall 0.1.1__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.
Files changed (388) hide show
  1. lightfall/__init__.py +8 -0
  2. lightfall/__main__.py +10 -0
  3. lightfall/_version.py +24 -0
  4. lightfall/acquire/__init__.py +74 -0
  5. lightfall/acquire/buffer.py +363 -0
  6. lightfall/acquire/device_wrapper.py +416 -0
  7. lightfall/acquire/engine/__init__.py +155 -0
  8. lightfall/acquire/engine/base.py +587 -0
  9. lightfall/acquire/engine/bluesky.py +358 -0
  10. lightfall/acquire/engine/mock.py +165 -0
  11. lightfall/acquire/engine/plugins/__init__.py +9 -0
  12. lightfall/acquire/engine/plugins/bluesky_plugin.py +56 -0
  13. lightfall/acquire/engine/plugins/mock_plugin.py +55 -0
  14. lightfall/acquire/engine/protocol.py +145 -0
  15. lightfall/acquire/engine/registry.py +152 -0
  16. lightfall/acquire/engine/state.py +32 -0
  17. lightfall/acquire/engine/waiting_hook.py +225 -0
  18. lightfall/acquire/nats_bridge.py +62 -0
  19. lightfall/acquire/plan_ui.py +78 -0
  20. lightfall/acquire/plans/__init__.py +38 -0
  21. lightfall/acquire/plans/adaptive.py +288 -0
  22. lightfall/acquire/plans/example_plans.py +995 -0
  23. lightfall/acquire/plans/lightfall_plans.py +587 -0
  24. lightfall/acquire/plans/registry.py +543 -0
  25. lightfall/acquire/plans/standard_plans.py +186 -0
  26. lightfall/acquire/plans/user_plans.py +470 -0
  27. lightfall/acquire/runengine.py +36 -0
  28. lightfall/acquire/signals.py +452 -0
  29. lightfall/acquire/triggers/__init__.py +16 -0
  30. lightfall/acquire/triggers/base.py +25 -0
  31. lightfall/acquire/triggers/filter.py +37 -0
  32. lightfall/acquire/triggers/manager.py +73 -0
  33. lightfall/acquire/triggers/manual.py +36 -0
  34. lightfall/acquire/triggers/run_end.py +74 -0
  35. lightfall/acquire/triggers/run_start.py +52 -0
  36. lightfall/auth/__init__.py +38 -0
  37. lightfall/auth/policy.py +518 -0
  38. lightfall/auth/providers/__init__.py +30 -0
  39. lightfall/auth/providers/base.py +124 -0
  40. lightfall/auth/providers/keycloak.py +1017 -0
  41. lightfall/auth/providers/local.py +319 -0
  42. lightfall/auth/providers/pam.py +250 -0
  43. lightfall/auth/service_key.py +173 -0
  44. lightfall/auth/service_key_auth.py +79 -0
  45. lightfall/auth/session.py +656 -0
  46. lightfall/claude/__init__.py +52 -0
  47. lightfall/claude/_internal/__init__.py +1 -0
  48. lightfall/claude/_internal/serialization.py +195 -0
  49. lightfall/claude/_internal/threading.py +61 -0
  50. lightfall/claude/_internal/worker.py +757 -0
  51. lightfall/claude/_session_assembly.py +124 -0
  52. lightfall/claude/agent.py +596 -0
  53. lightfall/claude/lightfall_core_tools.py +410 -0
  54. lightfall/claude/markdown.py +103 -0
  55. lightfall/claude/permission_manager.py +588 -0
  56. lightfall/claude/tools/__init__.py +45 -0
  57. lightfall/claude/tools/controller.py +143 -0
  58. lightfall/claude/tools/interaction.py +177 -0
  59. lightfall/claude/tools/introspection.py +127 -0
  60. lightfall/claude/tools/logs.py +155 -0
  61. lightfall/claude/tools/screenshot.py +87 -0
  62. lightfall/claude/widget.py +851 -0
  63. lightfall/claude/widgets/__init__.py +5 -0
  64. lightfall/claude/widgets/permission_request.py +282 -0
  65. lightfall/claude/widgets/question_request.py +227 -0
  66. lightfall/claude/widgets/task_card.py +223 -0
  67. lightfall/config/__init__.py +23 -0
  68. lightfall/config/layers.py +317 -0
  69. lightfall/config/manager.py +244 -0
  70. lightfall/config/schema.py +154 -0
  71. lightfall/core/__init__.py +23 -0
  72. lightfall/core/application.py +727 -0
  73. lightfall/core/services.py +235 -0
  74. lightfall/devices/__init__.py +53 -0
  75. lightfall/devices/backends/__init__.py +17 -0
  76. lightfall/devices/backends/bcs.py +448 -0
  77. lightfall/devices/backends/happi.py +986 -0
  78. lightfall/devices/backends/mock.py +646 -0
  79. lightfall/devices/base.py +338 -0
  80. lightfall/devices/catalog.py +1039 -0
  81. lightfall/devices/connection_manager.py +676 -0
  82. lightfall/devices/model.py +290 -0
  83. lightfall/devices/monitoring.py +442 -0
  84. lightfall/devices/sim/__init__.py +26 -0
  85. lightfall/devices/sim/areadetector.py +436 -0
  86. lightfall/devices/sim/generators.py +223 -0
  87. lightfall/devices/sim/plugins.py +116 -0
  88. lightfall/epics/__init__.py +28 -0
  89. lightfall/epics/ca/__init__.py +10 -0
  90. lightfall/epics/ca/context.py +100 -0
  91. lightfall/epics/ca/pv.py +303 -0
  92. lightfall/epics/widgets/__init__.py +49 -0
  93. lightfall/epics/widgets/areadetector/__init__.py +16 -0
  94. lightfall/epics/widgets/areadetector/areadetector.py +281 -0
  95. lightfall/epics/widgets/areadetector/controls.py +478 -0
  96. lightfall/epics/widgets/areadetector/image_view.py +447 -0
  97. lightfall/epics/widgets/auto.py +319 -0
  98. lightfall/epics/widgets/base.py +404 -0
  99. lightfall/epics/widgets/checkbox.py +239 -0
  100. lightfall/epics/widgets/combobox.py +202 -0
  101. lightfall/epics/widgets/label.py +176 -0
  102. lightfall/epics/widgets/lineedit.py +253 -0
  103. lightfall/epics/widgets/motor.py +694 -0
  104. lightfall/epics/widgets/ophyd_base.py +469 -0
  105. lightfall/epics/widgets/ophyd_combobox.py +86 -0
  106. lightfall/epics/widgets/ophyd_label.py +54 -0
  107. lightfall/epics/widgets/ophyd_lineedit.py +170 -0
  108. lightfall/epics/widgets/ophyd_spinbox.py +79 -0
  109. lightfall/epics/widgets/slider.py +272 -0
  110. lightfall/epics/widgets/status_indicator.py +98 -0
  111. lightfall/epics/widgets/style.py +188 -0
  112. lightfall/exporter/__init__.py +1 -0
  113. lightfall/exporter/cli.py +67 -0
  114. lightfall/exporter/converters/__init__.py +26 -0
  115. lightfall/exporter/converters/base.py +39 -0
  116. lightfall/exporter/converters/noop.py +39 -0
  117. lightfall/exporter/converters/nxsas.py +73 -0
  118. lightfall/exporter/service.py +200 -0
  119. lightfall/exporter/tiled_utils.py +92 -0
  120. lightfall/ipc/__init__.py +6 -0
  121. lightfall/ipc/service.py +701 -0
  122. lightfall/ipc/trust.py +144 -0
  123. lightfall/logbook/__init__.py +46 -0
  124. lightfall/logbook/action_dialog.py +207 -0
  125. lightfall/logbook/action_logger.py +432 -0
  126. lightfall/logbook/block_mapper.py +562 -0
  127. lightfall/logbook/client.py +799 -0
  128. lightfall/logbook/converter.py +273 -0
  129. lightfall/logbook/editors/__init__.py +19 -0
  130. lightfall/logbook/editors/highlighter.py +305 -0
  131. lightfall/logbook/editors/markdown_editor.py +319 -0
  132. lightfall/logbook/editors/richtext_editor.py +1397 -0
  133. lightfall/logbook/entry_widget.py +1065 -0
  134. lightfall/logbook/event_listener.py +221 -0
  135. lightfall/logbook/fragment_widgets.py +925 -0
  136. lightfall/logbook/position_mapper.py +320 -0
  137. lightfall/logbook/protection.py +402 -0
  138. lightfall/logbook/style.py +394 -0
  139. lightfall/logbook/url.py +29 -0
  140. lightfall/logbook/visual_protection.py +330 -0
  141. lightfall/logbook/widget.py +680 -0
  142. lightfall/main.py +1091 -0
  143. lightfall/pipelines/__init__.py +4 -0
  144. lightfall/pipelines/client.py +148 -0
  145. lightfall/plugins/__init__.py +119 -0
  146. lightfall/plugins/agent_plugin.py +106 -0
  147. lightfall/plugins/agents/__init__.py +10 -0
  148. lightfall/plugins/agents/_mcp_helpers.py +52 -0
  149. lightfall/plugins/agents/alignment.py +94 -0
  150. lightfall/plugins/agents/autonomous_experiment/__init__.py +12 -0
  151. lightfall/plugins/agents/autonomous_experiment/nats_tools.py +210 -0
  152. lightfall/plugins/agents/autonomous_experiment/plugin.py +60 -0
  153. lightfall/plugins/agents/autonomous_experiment/prompts.py +164 -0
  154. lightfall/plugins/agents/current_esaf.py +435 -0
  155. lightfall/plugins/agents/device_tools.py +1043 -0
  156. lightfall/plugins/agents/engine_tools.py +720 -0
  157. lightfall/plugins/agents/ipython_tools.py +444 -0
  158. lightfall/plugins/agents/panel_builder.py +637 -0
  159. lightfall/plugins/agents/panel_design/references/cross_panel_patterns.md +95 -0
  160. lightfall/plugins/agents/panel_design/references/panel_design.md +680 -0
  161. lightfall/plugins/agents/panel_design.py +94 -0
  162. lightfall/plugins/agents/plan_design/references/plan_design.md +398 -0
  163. lightfall/plugins/agents/plan_design.py +90 -0
  164. lightfall/plugins/agents/plan_tools.py +878 -0
  165. lightfall/plugins/agents/scan_planning.py +101 -0
  166. lightfall/plugins/builtin_manifest.py +348 -0
  167. lightfall/plugins/controller_plugin.py +162 -0
  168. lightfall/plugins/engine_plugin.py +124 -0
  169. lightfall/plugins/errors.py +104 -0
  170. lightfall/plugins/info.py +112 -0
  171. lightfall/plugins/loader.py +878 -0
  172. lightfall/plugins/manifest.py +150 -0
  173. lightfall/plugins/panel_plugin.py +119 -0
  174. lightfall/plugins/plan_plugin.py +163 -0
  175. lightfall/plugins/registry.py +309 -0
  176. lightfall/plugins/settings_plugin.py +226 -0
  177. lightfall/plugins/statusbar_plugin.py +289 -0
  178. lightfall/plugins/theme_plugin.py +165 -0
  179. lightfall/plugins/types.py +136 -0
  180. lightfall/plugins/user_plugins.py +764 -0
  181. lightfall/project/__init__.py +37 -0
  182. lightfall/project/model.py +375 -0
  183. lightfall/project/service.py +427 -0
  184. lightfall/project/welcome.py +106 -0
  185. lightfall/resources/__init__.py +126 -0
  186. lightfall/resources/images/__init__.py +1 -0
  187. lightfall/resources/images/icon.ico +0 -0
  188. lightfall/resources/images/icon.png +0 -0
  189. lightfall/resources/images/logo.png +0 -0
  190. lightfall/services/__init__.py +33 -0
  191. lightfall/services/_alshub_client.py +73 -0
  192. lightfall/services/access_stamper.py +240 -0
  193. lightfall/services/als_beam_status.py +347 -0
  194. lightfall/services/ca_tunnel.py +325 -0
  195. lightfall/services/threaded_tiled_writer.py +174 -0
  196. lightfall/services/tiled_auth.py +21 -0
  197. lightfall/services/tiled_service.py +971 -0
  198. lightfall/services/tiled_writer_patch.py +301 -0
  199. lightfall/settings/__init__.py +1 -0
  200. lightfall/settings/image_helpers.py +30 -0
  201. lightfall/settings/user_settings_client.py +232 -0
  202. lightfall/ui/__init__.py +28 -0
  203. lightfall/ui/annotations.py +208 -0
  204. lightfall/ui/common/__init__.py +7 -0
  205. lightfall/ui/dialogs/__init__.py +26 -0
  206. lightfall/ui/dialogs/about_dialog.py +131 -0
  207. lightfall/ui/dialogs/add_trigger_dialog.py +152 -0
  208. lightfall/ui/dialogs/base.py +44 -0
  209. lightfall/ui/dialogs/bug_report_dialog.py +353 -0
  210. lightfall/ui/dialogs/create_plan_dialog.py +189 -0
  211. lightfall/ui/dialogs/device_edit_dialog.py +183 -0
  212. lightfall/ui/dialogs/export_dialog.py +565 -0
  213. lightfall/ui/dialogs/go_to_position_dialog.py +192 -0
  214. lightfall/ui/dialogs/login_dialog.py +756 -0
  215. lightfall/ui/dialogs/oauth_browser_dialog.py +305 -0
  216. lightfall/ui/dialogs/run_pipeline_dialog.py +131 -0
  217. lightfall/ui/dialogs/sample_metadata_dialog.py +316 -0
  218. lightfall/ui/docking/__init__.py +22 -0
  219. lightfall/ui/docking/icon_sidebar.py +806 -0
  220. lightfall/ui/docking/manager.py +682 -0
  221. lightfall/ui/docking/state.py +113 -0
  222. lightfall/ui/docking/theme.py +399 -0
  223. lightfall/ui/docking/widget.py +214 -0
  224. lightfall/ui/events.py +75 -0
  225. lightfall/ui/mainwindow.py +1006 -0
  226. lightfall/ui/models/__init__.py +49 -0
  227. lightfall/ui/models/device_selection.py +389 -0
  228. lightfall/ui/models/device_tree.py +1095 -0
  229. lightfall/ui/models/thread_model.py +667 -0
  230. lightfall/ui/models/tiled_model.py +384 -0
  231. lightfall/ui/panels/__init__.py +28 -0
  232. lightfall/ui/panels/base.py +525 -0
  233. lightfall/ui/panels/bluesky_panel.py +619 -0
  234. lightfall/ui/panels/claude/__init__.py +9 -0
  235. lightfall/ui/panels/claude/agent_registry.py +168 -0
  236. lightfall/ui/panels/claude_panel.py +887 -0
  237. lightfall/ui/panels/device_panel.py +370 -0
  238. lightfall/ui/panels/documents_panel.py +166 -0
  239. lightfall/ui/panels/ipython_panel.py +580 -0
  240. lightfall/ui/panels/logbook_entries_panel.py +84 -0
  241. lightfall/ui/panels/logbook_panel.py +627 -0
  242. lightfall/ui/panels/logging_panel.py +587 -0
  243. lightfall/ui/panels/pipeline_jobs_panel.py +160 -0
  244. lightfall/ui/panels/pipeline_triggers_panel.py +170 -0
  245. lightfall/ui/panels/plugins/__init__.py +34 -0
  246. lightfall/ui/panels/plugins/bluesky_plugin.py +27 -0
  247. lightfall/ui/panels/plugins/claude_plugin.py +29 -0
  248. lightfall/ui/panels/plugins/device_plugin.py +27 -0
  249. lightfall/ui/panels/plugins/documents_plugin.py +26 -0
  250. lightfall/ui/panels/plugins/ipython_plugin.py +27 -0
  251. lightfall/ui/panels/plugins/logbook_entries_plugin.py +23 -0
  252. lightfall/ui/panels/plugins/logbook_plugin.py +27 -0
  253. lightfall/ui/panels/plugins/logging_plugin.py +27 -0
  254. lightfall/ui/panels/plugins/pipeline_jobs_plugin.py +23 -0
  255. lightfall/ui/panels/plugins/pipeline_triggers_plugin.py +25 -0
  256. lightfall/ui/panels/plugins/queue_plugin.py +29 -0
  257. lightfall/ui/panels/plugins/synoptic_plugin.py +38 -0
  258. lightfall/ui/panels/plugins/threads_plugin.py +27 -0
  259. lightfall/ui/panels/plugins/tiled_browser_plugin.py +27 -0
  260. lightfall/ui/panels/plugins/visualization_plugin.py +27 -0
  261. lightfall/ui/panels/queue.py +754 -0
  262. lightfall/ui/panels/registry.py +483 -0
  263. lightfall/ui/panels/synoptic/__init__.py +27 -0
  264. lightfall/ui/panels/synoptic/editors.py +481 -0
  265. lightfall/ui/panels/synoptic/items.py +556 -0
  266. lightfall/ui/panels/synoptic/models.py +336 -0
  267. lightfall/ui/panels/synoptic/panel.py +889 -0
  268. lightfall/ui/panels/synoptic/serialization.py +300 -0
  269. lightfall/ui/panels/synoptic/view.py +504 -0
  270. lightfall/ui/panels/threads_panel.py +621 -0
  271. lightfall/ui/panels/tiled_browser_panel.py +854 -0
  272. lightfall/ui/panels/visualization_panel.py +508 -0
  273. lightfall/ui/preferences/__init__.py +24 -0
  274. lightfall/ui/preferences/backend.py +148 -0
  275. lightfall/ui/preferences/builtin.py +220 -0
  276. lightfall/ui/preferences/claude_settings.py +762 -0
  277. lightfall/ui/preferences/device_settings.py +461 -0
  278. lightfall/ui/preferences/dialog.py +234 -0
  279. lightfall/ui/preferences/editor_settings.py +227 -0
  280. lightfall/ui/preferences/ipc_settings.py +226 -0
  281. lightfall/ui/preferences/logbook_settings.py +232 -0
  282. lightfall/ui/preferences/login_settings.py +183 -0
  283. lightfall/ui/preferences/manager.py +562 -0
  284. lightfall/ui/preferences/plugin_settings.py +392 -0
  285. lightfall/ui/preferences/proxy_settings.py +561 -0
  286. lightfall/ui/preferences/skill_settings.py +28 -0
  287. lightfall/ui/preferences/tiled_settings.py +469 -0
  288. lightfall/ui/preferences/tool_settings.py +393 -0
  289. lightfall/ui/preferences/user_portable_backend.py +131 -0
  290. lightfall/ui/preferences/user_profile_settings.py +316 -0
  291. lightfall/ui/preferences/visualization_settings.py +159 -0
  292. lightfall/ui/resources/__init__.py +1 -0
  293. lightfall/ui/resources/logo.png +0 -0
  294. lightfall/ui/statusbar/__init__.py +11 -0
  295. lightfall/ui/statusbar/manager.py +379 -0
  296. lightfall/ui/statusbar/plugins/__init__.py +28 -0
  297. lightfall/ui/statusbar/plugins/als_beam_status.py +218 -0
  298. lightfall/ui/statusbar/plugins/auth_status.py +116 -0
  299. lightfall/ui/statusbar/plugins/connection_status.py +100 -0
  300. lightfall/ui/statusbar/plugins/thread_status.py +556 -0
  301. lightfall/ui/statusbar/plugins/tiled_status.py +179 -0
  302. lightfall/ui/statusbar/plugins/user_status.py +84 -0
  303. lightfall/ui/theater/__init__.py +28 -0
  304. lightfall/ui/theater/manager.py +124 -0
  305. lightfall/ui/theater/overlay.py +279 -0
  306. lightfall/ui/theater/proxy.py +111 -0
  307. lightfall/ui/theme/__init__.py +18 -0
  308. lightfall/ui/theme/builtin.py +1015 -0
  309. lightfall/ui/theme/manager.py +875 -0
  310. lightfall/ui/theme/registry.py +195 -0
  311. lightfall/ui/toast.py +221 -0
  312. lightfall/ui/tutorial.py +1100 -0
  313. lightfall/ui/widgets/__init__.py +110 -0
  314. lightfall/ui/widgets/base_control.py +259 -0
  315. lightfall/ui/widgets/camera/__init__.py +36 -0
  316. lightfall/ui/widgets/camera/base.py +815 -0
  317. lightfall/ui/widgets/camera/dark_frames.py +213 -0
  318. lightfall/ui/widgets/camera/image_view.py +649 -0
  319. lightfall/ui/widgets/camera/panels/__init__.py +14 -0
  320. lightfall/ui/widgets/camera/panels/cooler.py +320 -0
  321. lightfall/ui/widgets/camera/panels/temperature.py +192 -0
  322. lightfall/ui/widgets/camera/plan_based.py +202 -0
  323. lightfall/ui/widgets/compact_motor.py +522 -0
  324. lightfall/ui/widgets/controller_matcher.py +278 -0
  325. lightfall/ui/widgets/controller_registry.py +144 -0
  326. lightfall/ui/widgets/device_control.py +411 -0
  327. lightfall/ui/widgets/device_selector.py +438 -0
  328. lightfall/ui/widgets/device_tree_tab.py +461 -0
  329. lightfall/ui/widgets/document_stream.py +1028 -0
  330. lightfall/ui/widgets/favorites_tab.py +191 -0
  331. lightfall/ui/widgets/motor_control.py +1120 -0
  332. lightfall/ui/widgets/observers/__init__.py +8 -0
  333. lightfall/ui/widgets/observers/camera.py +48 -0
  334. lightfall/ui/widgets/observers/image_view.py +130 -0
  335. lightfall/ui/widgets/plan_config.py +954 -0
  336. lightfall/ui/widgets/plan_edit_dialog.py +294 -0
  337. lightfall/ui/widgets/plan_selector.py +452 -0
  338. lightfall/ui/widgets/profile_avatar.py +128 -0
  339. lightfall/ui/widgets/queue_view.py +647 -0
  340. lightfall/ui/widgets/runengine_control.py +549 -0
  341. lightfall/ui/widgets/signal_control.py +793 -0
  342. lightfall/ui/widgets/skill_trigger_button.py +183 -0
  343. lightfall/ui/widgets/tiled_filter_widget.py +314 -0
  344. lightfall/ui/widgets/tiled_status.py +149 -0
  345. lightfall/ui/widgets/warning_banner.py +185 -0
  346. lightfall/utils/__init__.py +53 -0
  347. lightfall/utils/crash_diagnostics.py +454 -0
  348. lightfall/utils/data_migration.py +22 -0
  349. lightfall/utils/editor_launcher.py +594 -0
  350. lightfall/utils/error_collector.py +245 -0
  351. lightfall/utils/git_tracker.py +197 -0
  352. lightfall/utils/log_buffer.py +233 -0
  353. lightfall/utils/logging.py +229 -0
  354. lightfall/utils/module_resolver.py +70 -0
  355. lightfall/utils/sentry.py +722 -0
  356. lightfall/utils/threads.py +991 -0
  357. lightfall/utils/tiled_helpers.py +96 -0
  358. lightfall/visualization/__init__.py +50 -0
  359. lightfall/visualization/base.py +5 -0
  360. lightfall/visualization/base_visualization.py +74 -0
  361. lightfall/visualization/fitting/__init__.py +24 -0
  362. lightfall/visualization/fitting/base.py +267 -0
  363. lightfall/visualization/fitting/fitters.py +325 -0
  364. lightfall/visualization/fitting/panel.py +265 -0
  365. lightfall/visualization/memory.py +392 -0
  366. lightfall/visualization/motor_mixin.py +524 -0
  367. lightfall/visualization/pg.py +156 -0
  368. lightfall/visualization/registry.py +144 -0
  369. lightfall/visualization/spec.py +79 -0
  370. lightfall/visualization/theme.py +266 -0
  371. lightfall/visualization/widgets/__init__.py +28 -0
  372. lightfall/visualization/widgets/adaptive/__init__.py +1 -0
  373. lightfall/visualization/widgets/adaptive/heatmap.py +655 -0
  374. lightfall/visualization/widgets/adaptive/plot.py +233 -0
  375. lightfall/visualization/widgets/heatmap.py +264 -0
  376. lightfall/visualization/widgets/image_stack.py +316 -0
  377. lightfall/visualization/widgets/image_view_toolbar.py +227 -0
  378. lightfall/visualization/widgets/lazy_image_view.py +590 -0
  379. lightfall/visualization/widgets/plot_1d.py +262 -0
  380. lightfall/visualization/widgets/scatter.py +247 -0
  381. lightfall/visualization/widgets/table.py +221 -0
  382. lightfall/visualization/widgets/time_axis.py +93 -0
  383. lightfall-0.1.1.dist-info/METADATA +223 -0
  384. lightfall-0.1.1.dist-info/RECORD +388 -0
  385. lightfall-0.1.1.dist-info/WHEEL +4 -0
  386. lightfall-0.1.1.dist-info/entry_points.txt +6 -0
  387. lightfall-0.1.1.dist-info/licenses/LEGAL.md +13 -0
  388. lightfall-0.1.1.dist-info/licenses/LICENSE.md +33 -0
@@ -0,0 +1,379 @@
1
+ """Status bar manager for NCS.
2
+
3
+ Manages the lifecycle of status bar indicator plugins, including
4
+ loading, positioning, and cleanup.
5
+
6
+ All plugin widgets render into a single manager-owned container that
7
+ spans the full width of the ``QStatusBar``. Inside the container, a
8
+ ``QHBoxLayout`` holds the "left"-positioned plugins, then a stretch,
9
+ then the "right"/"permanent" plugins. Because the statusbar has only
10
+ one child widget there are no Qt per-item separator notches, and the
11
+ size grip is disabled so the far-right notch goes away too.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from typing import TYPE_CHECKING, Any
17
+
18
+ from PySide6.QtWidgets import QHBoxLayout, QSizePolicy, QSpacerItem, QStatusBar, QWidget
19
+
20
+ from lightfall.utils.logging import logger
21
+
22
+ if TYPE_CHECKING:
23
+ from lightfall.plugins.info import PluginInfo
24
+ from lightfall.plugins.loader import PluginLoader
25
+ from lightfall.plugins.statusbar_plugin import StatusBarPlugin
26
+
27
+
28
+ # Spacing between adjacent status bar entries (pixels). Small enough to
29
+ # read as related items, large enough to distinguish them without a glyph.
30
+ ITEM_SPACING_PX = 4
31
+
32
+
33
+ class StatusBarManager:
34
+ """Manages status bar indicator plugins.
35
+
36
+ The StatusBarManager handles:
37
+ - Loading plugins from the PluginRegistry
38
+ - Subscribing to PluginLoader signals for dynamic plugin loading
39
+ - Rendering plugin widgets inside a single full-width container so
40
+ Qt's per-item separator notches never appear, and disabling the
41
+ size grip so there's no notch on the far right either
42
+ - Connecting/disconnecting signal handlers
43
+ - Reacting to per-plugin visibility changes
44
+ - Cleanup on shutdown
45
+
46
+ Plugins are positioned by priority (lower = further left). The
47
+ ``position`` metadata field decides which side of the central
48
+ stretch they sit on: "left" anchors to the left edge, "right" or
49
+ "permanent" anchors to the right edge.
50
+
51
+ Example:
52
+ >>> statusbar = QStatusBar()
53
+ >>> manager = StatusBarManager(statusbar, parent)
54
+ >>> manager.load_plugins()
55
+ >>> # Later, on cleanup:
56
+ >>> manager.cleanup()
57
+ """
58
+
59
+ def __init__(
60
+ self,
61
+ statusbar: QStatusBar,
62
+ parent: QWidget | None = None,
63
+ ) -> None:
64
+ """Initialize the status bar manager.
65
+
66
+ Args:
67
+ statusbar: The QStatusBar to manage.
68
+ parent: Parent widget (typically the main window).
69
+ """
70
+ self._statusbar = statusbar
71
+ self._parent = parent
72
+ self._plugins: dict[str, StatusBarPlugin] = {}
73
+ self._widgets: dict[str, QWidget] = {}
74
+ self._sides: dict[str, str] = {} # plugin_id -> "left" | "right"
75
+ self._loader: PluginLoader | None = None
76
+
77
+ # Quench the far-right size-grip notch.
78
+ self._statusbar.setSizeGripEnabled(False)
79
+
80
+ # A single container that spans the whole statusbar. With only one
81
+ # child, the statusbar's per-item frame style never has a chance
82
+ # to draw a notch between items, and there's no left/right boundary
83
+ # frame either.
84
+ self._container = QWidget(self._statusbar)
85
+ self._layout = QHBoxLayout(self._container)
86
+ self._layout.setContentsMargins(0, 0, 0, 0)
87
+ self._layout.setSpacing(ITEM_SPACING_PX)
88
+ # Stretch=1 makes the container fill the full statusbar width so
89
+ # the right-side plugins anchor to the actual right edge.
90
+ self._statusbar.addWidget(self._container, 1)
91
+
92
+ # Center stretch separating left and right plugin groups. Tracks
93
+ # its layout index so insertions on either side stay sorted.
94
+ self._stretch = QSpacerItem(
95
+ 0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum
96
+ )
97
+ self._layout.addSpacerItem(self._stretch)
98
+
99
+ # ------------------------------------------------------------------
100
+ # Helpers
101
+ # ------------------------------------------------------------------
102
+
103
+ def _stretch_index(self) -> int:
104
+ """Current layout index of the center stretch spacer.
105
+
106
+ We can't store a fixed index because inserts on either side shift
107
+ it; ``indexOf`` is O(n) but n is tiny.
108
+ """
109
+ return self._layout.indexOf(self._stretch)
110
+
111
+ @staticmethod
112
+ def _side_for(plugin: StatusBarPlugin) -> str:
113
+ """Map metadata.position to a side key."""
114
+ return "left" if plugin.metadata.position == "left" else "right"
115
+
116
+ def _insert_index(
117
+ self, side: str, priority: int, exclude_id: str | None = None
118
+ ) -> int:
119
+ """Find the layout index to insert a new plugin so the side stays sorted.
120
+
121
+ Lower priority sorts further left within each side. ``exclude_id``
122
+ skips the plugin being inserted if it has already been recorded
123
+ in :attr:`_plugins` / :attr:`_sides`.
124
+ """
125
+ stretch_idx = self._stretch_index()
126
+ # Count peers on the same side with priority <= ours.
127
+ peers_before = 0
128
+ for pid, sd in self._sides.items():
129
+ if sd != side or pid == exclude_id or pid not in self._plugins:
130
+ continue
131
+ if self._plugins[pid].metadata.priority <= priority:
132
+ peers_before += 1
133
+ if side == "left":
134
+ # Left plugins live in [0, stretch_idx). Place after the peers.
135
+ return peers_before
136
+ # Right plugins live in (stretch_idx, end). Place after the peers.
137
+ return stretch_idx + 1 + peers_before
138
+
139
+ # ------------------------------------------------------------------
140
+ # Loading
141
+ # ------------------------------------------------------------------
142
+
143
+ def load_plugins(self) -> int:
144
+ """Load status bar plugins from the registry and subscribe to future loads.
145
+
146
+ Discovers all registered statusbar plugins that are already loaded,
147
+ creates their widgets, and adds them to the status bar. Also subscribes
148
+ to the PluginLoader's plugin_loaded signal to handle plugins that load
149
+ later in the background.
150
+
151
+ Returns:
152
+ Number of plugins successfully loaded (already-loaded plugins only).
153
+ """
154
+ from lightfall.core import LFApplication
155
+ from lightfall.plugins.loader import PluginLoader
156
+ from lightfall.plugins.registry import PluginRegistry
157
+
158
+ app = LFApplication.get_instance()
159
+ services = app.services
160
+
161
+ try:
162
+ self._loader = services.get(PluginLoader)
163
+ self._loader.plugin_loaded.connect(self._on_plugin_loaded)
164
+ logger.debug("Subscribed to PluginLoader.plugin_loaded signal")
165
+ except Exception:
166
+ logger.warning("PluginLoader not available, dynamic loading disabled")
167
+
168
+ try:
169
+ registry = services.get(PluginRegistry)
170
+ except Exception:
171
+ logger.warning("PluginRegistry not available, no status bar plugins loaded")
172
+ return 0
173
+
174
+ loaded = 0
175
+
176
+ plugin_infos = registry.get_by_type("statusbar")
177
+
178
+ sorted_infos = sorted(
179
+ plugin_infos,
180
+ key=lambda info: getattr(
181
+ getattr(info.instance, "metadata", None),
182
+ "priority",
183
+ 100,
184
+ )
185
+ if info.instance
186
+ else 100,
187
+ )
188
+
189
+ for info in sorted_infos:
190
+ if info.instance is None:
191
+ logger.debug(
192
+ "Statusbar plugin {} not yet instantiated, will load via observer",
193
+ info.unique_id,
194
+ )
195
+ continue
196
+
197
+ plugin = info.instance
198
+ if self.add_plugin(plugin):
199
+ loaded += 1
200
+
201
+ logger.info("Loaded {} status bar plugins (more may load dynamically)", loaded)
202
+ return loaded
203
+
204
+ def _on_plugin_loaded(self, plugin_info: PluginInfo) -> None:
205
+ """Handle plugin_loaded signal from PluginLoader."""
206
+ if plugin_info.type_name != "statusbar":
207
+ return
208
+
209
+ if plugin_info.instance is None:
210
+ logger.warning(
211
+ "Statusbar plugin {} has no instance, skipping",
212
+ plugin_info.unique_id,
213
+ )
214
+ return
215
+
216
+ plugin_id = plugin_info.instance.metadata.id
217
+ if plugin_id in self._plugins:
218
+ logger.debug("Statusbar plugin {} already added", plugin_id)
219
+ return
220
+
221
+ logger.debug("Adding dynamically loaded statusbar plugin: {}", plugin_id)
222
+ if self.add_plugin(plugin_info.instance):
223
+ logger.info("Dynamically loaded status bar plugin: {}", plugin_id)
224
+
225
+ # ------------------------------------------------------------------
226
+ # Add / remove
227
+ # ------------------------------------------------------------------
228
+
229
+ def add_plugin(self, plugin: StatusBarPlugin) -> bool:
230
+ """Add a plugin to the status bar.
231
+
232
+ Creates the widget, connects signals, and inserts it into the
233
+ container at the position dictated by side + priority.
234
+
235
+ Args:
236
+ plugin: The StatusBarPlugin instance.
237
+
238
+ Returns:
239
+ True if successfully added.
240
+ """
241
+ plugin_id = plugin.metadata.id
242
+
243
+ if plugin_id in self._plugins:
244
+ logger.warning("Plugin {} already added to status bar", plugin_id)
245
+ return False
246
+
247
+ try:
248
+ side = self._side_for(plugin)
249
+
250
+ # Track BEFORE create so _insert_index sees the new plugin's
251
+ # bucket consistently if anything calls back during create.
252
+ self._plugins[plugin_id] = plugin
253
+ self._sides[plugin_id] = side
254
+
255
+ widget = plugin.create_widget(self._container)
256
+ # Backward-compat: custom create_widget overrides that don't
257
+ # populate self._widget themselves still get tracked here.
258
+ if plugin.widget is None:
259
+ plugin._widget = widget
260
+
261
+ widget.setVisible(plugin.is_visible)
262
+
263
+ insert_idx = self._insert_index(
264
+ side, plugin.metadata.priority, exclude_id=plugin_id
265
+ )
266
+ self._layout.insertWidget(insert_idx, widget)
267
+ self._widgets[plugin_id] = widget
268
+
269
+ try:
270
+ plugin.visibility_changed.connect(self._on_visibility_changed)
271
+ except (AttributeError, RuntimeError):
272
+ pass
273
+
274
+ plugin.connect_signals()
275
+ plugin.update()
276
+
277
+ logger.debug(
278
+ "Added status bar plugin: {} (priority={}, side={})",
279
+ plugin_id,
280
+ plugin.metadata.priority,
281
+ side,
282
+ )
283
+ return True
284
+
285
+ except Exception as e:
286
+ self._plugins.pop(plugin_id, None)
287
+ self._sides.pop(plugin_id, None)
288
+ self._widgets.pop(plugin_id, None)
289
+ logger.error("Failed to add status bar plugin {}: {}", plugin_id, e)
290
+ return False
291
+
292
+ def remove_plugin(self, plugin_id: str) -> bool:
293
+ """Remove a plugin from the status bar.
294
+
295
+ Disconnects signals and removes the widget.
296
+
297
+ Args:
298
+ plugin_id: The plugin identifier.
299
+
300
+ Returns:
301
+ True if successfully removed.
302
+ """
303
+ plugin = self._plugins.pop(plugin_id, None)
304
+ widget = self._widgets.pop(plugin_id, None)
305
+ self._sides.pop(plugin_id, None)
306
+
307
+ if plugin is None:
308
+ return False
309
+
310
+ try:
311
+ try:
312
+ plugin.visibility_changed.disconnect(self._on_visibility_changed)
313
+ except (AttributeError, RuntimeError, TypeError):
314
+ pass
315
+
316
+ plugin.disconnect_signals()
317
+
318
+ if widget is not None:
319
+ self._layout.removeWidget(widget)
320
+ widget.setParent(None)
321
+ widget.deleteLater()
322
+
323
+ logger.debug("Removed status bar plugin: {}", plugin_id)
324
+ return True
325
+
326
+ except Exception as e:
327
+ logger.error("Error removing status bar plugin {}: {}", plugin_id, e)
328
+ return False
329
+
330
+ def _on_visibility_changed(self, _visible: bool) -> None:
331
+ """Plugin visibility toggled.
332
+
333
+ ``QHBoxLayout`` collapses hidden widgets automatically (size
334
+ policy does not retain space when hidden), so the container
335
+ reflows without any manual work. Hook kept for future extension.
336
+ """
337
+
338
+ # ------------------------------------------------------------------
339
+ # Lifecycle / introspection
340
+ # ------------------------------------------------------------------
341
+
342
+ def cleanup(self) -> None:
343
+ """Clean up all plugins and disconnect signals.
344
+
345
+ Should be called when the main window is closing.
346
+ """
347
+ if self._loader is not None:
348
+ try:
349
+ self._loader.plugin_loaded.disconnect(self._on_plugin_loaded)
350
+ logger.debug("Disconnected from PluginLoader.plugin_loaded signal")
351
+ except (RuntimeError, TypeError):
352
+ pass
353
+ self._loader = None
354
+
355
+ for plugin_id in list(self._plugins.keys()):
356
+ self.remove_plugin(plugin_id)
357
+
358
+ logger.debug("Status bar manager cleanup complete")
359
+
360
+ def get_plugin(self, plugin_id: str) -> StatusBarPlugin | None:
361
+ """Get a plugin by ID."""
362
+ return self._plugins.get(plugin_id)
363
+
364
+ def list_plugins(self) -> list[str]:
365
+ """List all loaded plugin IDs."""
366
+ return list(self._plugins.keys())
367
+
368
+ def get_introspection_data(self) -> dict[str, Any]:
369
+ """Get introspection data for MCP tools."""
370
+ return {
371
+ "plugin_count": len(self._plugins),
372
+ "plugins": [
373
+ plugin.get_introspection_data()
374
+ for plugin in sorted(
375
+ self._plugins.values(),
376
+ key=lambda p: p.metadata.priority,
377
+ )
378
+ ],
379
+ }
@@ -0,0 +1,28 @@
1
+ """Built-in status bar plugins for NCS.
2
+
3
+ Provides the default status bar indicators:
4
+ - UserStatusPlugin: Shows current user
5
+ - AuthStatusPlugin: Shows authentication state
6
+ - ConnectionStatusPlugin: Shows online/offline status
7
+ - TiledStatusPlugin: Shows Tiled connection state
8
+ - ALSBeamStatusPlugin: Shows ALS synchrotron beam status
9
+ - ThreadStatusPlugin: Shows background task progress
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from lightfall.ui.statusbar.plugins.als_beam_status import ALSBeamStatusPlugin
15
+ from lightfall.ui.statusbar.plugins.auth_status import AuthStatusPlugin
16
+ from lightfall.ui.statusbar.plugins.connection_status import ConnectionStatusPlugin
17
+ from lightfall.ui.statusbar.plugins.thread_status import ThreadStatusPlugin
18
+ from lightfall.ui.statusbar.plugins.tiled_status import TiledStatusPlugin
19
+ from lightfall.ui.statusbar.plugins.user_status import UserStatusPlugin
20
+
21
+ __all__ = [
22
+ "UserStatusPlugin",
23
+ "AuthStatusPlugin",
24
+ "ConnectionStatusPlugin",
25
+ "TiledStatusPlugin",
26
+ "ALSBeamStatusPlugin",
27
+ "ThreadStatusPlugin",
28
+ ]
@@ -0,0 +1,218 @@
1
+ """ALS beam status plugin for NCS status bar.
2
+
3
+ Displays real-time ALS synchrotron beam current, lifetime, and availability.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import TYPE_CHECKING, Any, ClassVar
9
+
10
+ from PySide6.QtCore import QUrl, Slot
11
+ from PySide6.QtGui import QDesktopServices
12
+
13
+ from lightfall.plugins.statusbar_plugin import StatusBarPlugin, StatusBarPluginMetadata
14
+ from lightfall.ui.theme import ThemeManager
15
+ from lightfall.ui.toast import ToastManager
16
+ from lightfall.utils.logging import logger
17
+
18
+ if TYPE_CHECKING:
19
+ from lightfall.services.als_beam_status import ALSBeamData, ALSBeamStatusService
20
+
21
+
22
+ class ALSBeamStatusPlugin(StatusBarPlugin):
23
+ """Status bar plugin showing ALS beam status.
24
+
25
+ Displays beam current, lifetime, and availability with theme-aware coloring:
26
+ - success: Beam available (shutters open)
27
+ - error: Beam unavailable (shutters closed)
28
+ - text_secondary: Offline/disconnected from API
29
+
30
+ Clicking opens the ALS beam status page.
31
+ """
32
+
33
+ metadata: ClassVar[StatusBarPluginMetadata] = StatusBarPluginMetadata(
34
+ id="lightfall.statusbar.als_beam",
35
+ name="ALS Beam Status",
36
+ description="Shows ALS synchrotron beam current and status",
37
+ priority=45,
38
+ position="permanent",
39
+ tooltip="ALS beam status - click for details",
40
+ )
41
+
42
+ BEAM_STATUS_URL = "https://als.lbl.gov/beam-status/"
43
+
44
+ def __init__(self) -> None:
45
+ """Initialize the ALS beam status plugin."""
46
+ super().__init__()
47
+ self._service: ALSBeamStatusService | None = None
48
+ self._last_beam_available: bool | None = None
49
+ self._theme_manager: ThemeManager | None = None
50
+
51
+ @property
52
+ def name(self) -> str:
53
+ """Plugin name."""
54
+ return "als_beam_status"
55
+
56
+ def on_clicked(self) -> None:
57
+ """Open the ALS beam status page in the default browser."""
58
+ QDesktopServices.openUrl(QUrl(self.BEAM_STATUS_URL))
59
+
60
+ def update(self) -> None:
61
+ """Update the button with current beam status."""
62
+ if self._theme_manager is None:
63
+ self._theme_manager = ThemeManager.get_instance()
64
+
65
+ try:
66
+ from lightfall.services.als_beam_status import ALSBeamStatusService
67
+
68
+ service = ALSBeamStatusService.get_instance()
69
+ self._service = service
70
+
71
+ if not service.is_polling:
72
+ service.start_polling()
73
+
74
+ if not service.is_connected:
75
+ self._update_display_offline()
76
+ elif service.current_data is not None:
77
+ self._update_display_data(service.current_data)
78
+ else:
79
+ self._update_display_offline()
80
+
81
+ except Exception as e:
82
+ logger.debug("Could not get ALS beam status: {}", e)
83
+ self._update_display_offline()
84
+
85
+ def connect_signals(self) -> None:
86
+ """Connect to beam status service signals."""
87
+ if self._theme_manager is None:
88
+ self._theme_manager = ThemeManager.get_instance()
89
+ self._theme_manager.colors_changed.connect(self.update)
90
+
91
+ try:
92
+ from lightfall.services.als_beam_status import ALSBeamStatusService
93
+
94
+ service = ALSBeamStatusService.get_instance()
95
+ self._service = service
96
+ service.status_changed.connect(self._on_status_changed)
97
+ service.connection_changed.connect(self._on_connection_changed)
98
+
99
+ except Exception as e:
100
+ logger.debug("Could not connect to ALSBeamStatusService: {}", e)
101
+
102
+ def disconnect_signals(self) -> None:
103
+ """Disconnect from service signals."""
104
+ if self._service is not None:
105
+ try:
106
+ self._service.status_changed.disconnect(self._on_status_changed)
107
+ self._service.connection_changed.disconnect(self._on_connection_changed)
108
+ except RuntimeError:
109
+ pass
110
+
111
+ if self._theme_manager is not None:
112
+ try:
113
+ self._theme_manager.colors_changed.disconnect(self.update)
114
+ except RuntimeError:
115
+ pass
116
+
117
+ @Slot(object)
118
+ def _on_status_changed(self, data: ALSBeamData) -> None:
119
+ """Handle beam status update."""
120
+ self._update_display_data(data)
121
+
122
+ @Slot(bool)
123
+ def _on_connection_changed(self, connected: bool) -> None:
124
+ """Handle connection state change."""
125
+ if not connected:
126
+ self._update_display_offline()
127
+ else:
128
+ self.update()
129
+
130
+ def _update_display_data(self, data: ALSBeamData) -> None:
131
+ """Update display with beam data; toast on availability change."""
132
+ if (
133
+ self._last_beam_available is not None
134
+ and data.beam_available != self._last_beam_available
135
+ ):
136
+ self._notify_status_change(data.beam_available)
137
+ self._last_beam_available = data.beam_available
138
+
139
+ current_str = f"{data.beam_current:.1f} mA"
140
+ lifetime_str = f"{data.lifetime:.1f}h"
141
+ status_str = "Available" if data.beam_available else "Closed"
142
+
143
+ if self._theme_manager is None:
144
+ self._theme_manager = ThemeManager.get_instance()
145
+ colors = self._theme_manager.colors
146
+ color = colors.success if data.beam_available else colors.error
147
+
148
+ self.set_text(f"{current_str} | {lifetime_str} | {status_str}")
149
+ self.set_color(color)
150
+ self.set_tooltip(self._build_tooltip(data))
151
+
152
+ def _notify_status_change(self, beam_available: bool) -> None:
153
+ """Show a toast notification when ring status changes."""
154
+ toast = ToastManager.get_instance()
155
+ link = f'<a href="{self.BEAM_STATUS_URL}">Beam Status</a>'
156
+
157
+ if beam_available:
158
+ toast.success(
159
+ "ALS Ring Open",
160
+ f"Beam is now available · {link}",
161
+ duration=10000,
162
+ )
163
+ else:
164
+ toast.warning(
165
+ "ALS Ring Closed",
166
+ f"Beam is no longer available · {link}",
167
+ duration=10000,
168
+ )
169
+
170
+ def _update_display_offline(self) -> None:
171
+ """Update display for offline/error state."""
172
+ if self._theme_manager is None:
173
+ self._theme_manager = ThemeManager.get_instance()
174
+
175
+ self.set_text("Offline")
176
+ self.set_color(self._theme_manager.colors.text_secondary)
177
+
178
+ error_msg = ""
179
+ if self._service and self._service.last_error:
180
+ error_msg = f"\nError: {self._service.last_error}"
181
+ self.set_tooltip(f"ALS beam status unavailable{error_msg}")
182
+
183
+ def _build_tooltip(self, data: ALSBeamData) -> str:
184
+ """Build detailed tooltip from beam data."""
185
+ lines = [
186
+ "ALS Beam Status",
187
+ "─" * 25,
188
+ f"Current: {data.beam_current:.1f} mA",
189
+ f"Energy: {data.beam_energy:.2f} GeV",
190
+ f"Lifetime: {data.lifetime:.1f} hours",
191
+ f"Status: {'Available' if data.beam_available else 'Shutters Closed'}",
192
+ "",
193
+ f"X RMS: {data.x_rms:.1f} μm",
194
+ f"Y RMS: {data.y_rms:.1f} μm",
195
+ ]
196
+
197
+ if data.comment:
198
+ lines.extend(["", "Operations:", data.comment])
199
+
200
+ if data.timestamp:
201
+ lines.extend(["", f"Updated: {data.timestamp.strftime('%H:%M:%S')}"])
202
+
203
+ return "\n".join(lines)
204
+
205
+ def get_introspection_data(self) -> dict[str, Any]:
206
+ """Get introspection data for MCP tools."""
207
+ data = super().get_introspection_data()
208
+
209
+ try:
210
+ from lightfall.services.als_beam_status import ALSBeamStatusService
211
+
212
+ service = ALSBeamStatusService.get_instance()
213
+ data.update(service.get_introspection_data())
214
+
215
+ except Exception:
216
+ data["als_beam_connected"] = False
217
+
218
+ return data