@sirenodeck/sirenodeck 0.1.1-alpha.0 → 0.2.2

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 (84) hide show
  1. package/LICENSE +674 -21
  2. package/bin/dev.js +12 -2
  3. package/dist/main.mjs +3655 -1657
  4. package/package.json +18 -16
  5. package/src/api/protocol-internal.ts +16 -1
  6. package/src/assets/logo.png +0 -0
  7. package/src/assets/logo72x72.png +0 -0
  8. package/src/builtin-addons/brightness/buttons/brightness/config.ts +12 -2
  9. package/src/builtin-addons/coding-agents/buttons/agent/config.ts +5 -1
  10. package/src/builtin-addons/coding-agents/buttons/summary/config.ts +15 -3
  11. package/src/builtin-addons/coding-agents/buttons/summary/frontend.tsx +3 -3
  12. package/src/builtin-addons/coding-agents/global/backend.ts +56 -34
  13. package/src/builtin-addons/coding-agents/providers/opencode.ts +4 -5
  14. package/src/builtin-addons/core/buttons/action/config.ts +5 -2
  15. package/src/builtin-addons/core/buttons/change-deck/config.ts +6 -3
  16. package/src/builtin-addons/core/buttons/media-sample/config.ts +2 -2
  17. package/src/builtin-addons/core/buttons/toggle/config.ts +26 -9
  18. package/src/builtin-addons/date-time/buttons/custom/config.ts +5 -1
  19. package/src/builtin-addons/date-time/buttons/date/config.ts +2 -2
  20. package/src/builtin-addons/date-time/buttons/time/config.ts +5 -1
  21. package/src/builtin-addons/emoji-selector/buttons/category/config.ts +3 -3
  22. package/src/builtin-addons/emoji-selector/buttons/emoji/config.ts +5 -2
  23. package/src/builtin-addons/emoji-selector/support.ts +5 -2
  24. package/src/builtin-addons/global-services.ts +23 -0
  25. package/src/builtin-addons/internal-settings/buttons/app-info/config.ts +2 -1
  26. package/src/builtin-addons/internal-settings/buttons/brightness-down/config.ts +6 -1
  27. package/src/builtin-addons/internal-settings/buttons/brightness-up/config.ts +6 -1
  28. package/src/builtin-addons/media/backend.ts +54 -0
  29. package/src/builtin-addons/media/buttons/volume/volume-down/config.ts +1 -1
  30. package/src/builtin-addons/media/buttons/volume/volume-up/config.ts +1 -1
  31. package/src/builtin-addons/session/buttons/time/config.ts +1 -1
  32. package/src/builtin-addons/system-status/buttons/system-status/schemas.ts +32 -6
  33. package/src/builtin-addons/system-status/manifest.ts +49 -0
  34. package/src/builtin-addons/value-display/buttons/value-display/config.ts +23 -9
  35. package/src/builtin-addons/weather/buttons/weather/config.ts +11 -6
  36. package/src/cli/coding-agents-onboarding.ts +181 -34
  37. package/src/cli/commands/command-executor.ts +61 -0
  38. package/src/cli/commands/emulator-mode.ts +17 -2
  39. package/src/cli/commands/network-bind.ts +13 -9
  40. package/src/cli/commands/restart.ts +15 -5
  41. package/src/cli/commands/run.ts +174 -317
  42. package/src/cli/commands/service/render-template.ts +10 -0
  43. package/src/cli/commands/skills.ts +106 -0
  44. package/src/cli/commands/start.ts +39 -9
  45. package/src/cli/commands/stop.ts +3 -2
  46. package/src/cli/commands/system-requirements.ts +1 -0
  47. package/src/cli/index.ts +16 -3
  48. package/src/cli/main.ts +15 -2
  49. package/src/cli/package-manager.ts +6 -0
  50. package/src/cli/skills-first-run.ts +46 -0
  51. package/src/cli/startup-display.ts +35 -17
  52. package/src/config/mutation.ts +13 -1
  53. package/src/config/schemas.ts +3 -3
  54. package/src/config/validation.ts +7 -1
  55. package/src/core/icon-asset-registry.ts +11 -6
  56. package/src/deck/addon-handler-bridge.ts +246 -176
  57. package/src/deck/deck-config.ts +11 -2
  58. package/src/deck/deck-presentation-publisher.ts +116 -0
  59. package/src/deck/index.ts +13 -0
  60. package/src/deck/inject-config-ui-button.ts +23 -0
  61. package/src/deck/methods.ts +23 -0
  62. package/src/deck/position-settings-version-button.ts +20 -0
  63. package/src/deck/runtime/host-policy-coordinator.ts +186 -0
  64. package/src/deck/runtime/runtime.ts +123 -250
  65. package/src/deck/system-back-injection.ts +2 -1
  66. package/src/device/reconnecting.ts +8 -1
  67. package/src/index.ts +1 -2
  68. package/src/outputClient/emulator.ts +13 -0
  69. package/src/outputClient/index.ts +8 -0
  70. package/src/outputClient/real.ts +40 -45
  71. package/src/outputClient/remote-mirror.ts +77 -0
  72. package/src/outputClient/types.ts +2 -0
  73. package/src/render/editor-handler.ts +12 -1
  74. package/src/render/frontend-bridge-url.ts +10 -0
  75. package/src/render/push-startup-screen.ts +76 -0
  76. package/src/render/ws-bridge.ts +2 -0
  77. package/src/system/providers/active-app/capture-file.ts +61 -0
  78. package/src/system/providers/active-app/wayland-gnome.ts +26 -10
  79. package/src/system/providers/active-app.ts +6 -0
  80. package/src/system/providers/clipboard/darwin.ts +28 -4
  81. package/src/system/providers/url.ts +57 -0
  82. package/src/util/logger.ts +19 -3
  83. package/src/version.ts +3 -1
  84. package/src/vite/virtual-modules.ts +12 -6
@@ -4,10 +4,16 @@ import type { PubSub } from "@/core/pub-sub"
4
4
  import type { Store } from "@/core/store"
5
5
  import type { GestureKind } from "@/core/gesture-state"
6
6
  import type { ActiveAppProvider } from "@/system/providers/active-app"
7
- import type { SessionProvider, SessionState } from "@/system/providers/session"
7
+ import {
8
+ createNullSessionProvider,
9
+ type SessionProvider,
10
+ } from "@/system/providers/session"
8
11
  import { getRequiredCapability } from "@/system/requirements"
9
- import { compileDeckMatcher } from "@/system/glob-match"
10
12
  import type { Methods } from "../methods"
13
+ import {
14
+ createHostPolicyCoordinator,
15
+ type HostPolicyCoordinator,
16
+ } from "./host-policy-coordinator"
11
17
  import { describeEditorSurfaces } from "../editor-surfaces"
12
18
  import type {
13
19
  EditorAddonOwner,
@@ -15,13 +21,13 @@ import type {
15
21
  EditorSurfaceDescriptor,
16
22
  } from "../editor-surfaces"
17
23
 
18
- type ActiveAppProviderLike = Pick<ActiveAppProvider, "getActive" | "stop">
19
-
20
24
  export interface RuntimeButton {
21
25
  id: string
22
26
  type: string
23
27
  position?: number
24
28
  config?: unknown
29
+ icon?: string
30
+ label?: string
25
31
  actions?: {
26
32
  tap?: string
27
33
  dbltap?: string
@@ -143,9 +149,20 @@ export interface Runtime {
143
149
  invokeAction(buttonId: string, gesture: GestureKind): Promise<void>
144
150
  setGestureListener(listener: GestureListener | null): void
145
151
  invalidate(): void
146
- setActiveAppProvider(provider: ActiveAppProviderLike): void
152
+ setAvailableOverlayDeck(deckId: string | null): void
153
+ enterLock(): { activeDeckId: string; overlayDeckId: string | null }
154
+ restoreFromLock(snapshot: {
155
+ activeDeckId: string
156
+ overlayDeckId: string | null
157
+ }): void
158
+ /** @deprecated Host composition should use createHostPolicyCoordinator. */
159
+ setActiveAppProvider(
160
+ provider: Pick<ActiveAppProvider, "getActive" | "stop">,
161
+ ): void
162
+ /** @deprecated Host composition should use createHostPolicyCoordinator. */
147
163
  setSessionProvider(provider: SessionProvider): void
148
164
  isLockActive(): boolean
165
+ /** @deprecated Host composition should dispose its policy coordinator. */
149
166
  stopActiveAppPolling(): Promise<void>
150
167
  navStackDepth(): number
151
168
  hasOverlayDeckAvailable(): boolean
@@ -195,9 +212,13 @@ export const createRuntime = (options: CreateRuntimeOptions): Runtime => {
195
212
  }
196
213
  let brightness = 50
197
214
  let lockActive = false
198
- let preLockActiveDeckId: string | null = null
199
- let preLockOverlayDeckId: string | null = null
200
- let sessionUnsubscribe: (() => void) | null = null
215
+ let legacyActiveApp: Pick<ActiveAppProvider, "getActive" | "stop"> = {
216
+ getActive: async () => null,
217
+ stop: async () => undefined,
218
+ }
219
+ let legacySessionUnsubscribe: (() => void) | null = null
220
+ let legacyLockSnapshot: ReturnType<Runtime["enterLock"]> | null = null
221
+ let legacyPolicy: HostPolicyCoordinator | null = null
201
222
 
202
223
  const deckById = (id: string): RuntimeDeck | undefined =>
203
224
  decks.find((d) => d.id === id)
@@ -281,21 +302,24 @@ export const createRuntime = (options: CreateRuntimeOptions): Runtime => {
281
302
  navStack[navStack.length - 1] ??
282
303
  mainDeck.id
283
304
 
284
- const enterLockMode = (): void => {
285
- if (lockActive) return
286
- preLockActiveDeckId = snapshotRegularActiveDeckId()
287
- preLockOverlayDeckId = overlayDeckId
305
+ const enterLock = (): {
306
+ activeDeckId: string
307
+ overlayDeckId: string | null
308
+ } => {
309
+ const snapshot = {
310
+ activeDeckId: snapshotRegularActiveDeckId(),
311
+ overlayDeckId,
312
+ }
313
+ if (lockActive) return snapshot
288
314
  lockActive = true
289
- logger.info(
290
- { preLockActiveDeckId, preLockOverlayDeckId },
291
- "runtime: lock active",
292
- )
315
+ logger.info(snapshot, "runtime: lock active")
293
316
  pubSub.publish("runtime:lock-mode", {
294
317
  active: true,
295
318
  reason: "session-locked",
296
319
  })
297
320
  pubSub.publish("runtime:activeDeck", { deckId: "core:lock" })
298
321
  pubSub.publish("runtime:invalidate", undefined)
322
+ return snapshot
299
323
  }
300
324
 
301
325
  const navigateToDeck = (
@@ -566,8 +590,6 @@ export const createRuntime = (options: CreateRuntimeOptions): Runtime => {
566
590
  if (lockActive && found.deckId === "core:lock") {
567
591
  if (LOCK_FOLDER_NAV_TYPES.has(found.button.type)) {
568
592
  lockActive = false
569
- preLockActiveDeckId = null
570
- preLockOverlayDeckId = null
571
593
  if (overlayDeckId !== null) setOverlay(null)
572
594
  pubSub.publish("runtime:lock-mode", {
573
595
  active: false,
@@ -601,6 +623,24 @@ export const createRuntime = (options: CreateRuntimeOptions): Runtime => {
601
623
  ? found.button.actions?.dbltap
602
624
  : found.button.actions?.hold
603
625
 
626
+ const actionHandler = handlers.get(`${found.deckId}:${found.button.id}`)
627
+ const actionHandlerFn =
628
+ gesture === "tap"
629
+ ? actionHandler?.onTap
630
+ : gesture === "dbl-tap"
631
+ ? actionHandler?.onDblTap
632
+ : actionHandler?.onHold
633
+ if (userAction !== undefined && actionHandlerFn !== undefined) {
634
+ await actionHandlerFn({
635
+ buttonId,
636
+ deckId: found.deckId,
637
+ config: found.button.config,
638
+ gesture,
639
+ position: found.button.position,
640
+ })
641
+ return
642
+ }
643
+
604
644
  const deck = deckById(found.deckId)
605
645
  // ponytail: Array.isArray is tighter than — rejects
606
646
  // , , and non-array values uniformly. Defends
@@ -750,252 +790,83 @@ export const createRuntime = (options: CreateRuntimeOptions): Runtime => {
750
790
 
751
791
  void store
752
792
 
753
- const overlayDecks = (): Array<{
754
- deck: RuntimeDeck
755
- matcher: ReturnType<typeof compileDeckMatcher>
756
- specificity: number
757
- }> => {
758
- const result: Array<{
759
- deck: RuntimeDeck
760
- matcher: ReturnType<typeof compileDeckMatcher>
761
- specificity: number
762
- }> = []
763
- for (const deck of decks) {
764
- const hasProcess =
765
- deck.processNames !== undefined && deck.processNames.length > 0
766
- const hasWindow =
767
- deck.windowNames !== undefined && deck.windowNames.length > 0
768
- if (!hasProcess && !hasWindow) continue
769
- result.push({
770
- deck,
771
- matcher: compileDeckMatcher({
772
- processNames: deck.processNames,
773
- windowNames: deck.windowNames,
774
- }),
775
- specificity: (hasProcess ? 1 : 0) + (hasWindow ? 1 : 0),
776
- })
777
- }
778
- return result
779
- }
780
-
781
- let activeAppPoll: ReturnType<typeof setInterval> | null = null
782
- let activeAppProvider: ActiveAppProviderLike | null = null
783
- let lastOverlayDeckId: string | null = overlayDeckId
784
- let debounceTimer: ReturnType<typeof setTimeout> | null = null
785
- let pendingOverlayDeckId: string | null = null
786
- let latestActiveAppSnapshot: {
787
- name: string
788
- windowTitle: string | null
789
- processId: number | null
790
- } | null = null
791
-
792
- const applyOverlay = (deckId: string | null): void => {
793
+ const setAvailableOverlayDeck = (deckId: string | null): void => {
793
794
  if (deckId !== null && deckById(deckId) === undefined) {
794
- logger.warn({ deckId }, "active-app: overlay deck not found")
795
- return
796
- }
797
- if (deckId === null) {
798
- // ponytail: no overlay matches anymore. If we had one active, dismiss it.
799
- if (overlayDeckId !== null) {
800
- logger.info(
801
- { prevOverlayId: overlayDeckId },
802
- "active-app: dismissing previous overlay (no match)",
803
- )
804
- setOverlay(null, { source: "autoShow" })
805
- }
806
- lastOverlayDeckId = null
795
+ logger.warn({ deckId }, "setAvailableOverlayDeck: deck not found")
807
796
  return
808
797
  }
809
- if (overlayDeckId !== null && deckId !== overlayDeckId) {
810
- // ponytail: overlay mode is a routing branch. If the new match is
811
- // auto-show it replaces the current overlay; if it's not auto-show the
812
- // current overlay dismisses and the new match stays as available-only
813
- // (manual toggle required). In both cases the previous overlay's
814
- // overlayNavStacks entry is preserved for re-activation.
815
- const newDeck = deckById(deckId)
816
- if (newDeck === undefined) return
817
- if (newDeck.autoShow === true) {
818
- logger.info(
819
- { prevOverlayId: overlayDeckId, newMatch: deckId },
820
- "active-app: switching overlay (match moved, autoShow)",
821
- )
822
- setOverlay(deckId, { source: "autoShow" })
823
- } else {
824
- logger.info(
825
- { prevOverlayId: overlayDeckId, newMatch: deckId },
826
- "active-app: dismissing current overlay (new match is not autoShow)",
827
- )
828
- setOverlay(null, { source: "autoShow" })
829
- }
830
- lastOverlayDeckId = deckId
831
- return
832
- }
833
- if (deckId === lastOverlayDeckId) return
834
- const deck = deckById(deckId)
835
- if (deck === undefined) return
836
- logger.info(
837
- { deckId, autoShow: deck.autoShow === true },
838
- "active-app: applying overlay",
839
- )
840
- if (deck.autoShow !== true) {
841
- lastOverlayDeckId = deckId
842
- return
843
- }
844
- lastOverlayDeckId = deckId
845
- setOverlay(deckId, { source: "autoShow" })
798
+ if (availableOverlayDeckId === deckId) return
799
+ availableOverlayDeckId = deckId
800
+ pubSub.publish("runtime:overlay-available", { deckId })
846
801
  }
847
802
 
848
- const computeOverlayFor = (snapshot: {
849
- name: string
850
- windowTitle: string | null
851
- processId: number | null
852
- }): string | null => {
853
- let bestId: string | null = null
854
- let bestSpecificity = -1
855
- for (const { deck, matcher, specificity } of overlayDecks()) {
856
- if (!matcher(snapshot)) continue
857
- if (specificity > bestSpecificity) {
858
- bestId = deck.id
859
- bestSpecificity = specificity
860
- }
861
- }
862
- if (availableOverlayDeckId !== bestId) {
863
- const prev = availableOverlayDeckId
864
- availableOverlayDeckId = bestId
865
- if (bestId !== null) {
866
- logger.info(
867
- {
868
- from: prev,
869
- to: bestId,
870
- snapshot: {
871
- name: snapshot.name,
872
- windowTitle: snapshot.windowTitle,
873
- },
874
- },
875
- "active-app: overlay deck available",
876
- )
877
- } else if (prev !== null) {
878
- logger.info({ from: prev }, "active-app: no overlay deck matches")
879
- }
880
- pubSub.publish("runtime:overlay-available", { deckId: bestId })
803
+ const restoreFromLock = (snapshot: {
804
+ activeDeckId: string
805
+ overlayDeckId: string | null
806
+ }): void => {
807
+ if (!lockActive) return
808
+ lockActive = false
809
+ if (snapshot.overlayDeckId !== null) {
810
+ setOverlay(snapshot.overlayDeckId, { source: "autoShow" })
811
+ } else {
812
+ if (overlayDeckId !== null) setOverlay(null)
813
+ navigateToDeck(snapshot.activeDeckId, { addToHistory: false })
881
814
  }
882
- return bestId
883
- }
884
-
885
- const scheduleOverlay = (deckId: string | null): void => {
886
- pendingOverlayDeckId = deckId
887
- if (debounceTimer !== null) clearTimeout(debounceTimer)
888
- debounceTimer = setTimeout(() => {
889
- debounceTimer = null
890
- const next = pendingOverlayDeckId
891
- pendingOverlayDeckId = null
892
- applyOverlay(next)
893
- }, 200)
894
- }
895
-
896
- const startActiveAppLoop = (provider: ActiveAppProviderLike): void => {
897
- if (activeAppPoll !== null) return
898
- logger.info("active-app: poll loop started")
899
- activeAppPoll = setInterval(() => {
900
- void provider.getActive().then((snapshot) => {
901
- if (snapshot === null) {
902
- latestActiveAppSnapshot = null
903
- scheduleOverlay(null)
904
- return
905
- }
906
- latestActiveAppSnapshot = snapshot
907
- logger.debug(
908
- {
909
- snapshot: {
910
- name: snapshot.name,
911
- windowTitle: snapshot.windowTitle,
912
- },
913
- },
914
- "active-app: snapshot",
915
- )
916
- scheduleOverlay(computeOverlayFor(snapshot))
917
- })
918
- }, 1000)
815
+ pubSub.publish("runtime:lock-mode", {
816
+ active: false,
817
+ reason: "session-unlocked",
818
+ })
819
+ pubSub.publish("runtime:invalidate", undefined)
919
820
  }
920
821
 
921
- const stopActiveAppLoop = (): void => {
922
- if (debounceTimer !== null) {
923
- clearTimeout(debounceTimer)
924
- debounceTimer = null
925
- }
926
- pendingOverlayDeckId = null
927
- if (activeAppPoll !== null) {
928
- clearInterval(activeAppPoll)
929
- activeAppPoll = null
930
- }
822
+ const startLegacyPolicy = (): void => {
823
+ void legacyPolicy?.dispose()
824
+ legacyPolicy = createHostPolicyCoordinator({
825
+ runtime: {
826
+ enterLock,
827
+ getOverlay,
828
+ restoreFromLock,
829
+ setAvailableOverlayDeck,
830
+ setOverlay,
831
+ },
832
+ activeApp: legacyActiveApp,
833
+ session: createNullSessionProvider(),
834
+ decks,
835
+ logger,
836
+ })
837
+ legacyPolicy.start()
931
838
  }
932
839
 
933
- const setActiveAppProvider = (provider: ActiveAppProviderLike): void => {
934
- activeAppProvider = provider
935
- startActiveAppLoop(provider)
840
+ const setActiveAppProvider = (
841
+ provider: Pick<ActiveAppProvider, "getActive" | "stop">,
842
+ ): void => {
843
+ legacyActiveApp = provider
844
+ startLegacyPolicy()
936
845
  }
937
846
 
938
847
  const setSessionProvider = (provider: SessionProvider): void => {
939
- if (sessionUnsubscribe !== null) {
940
- sessionUnsubscribe()
941
- sessionUnsubscribe = null
942
- }
943
- const handle = (state: SessionState): void => {
944
- if (state === "locked" && !lockActive) {
945
- enterLockMode()
946
- return
947
- }
948
- if (state === "locked" && lockActive) {
949
- preLockActiveDeckId = snapshotRegularActiveDeckId()
950
- preLockOverlayDeckId = overlayDeckId
951
- logger.info("runtime: lock snapshot refreshed on re-lock")
848
+ legacySessionUnsubscribe?.()
849
+ legacySessionUnsubscribe = provider.subscribe((state) => {
850
+ if (state === "locked") {
851
+ legacyLockSnapshot = enterLock()
952
852
  return
953
853
  }
954
- if (state === "unlocked" && lockActive) {
955
- lockActive = false
956
- const overlaySnapshot = preLockOverlayDeckId
957
- const activeSnapshot = preLockActiveDeckId
958
- preLockActiveDeckId = null
959
- preLockOverlayDeckId = null
960
- if (
961
- overlaySnapshot !== null &&
962
- latestActiveAppSnapshot !== null &&
963
- computeOverlayFor(latestActiveAppSnapshot) === overlaySnapshot
964
- ) {
965
- logger.info(
966
- { overlayId: overlaySnapshot },
967
- "runtime: overlay auto-resumed on unlock (trigger still matches)",
968
- )
969
- setOverlay(overlaySnapshot, { source: "autoShow" })
970
- } else {
971
- if (overlayDeckId !== null) setOverlay(null)
972
- const restoreId = activeSnapshot ?? mainDeck.id
973
- logger.info(
974
- { restoreId, overlayWas: overlaySnapshot, triggerMatches: false },
975
- "runtime: lock cleared, restoring previous deck",
976
- )
977
- navigateToDeck(restoreId, { addToHistory: false })
978
- }
979
- pubSub.publish("runtime:lock-mode", {
980
- active: false,
981
- reason: "session-unlocked",
982
- })
983
- pubSub.publish("runtime:invalidate", undefined)
984
- }
985
- }
986
- sessionUnsubscribe = provider.subscribe(handle)
854
+ if (state !== "unlocked" || legacyLockSnapshot === null) return
855
+ restoreFromLock({
856
+ activeDeckId: legacyLockSnapshot.activeDeckId,
857
+ overlayDeckId:
858
+ legacyLockSnapshot.overlayDeckId === getOverlay()?.id
859
+ ? legacyLockSnapshot.overlayDeckId
860
+ : null,
861
+ })
862
+ legacyLockSnapshot = null
863
+ })
987
864
  }
988
865
 
989
866
  const stopActiveAppPolling = async (): Promise<void> => {
990
- stopActiveAppLoop()
991
- if (activeAppProvider !== null) {
992
- try {
993
- await activeAppProvider.stop()
994
- } catch (err) {
995
- logger.warn({ err }, "active-app: provider stop() failed")
996
- }
997
- activeAppProvider = null
998
- }
867
+ const policy = legacyPolicy
868
+ legacyPolicy = null
869
+ await policy?.dispose()
999
870
  }
1000
871
 
1001
872
  const runtime: Runtime = {
@@ -1015,21 +886,23 @@ export const createRuntime = (options: CreateRuntimeOptions): Runtime => {
1015
886
  invokeAction,
1016
887
  setGestureListener,
1017
888
  invalidate,
889
+ setAvailableOverlayDeck,
890
+ enterLock,
891
+ restoreFromLock,
1018
892
  setActiveAppProvider,
1019
893
  setSessionProvider,
1020
894
  isLockActive: () => lockActive,
1021
895
  stopActiveAppPolling,
1022
896
  navStackDepth: () => navStack.length,
1023
- hasOverlayDeckAvailable: () =>
1024
- availableOverlayDeckId !== null || pendingOverlayDeckId !== null,
897
+ hasOverlayDeckAvailable: () => availableOverlayDeckId !== null,
1025
898
  getAvailableOverlayDeckIcon: (): string | null => {
1026
- const id = availableOverlayDeckId ?? pendingOverlayDeckId
899
+ const id = availableOverlayDeckId
1027
900
  if (id === null) return null
1028
901
  const deck = deckById(id)
1029
902
  return deck?.icon ?? null
1030
903
  },
1031
904
  getAvailableOverlayDeckName: (): string | null => {
1032
- const id = availableOverlayDeckId ?? pendingOverlayDeckId
905
+ const id = availableOverlayDeckId
1033
906
  if (id === null) return null
1034
907
  const deck = deckById(id)
1035
908
  return deck?.name ?? null
@@ -29,7 +29,8 @@ export const computeSystemButtonForSlotN1 = (
29
29
  ): SystemButtonType | null => {
30
30
  if (state.lockActive === true) return null
31
31
  if (deck.isMain) return "core:settings-entry"
32
- if (state.inOverlayMode === true) return "core:overlay-toggle"
32
+ // `core:back` gives the split surface distinct tap (back) and dbl-tap
33
+ // (overlay toggle) actions, including while an overlay is active.
33
34
  return "core:back"
34
35
  }
35
36
 
@@ -39,6 +39,13 @@ export interface ReconnectingDevice extends StreamDeckDevice {
39
39
 
40
40
  const DEFAULT_RETRY_DELAY_MS = 2_000
41
41
 
42
+ const errorReason = (err: unknown): string => {
43
+ if (err instanceof Error) {
44
+ return err.message.length > 0 ? `${err.name}: ${err.message}` : err.name
45
+ }
46
+ return String(err)
47
+ }
48
+
42
49
  export const createReconnectingDevice = (
43
50
  initial: StreamDeckDevice,
44
51
  deps: ReconnectingDeviceDeps,
@@ -75,7 +82,7 @@ export const createReconnectingDevice = (
75
82
  detachCurrent?.()
76
83
  detachCurrent = null
77
84
  deps.logger.warn(
78
- { err: err instanceof Error ? err.message : String(err) },
85
+ { reason: errorReason(err) },
79
86
  "device: Stream Deck disconnected — holding the deck and watching for it to come back",
80
87
  )
81
88
  for (const h of errorHandlers) h(err)
package/src/index.ts CHANGED
@@ -17,6 +17,7 @@ export {
17
17
  PACKAGE_NAME,
18
18
  PROTOCOL_VERSION,
19
19
  SIRENO_ADDON_API_VERSION,
20
+ VERSION as cliVersion,
20
21
  } from "./version"
21
22
 
22
23
  export {
@@ -70,5 +71,3 @@ export {
70
71
  type TemporaryErrorSurfaceProps,
71
72
  type ThemeUiPresentation,
72
73
  } from "./ui"
73
-
74
- export const cliVersion = "0.1.0"
@@ -69,6 +69,12 @@ export class EmulatorOutputClient implements OutputClient {
69
69
  readonly kind = "emulator" as const
70
70
 
71
71
  private descriptor: DeviceDescriptor | null = null
72
+ private fixedDisplayDevice = false
73
+
74
+ setDisplayDevice(descriptor: DeviceDescriptor): void {
75
+ this.descriptor = descriptor
76
+ this.fixedDisplayDevice = true
77
+ }
72
78
 
73
79
  async validateReady(): Promise<void> {
74
80
  void this.kind
@@ -203,6 +209,13 @@ export class EmulatorOutputClient implements OutputClient {
203
209
  return
204
210
  }
205
211
  if (isSetDevice(message)) {
212
+ if (this.fixedDisplayDevice) {
213
+ logger.warn(
214
+ { deviceId: message.deviceId },
215
+ "emulator: ignoring device change while mirroring hardware",
216
+ )
217
+ return
218
+ }
206
219
  if (
207
220
  !VIRTUAL_MODELS.includes(
208
221
  message.deviceId as (typeof VIRTUAL_MODELS)[number],
@@ -1,9 +1,11 @@
1
1
  import { EmulatorOutputClient } from "./emulator"
2
2
  import { RealOutputClient } from "./real"
3
+ import { RemoteMirrorOutputClient } from "./remote-mirror"
3
4
  import type { OutputClient } from "./types"
4
5
 
5
6
  export interface SelectOutputClientOptions {
6
7
  readonly emulator: boolean
8
+ readonly remote?: boolean
7
9
  readonly xdgConfigHome: string
8
10
  }
9
11
 
@@ -13,6 +15,11 @@ export const selectOutputClient = (
13
15
  if (options.emulator) {
14
16
  return new EmulatorOutputClient()
15
17
  }
18
+ if (options.remote) {
19
+ return new RemoteMirrorOutputClient({
20
+ xdgConfigHome: options.xdgConfigHome,
21
+ })
22
+ }
16
23
  return new RealOutputClient({ xdgConfigHome: options.xdgConfigHome })
17
24
  }
18
25
 
@@ -23,4 +30,5 @@ export type {
23
30
  OutputKind,
24
31
  } from "./types"
25
32
  export { EmulatorOutputClient } from "./emulator"
33
+ export { RemoteMirrorOutputClient } from "./remote-mirror"
26
34
  export { RealOutputClient } from "./real"