@adea-ai/app-framework 0.39.3 → 0.39.4

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 (199) hide show
  1. package/README.md +158 -52
  2. package/dist/app/application.d.ts +0 -1
  3. package/dist/app/application.js +8 -6
  4. package/dist/app/create-application.js +3 -11
  5. package/dist/app/service-registry.d.ts +0 -1
  6. package/dist/app/service-registry.js +3 -3
  7. package/dist/app/value-guards.d.ts +2 -0
  8. package/dist/app/value-guards.js +6 -1
  9. package/dist/appearance/appearance-host.d.ts +1 -1
  10. package/dist/appearance/appearance-host.js +11 -2
  11. package/dist/appearance/appearance-preferences.d.ts +0 -1
  12. package/dist/appearance/custom-theme-import.d.ts +8 -2
  13. package/dist/appearance/custom-theme-import.js +58 -23
  14. package/dist/appearance/custom-theme-library.d.ts +3 -3
  15. package/dist/appearance/custom-theme-library.js +3 -3
  16. package/dist/appearance/theme-file-importer.d.ts +1 -1
  17. package/dist/appearance/theme-file-importer.js +2 -1
  18. package/dist/appearance/theme-library-mutation.d.ts +7 -0
  19. package/dist/appearance/theme-library-mutation.js +10 -2
  20. package/dist/appearance/theme-library-store.d.ts +17 -13
  21. package/dist/appearance/theme-library-store.js +35 -22
  22. package/dist/appearance/theme-record-adapter.js +1 -2
  23. package/dist/appearance/theme-registry.js +0 -1
  24. package/dist/cli/cli-runner.d.ts +3 -2
  25. package/dist/cli/cli-runner.js +5 -10
  26. package/dist/cli/release-assets-plan-cli.js +2 -2
  27. package/dist/cli/release-cut-cli.js +2 -3
  28. package/dist/cli/release-descriptor-staging-cli.js +2 -2
  29. package/dist/cli/release-finalize-cli.js +3 -3
  30. package/dist/cli/release-promote-cli.js +2 -2
  31. package/dist/cli/release-publish-cli.js +2 -2
  32. package/dist/cli/release-sign-cli.js +2 -1
  33. package/dist/cli/release-step-cli.js +2 -2
  34. package/dist/desktop/channel-proof.js +27 -11
  35. package/dist/desktop/client-assets.d.ts +6 -1
  36. package/dist/desktop/client-assets.js +16 -3
  37. package/dist/desktop/client-dev-proxy.d.ts +0 -2
  38. package/dist/desktop/client-dev-proxy.js +2 -2
  39. package/dist/desktop/desktop-client.js +2 -1
  40. package/dist/desktop/desktop-gateway.js +24 -82
  41. package/dist/desktop/desktop-host-websocket.d.ts +5 -1
  42. package/dist/desktop/desktop-host-websocket.js +9 -7
  43. package/dist/desktop/desktop-host.d.ts +5 -0
  44. package/dist/desktop/desktop-host.js +3 -0
  45. package/dist/desktop/desktop-stream.js +5 -10
  46. package/dist/desktop/typed-array-intrinsics.d.ts +6 -0
  47. package/dist/desktop/typed-array-intrinsics.js +13 -1
  48. package/dist/developer-app/developer-app.d.ts +1 -1
  49. package/dist/developer-app/developer-app.js +26 -13
  50. package/dist/framework-source.json +1 -1
  51. package/dist/installer/command-artifact.d.ts +1 -0
  52. package/dist/installer/command-artifact.js +47 -27
  53. package/dist/installer/installed-payload.js +3 -1
  54. package/dist/installer/installer-ci-bootstrap.js +5 -6
  55. package/dist/installer/installer-ci-preflight.js +3 -3
  56. package/dist/installer/installer-identity.d.ts +0 -22
  57. package/dist/installer/installer-identity.js +3 -53
  58. package/dist/installer/installer-image-mount.d.ts +0 -1
  59. package/dist/installer/installer-image-mount.js +1 -1
  60. package/dist/installer/installer-observation.d.ts +5 -5
  61. package/dist/installer/installer-observation.js +32 -47
  62. package/dist/installer/installer-process-cleanup.js +2 -2
  63. package/dist/installer/installer-renderer-evidence.js +7 -28
  64. package/dist/installer/installer-upgrade-command.js +8 -20
  65. package/dist/installer/installer-worker-guard.js +3 -3
  66. package/dist/native/cef-helper.js +4 -4
  67. package/dist/native/desktop-build.d.ts +0 -3
  68. package/dist/native/desktop-build.js +2 -2
  69. package/dist/native/electrobun-source-patch.d.ts +4 -0
  70. package/dist/native/electrobun-source-patch.js +5 -1
  71. package/dist/native/native-utilities.js +4 -3
  72. package/dist/native/pinned-download.d.ts +16 -0
  73. package/dist/native/pinned-download.js +42 -0
  74. package/dist/native/posix-launcher-build.js +15 -35
  75. package/dist/native/posix-tree-removal.js +21 -33
  76. package/dist/native/sidecar-services.d.ts +0 -2
  77. package/dist/native/sidecar-services.js +1 -1
  78. package/dist/native/sidecar.d.ts +3 -0
  79. package/dist/native/sidecar.js +15 -2
  80. package/dist/native/window-surface-store.js +3 -3
  81. package/dist/native/windows-extractor-build.d.ts +6 -16
  82. package/dist/native/windows-extractor-build.js +11 -14
  83. package/dist/release/feed-release-cut.d.ts +2 -6
  84. package/dist/release/feed-release-cut.js +5 -93
  85. package/dist/release/feed-state.js +1 -5
  86. package/dist/release/github-release-cut.js +5 -66
  87. package/dist/release/github-release-provenance.d.ts +2 -0
  88. package/dist/release/github-release-provenance.js +4 -7
  89. package/dist/release/github-release-publisher.js +2 -2
  90. package/dist/release/github-release-qualification.js +3 -3
  91. package/dist/release/local-release.d.ts +3 -3
  92. package/dist/release/local-release.js +12 -23
  93. package/dist/release/qualification-run.js +1 -1
  94. package/dist/release/release-assets-plan.js +1 -1
  95. package/dist/release/release-config.d.ts +7 -15
  96. package/dist/release/release-config.js +25 -29
  97. package/dist/release/release-cut-command.d.ts +1 -1
  98. package/dist/release/release-cut-command.js +1 -1
  99. package/dist/release/release-cut.d.ts +5 -32
  100. package/dist/release/release-cut.js +9 -55
  101. package/dist/release/release-descriptor-staging.js +3 -8
  102. package/dist/release/release-promotion.js +2 -1
  103. package/dist/release/release-publish-command.js +5 -15
  104. package/dist/release/release-qualification.js +1 -1
  105. package/dist/shared/bounded-body.d.ts +33 -0
  106. package/dist/shared/bounded-body.js +102 -0
  107. package/dist/shared/file-system.d.ts +12 -0
  108. package/dist/shared/file-system.js +40 -0
  109. package/dist/shell/app-shell.js +29 -14
  110. package/dist/shell/app-utilities.d.ts +2 -1
  111. package/dist/shell/app-utilities.js +2 -1
  112. package/dist/shell/application-menu.d.ts +1 -1
  113. package/dist/shell/application-menu.js +7 -3
  114. package/dist/shell/poll.d.ts +27 -0
  115. package/dist/shell/poll.js +88 -0
  116. package/dist/update-helper.bundle.js +268 -144
  117. package/dist/updates/channel-update-manager.js +0 -1
  118. package/dist/updates/desktop-updater.d.ts +9 -0
  119. package/dist/updates/desktop-updater.js +103 -50
  120. package/dist/updates/feed/release-feed.d.ts +7 -4
  121. package/dist/updates/feed/release-feed.js +3 -7
  122. package/dist/updates/feed/release-location.js +6 -26
  123. package/dist/updates/feed/release-version.d.ts +7 -2
  124. package/dist/updates/feed/release-version.js +9 -2
  125. package/dist/updates/feed/signed-release.d.ts +1 -1
  126. package/dist/updates/feed/signed-release.js +2 -2
  127. package/dist/updates/feed/update-discovery.js +2 -6
  128. package/dist/updates/helper/launch-gate-recovery.js +28 -78
  129. package/dist/updates/helper/resume-staging.d.ts +14 -3
  130. package/dist/updates/helper/resume-staging.js +23 -37
  131. package/dist/updates/helper/update-helper.d.ts +6 -2
  132. package/dist/updates/helper/update-helper.js +38 -33
  133. package/dist/updates/helper/update-resume.js +9 -6
  134. package/dist/updates/install/update-extraction.js +28 -8
  135. package/dist/updates/install/update-handoff-plan.d.ts +0 -1
  136. package/dist/updates/install/update-handoff-plan.js +3 -4
  137. package/dist/updates/install/update-swap-stage.js +1 -6
  138. package/dist/updates/install/update-swap.d.ts +5 -2
  139. package/dist/updates/install/update-swap.js +193 -72
  140. package/dist/updates/launch/helper-exit-wait.d.ts +6 -0
  141. package/dist/updates/launch/helper-exit-wait.js +18 -0
  142. package/dist/updates/launch/packaged-update-startup.js +8 -6
  143. package/dist/updates/launch/update-launch-gate.js +7 -14
  144. package/dist/updates/locks/stable-file.js +4 -1
  145. package/dist/updates/locks/update-helper-presence.d.ts +12 -0
  146. package/dist/updates/locks/update-helper-presence.js +27 -0
  147. package/dist/updates/retention/retention-cleanup.js +10 -9
  148. package/dist/updates/retention/retention-maintenance.d.ts +40 -0
  149. package/dist/updates/retention/retention-maintenance.js +95 -0
  150. package/dist/updates/retention/retention-prune-progress.js +4 -5
  151. package/dist/updates/retention/retirement-inventory.d.ts +13 -0
  152. package/dist/updates/retention/retirement-inventory.js +39 -31
  153. package/dist/updates/retention/retirement-records.d.ts +1 -4
  154. package/dist/updates/retention/retirement-records.js +18 -32
  155. package/dist/updates/retention/update-retention-marker.d.ts +4 -0
  156. package/dist/updates/retention/update-retention-marker.js +9 -14
  157. package/dist/updates/retention/update-retirement.d.ts +12 -0
  158. package/dist/updates/retention/update-retirement.js +59 -31
  159. package/dist/updates/update-adapter.d.ts +1 -23
  160. package/dist/updates/update-adapter.js +31 -24
  161. package/dist/updates/update-channel-store.d.ts +2 -1
  162. package/dist/updates/update-channel-store.js +6 -4
  163. package/dist/updates/update-manager.js +2 -2
  164. package/dist/updates/update-services.d.ts +1 -1
  165. package/dist/updates/update-services.js +9 -4
  166. package/dist/updates/update-state-store.d.ts +0 -2
  167. package/dist/updates/update-state-store.js +5 -12
  168. package/dist/updates/update-state.d.ts +6 -10
  169. package/dist/updates/update-state.js +1 -1
  170. package/dist/views/app-help.d.ts +1 -1
  171. package/dist/views/app-help.js +1 -3
  172. package/dist/views/appearance-surface.js +15 -8
  173. package/dist/views/update-surface.d.ts +1 -3
  174. package/dist/views/update-surface.js +2 -2
  175. package/package.json +18 -16
  176. package/src/app/application.tsx +13 -6
  177. package/src/appearance/appearance-host.tsx +17 -7
  178. package/src/appearance/appearance-preferences.ts +0 -1
  179. package/src/appearance/custom-theme-import.ts +99 -26
  180. package/src/appearance/custom-theme-library.ts +3 -2
  181. package/src/appearance/theme-file-importer.ts +3 -2
  182. package/src/appearance/theme-library-mutation.ts +20 -8
  183. package/src/appearance/theme-library-schema.ts +7 -0
  184. package/src/appearance/theme-library-store.ts +41 -26
  185. package/src/desktop/client-assets.ts +27 -12
  186. package/src/shell/app-shell.tsx +33 -13
  187. package/src/shell/app-utilities.tsx +7 -1
  188. package/src/shell/poll.ts +125 -0
  189. package/src/updates/feed/release-version.ts +11 -3
  190. package/src/updates/update-adapter.ts +27 -44
  191. package/src/updates/update-state.ts +7 -13
  192. package/src/views/app-help.tsx +1 -1
  193. package/src/views/appearance-surface.tsx +36 -8
  194. package/src/views/update-surface.tsx +0 -4
  195. package/templates/application/.github/workflows/release-assets.yml +2 -2
  196. package/templates/application/README.md +3 -3
  197. package/dist/native/cef-helper-download.d.ts +0 -1
  198. package/dist/native/cef-helper-download.js +0 -35
  199. package/src/desktop/client-response-lifecycle.ts +0 -305
@@ -16,17 +16,7 @@ export {
16
16
  type ClientAssetFileLimit,
17
17
  type ClientAssetVerificationCache,
18
18
  } from './client-asset-stream'
19
- export {
20
- CLIENT_ASSET_ASSET_PATTERN,
21
- CLIENT_ASSET_CHUNK_PATTERN,
22
- CLIENT_ASSET_MANIFEST_FILE,
23
- clientAssetAssetEvidenceKey,
24
- clientAssetChunkEvidenceKey,
25
- createClientAssetManifest,
26
- parseClientAssetManifest,
27
- snapshotClientAssetAllowlist,
28
- type ClientAssetManifest,
29
- } from './client-asset-manifest'
19
+ export { CLIENT_ASSET_MANIFEST_FILE } from './client-asset-manifest'
30
20
 
31
21
  const MIME: Record<string, string> = {
32
22
  '.html': 'text/html',
@@ -59,8 +49,19 @@ export type ClientOptions = {
59
49
  verificationCache?: ClientAssetVerificationCache
60
50
  /** Admission limit shared by streamed GET bodies; readers past it wait without a descriptor. */
61
51
  openFileLimit?: ClientAssetFileLimit
52
+ /**
53
+ * URL prefixes that hold only built assets, such as `/start-assets`. A missing path under one
54
+ * is a 404, never the SPA's index.html. `/assets` is always one.
55
+ */
56
+ assetPrefixes?: readonly string[]
62
57
  }
63
58
 
59
+ /*
60
+ * A missing script, style, font or wasm file is a stale chunk after an update, not a route.
61
+ * Answering it with index.html makes the webview report a MIME error instead of a 404.
62
+ */
63
+ const ASSET_EXTENSIONS = new Set(['.js', '.mjs', '.css', '.map', '.woff2', '.wasm'])
64
+
64
65
  const unavailable = (status = 404) =>
65
66
  new Response(null, { status, headers: { 'cache-control': 'no-store' } })
66
67
 
@@ -111,6 +112,14 @@ function deniedPrefixes(paths: readonly string[] | undefined): readonly string[]
111
112
  return prefixes
112
113
  }
113
114
 
115
+ const DEFAULT_ASSET_PREFIXES: readonly string[] = ['/assets']
116
+
117
+ function assetPrefixes(paths: readonly string[] | undefined): readonly string[] {
118
+ if (!paths?.length) return DEFAULT_ASSET_PREFIXES
119
+ // The root is never asset-only: it would turn every client route into a 404.
120
+ return [...DEFAULT_ASSET_PREFIXES, ...deniedPrefixes(paths).filter((prefix) => prefix !== '/')]
121
+ }
122
+
114
123
  /** A caller-owned, immutable client root kept available for the resolver's lifetime. */
115
124
  export type RetainedClientAssetRoot = Readonly<{
116
125
  root: string
@@ -281,7 +290,13 @@ async function serveClientInternal(
281
290
  }
282
291
  if (!metadata?.isFile()) {
283
292
  const folded = logical.toLowerCase()
284
- if (folded === '/assets' || folded.startsWith('/assets/')) return unavailable()
293
+ if (
294
+ ASSET_EXTENSIONS.has(extname(folded)) ||
295
+ assetPrefixes(options.assetPrefixes).some(
296
+ (prefix) => folded === prefix || folded.startsWith(prefix + '/')
297
+ )
298
+ )
299
+ return unavailable()
285
300
  filePath = join(root, 'index.html')
286
301
  metadata = await stat(filePath).catch(() => null)
287
302
  if (!metadata?.isFile()) return unavailable()
@@ -8,6 +8,7 @@ import {
8
8
  import {
9
9
  ContextualSidebar,
10
10
  type ContextualSidebarProps,
11
+ type ContextualSidebarRenderContext,
11
12
  } from '@adea-ai/ui/components/layout/contextual-sidebar'
12
13
  import { PixelPane } from '@adea-ai/ui/components/layout/pixel-pane'
13
14
  import { ShellRail } from '@adea-ai/ui/components/layout/shell-rail'
@@ -25,6 +26,7 @@ import {
25
26
  children,
26
27
  createComputed,
27
28
  createEffect,
29
+ createMemo,
28
30
  createSignal,
29
31
  lazy,
30
32
  onCleanup,
@@ -98,18 +100,32 @@ function getSidebarResponsiveMode(sidebar: ContextualSidebarProps | undefined) {
98
100
  /** Shared chrome and navigation composition; applications own routes and services. */
99
101
  export function ApplicationShell(props: ApplicationShellProps) {
100
102
  let sidebarToggle: HTMLButtonElement | undefined
103
+ // Read the sidebar prop once per change: an inline object (or a view's `sidebar()`) is
104
+ // rebuilt on every read, and the shell and sidebar read it about twenty times.
105
+ const sidebarProps = createMemo(() => props.sidebar)
106
+ // The slots re-render only when the app passes a different function, not whenever the
107
+ // width or open state changes, so dragging the resize handle keeps the sidebar's content.
108
+ const sidebarContent = createMemo(() => sidebarProps()?.content)
109
+ const sidebarHeader = createMemo(() => sidebarProps()?.header)
110
+ const sidebarFooter = createMemo(() => sidebarProps()?.footer)
111
+ const renderSidebarContent = (context: ContextualSidebarRenderContext) =>
112
+ sidebarContent()?.(context)
113
+ const renderSidebarHeader = (context: ContextualSidebarRenderContext) =>
114
+ sidebarHeader()?.(context)
115
+ const renderSidebarFooter = (context: ContextualSidebarRenderContext) =>
116
+ sidebarFooter()?.(context)
101
117
  const narrow = createMediaQuery(() =>
102
118
  props.drawer ? (props.narrowQuery ?? DEFAULT_NARROW_QUERY) : undefined
103
119
  )
104
120
  const sidebarMobile = createMediaQuery(() =>
105
- !props.drawer && props.sidebar ? '(max-width: 48rem)' : undefined
121
+ !props.drawer && sidebarProps() ? '(max-width: 48rem)' : undefined
106
122
  )
107
123
  const [sidebarElementMobile, setSidebarElementMobile] = createSignal<boolean>()
108
124
  // The shared callback's cleanup supplies the mode but not the detached element.
109
125
  const sidebarElements = new Map<boolean, HTMLElement>()
110
126
  const sidebarElementCallbacks = new Map<boolean, ContextualSidebarProps['onSidebarElement']>()
111
127
  createEffect(() => {
112
- const nextCallback = props.sidebar?.onSidebarElement
128
+ const nextCallback = sidebarProps()?.onSidebarElement
113
129
  for (const [mobile, element] of sidebarElements) {
114
130
  const previousCallback = sidebarElementCallbacks.get(mobile)
115
131
  if (previousCallback === nextCallback) continue
@@ -121,7 +137,7 @@ export function ApplicationShell(props: ApplicationShellProps) {
121
137
  const isSidebarMobile = () => {
122
138
  const mountedMode = sidebarElementMobile()
123
139
  if (mountedMode !== undefined) return mountedMode
124
- const mode = getSidebarResponsiveMode(props.sidebar)
140
+ const mode = getSidebarResponsiveMode(sidebarProps())
125
141
  if (mode === 'mobile') return true
126
142
  if (mode === 'desktop') return false
127
143
  return sidebarMobile()
@@ -129,20 +145,21 @@ export function ApplicationShell(props: ApplicationShellProps) {
129
145
  const restoreSidebarFocus = (sidebar: HTMLElement | undefined) => {
130
146
  const active = sidebar?.ownerDocument.activeElement
131
147
  if (
132
- !props.sidebar ||
148
+ !sidebarProps() ||
133
149
  sidebar?.dataset.open !== 'true' ||
134
150
  !sidebar.isConnected ||
135
151
  !active ||
136
152
  !sidebar.contains(active)
137
153
  )
138
154
  return
139
- const target = props.sidebar.restoreFocusRef ? props.sidebar.restoreFocusRef() : sidebarToggle
155
+ const restoreFocusRef = sidebarProps()?.restoreFocusRef
156
+ const target = restoreFocusRef ? restoreFocusRef() : sidebarToggle
140
157
  if (target?.isConnected) target.focus({ preventScroll: true })
141
158
  }
142
159
  let requestedModeInitialized = false
143
160
  let previousRequestedMode: ReturnType<typeof getSidebarResponsiveMode>
144
161
  createComputed(() => {
145
- const next = getSidebarResponsiveMode(props.sidebar)
162
+ const next = getSidebarResponsiveMode(sidebarProps())
146
163
  const shouldRestore =
147
164
  requestedModeInitialized && next === 'mobile' && previousRequestedMode !== 'mobile'
148
165
  previousRequestedMode = next
@@ -152,7 +169,7 @@ export function ApplicationShell(props: ApplicationShellProps) {
152
169
  const handleSidebarModeTransition: NonNullable<
153
170
  ContextualSidebarProps['onResponsiveModeTransition']
154
171
  > = (event) => {
155
- props.sidebar?.onResponsiveModeTransition?.(event)
172
+ sidebarProps()?.onResponsiveModeTransition?.(event)
156
173
  if (event.phase === 'before' && event.from === 'desktop' && event.to === 'mobile')
157
174
  restoreSidebarFocus(event.desktopSidebar)
158
175
  }
@@ -162,7 +179,7 @@ export function ApplicationShell(props: ApplicationShellProps) {
162
179
  ) => {
163
180
  if (element) {
164
181
  sidebarElements.set(mobile, element)
165
- const callback = props.sidebar?.onSidebarElement
182
+ const callback = sidebarProps()?.onSidebarElement
166
183
  sidebarElementCallbacks.set(mobile, callback)
167
184
  setSidebarElementMobile(mobile)
168
185
  callback?.(element, mobile)
@@ -183,12 +200,12 @@ export function ApplicationShell(props: ApplicationShellProps) {
183
200
  if (narrow()) setDrawerMounted(true)
184
201
  else setDrawerOpen(false)
185
202
  })
186
- const leading = () => props.sidebar ?? props.pane
203
+ const leading = () => sidebarProps() ?? props.pane
187
204
  const toggleVisible = () => narrow() || Boolean(leading())
188
205
  const expanded = () => (narrow() ? drawerOpen() : Boolean(leading()?.open))
189
206
  const toggleLabel = () => {
190
207
  if (narrow()) return 'Toggle navigation'
191
- const noun = props.sidebar ? 'contextual sidebar' : (props.pane?.label ?? 'sidebar')
208
+ const noun = sidebarProps() ? 'contextual sidebar' : (props.pane?.label ?? 'sidebar')
192
209
  return leading()?.open ? `Collapse ${noun}` : `Expand ${noun}`
193
210
  }
194
211
  const toggle = () => {
@@ -271,7 +288,7 @@ export function ApplicationShell(props: ApplicationShellProps) {
271
288
  navigation={props.navigation}
272
289
  workspace={props.workspace}
273
290
  sidebarOpen={!narrow() && leading()?.open && !isSidebarMobile()}
274
- alignSidebarAtNarrow={getSidebarResponsiveMode(props.sidebar) === 'desktop'}
291
+ alignSidebarAtNarrow={getSidebarResponsiveMode(sidebarProps()) === 'desktop'}
275
292
  sidebarWidth={leading()?.width}
276
293
  breadcrumb={props.title}
277
294
  search={props.search}
@@ -288,7 +305,7 @@ export function ApplicationShell(props: ApplicationShellProps) {
288
305
  tooltip={toggleLabel()}
289
306
  aria-label={toggleLabel()}
290
307
  aria-expanded={expanded()}
291
- aria-controls={narrow() || props.sidebar ? undefined : props.pane?.id}
308
+ aria-controls={narrow() || sidebarProps() ? undefined : props.pane?.id}
292
309
  onClick={toggle}
293
310
  >
294
311
  <Show
@@ -321,7 +338,7 @@ export function ApplicationShell(props: ApplicationShellProps) {
321
338
  </Show>
322
339
  <AppShellBody>
323
340
  <AppShellContent>
324
- <Show when={props.sidebar}>
341
+ <Show when={sidebarProps()}>
325
342
  {(sidebar) => (
326
343
  <PixelPane
327
344
  class="overflow-visible"
@@ -331,6 +348,9 @@ export function ApplicationShell(props: ApplicationShellProps) {
331
348
  <Show when={!props.drawer || !narrow()}>
332
349
  <ContextualSidebar
333
350
  {...sidebar()}
351
+ content={renderSidebarContent}
352
+ header={sidebarHeader() && renderSidebarHeader}
353
+ footer={sidebarFooter() && renderSidebarFooter}
334
354
  onSidebarElement={handleSidebarElement}
335
355
  onResponsiveModeTransition={handleSidebarModeTransition}
336
356
  restoreFocusRef={sidebar().restoreFocusRef ?? (() => sidebarToggle)}
@@ -29,8 +29,14 @@ import { resolveShortcutPlatform, type ShortcutPlatform } from './shortcut-platf
29
29
  import { hasEditableKeyboardTarget } from './keyboard-target'
30
30
  import { browserUpdateAdapter, type UpdateChannelSource } from '../updates/update-adapter'
31
31
 
32
- export * from './shortcut-platform'
32
+ export {
33
+ detectShortcutPlatform,
34
+ settingsShortcutLabel,
35
+ shortcutModifierKey,
36
+ type ShortcutPlatform,
37
+ } from './shortcut-platform'
33
38
  export { createMediaQuery, DEFAULT_NARROW_QUERY } from './media-query'
39
+ export { createPoll, type Poll, type PollOptions } from './poll'
34
40
 
35
41
  const AppearancePanel = lazy(() =>
36
42
  import('@adea-ai/ui/components/theme').then((module) => ({ default: module.AppearancePanel }))
@@ -0,0 +1,125 @@
1
+ import { createEffect, getOwner, onCleanup, untrack } from 'solid-js'
2
+
3
+ export type PollOptions = Readonly<{
4
+ /** Time from one run settling to the next starting. */
5
+ intervalMs: number
6
+ /** One tick. Its signal aborts when the poll stops, is disabled or its owner is disposed. */
7
+ run: (signal: AbortSignal) => unknown
8
+ /** Pause while the document is hidden and catch up when it is shown. Default true. */
9
+ visibleOnly?: boolean
10
+ /** Run once as soon as the poll starts. Default true. */
11
+ immediate?: boolean
12
+ /** Reactive switch; the poll stops while it reads false. */
13
+ enabled?: () => boolean
14
+ /** A tick's rejection. Polling continues either way. */
15
+ onError?: (error: unknown) => void
16
+ }>
17
+
18
+ export type Poll = Readonly<{
19
+ /** Run now, unless a tick is already running, and restart the interval from it. */
20
+ refresh(): void
21
+ /** Stop for good. Only needed outside a reactive owner, whose disposal stops the poll. */
22
+ stop(): void
23
+ }>
24
+
25
+ const hidden = () => typeof document !== 'undefined' && document.visibilityState === 'hidden'
26
+
27
+ /**
28
+ * A polling loop owned by the current reactive scope. Ticks never overlap: the next one is
29
+ * scheduled when the previous settles. With `visibleOnly` (the default) a hidden window holds
30
+ * no timer at all, and on being shown it runs at once if a tick is due. Disposal clears the
31
+ * timer and aborts the tick in flight, so a late answer can check its signal and drop itself.
32
+ */
33
+ export function createPoll(options: PollOptions): Poll {
34
+ if (!Number.isFinite(options.intervalMs) || options.intervalMs <= 0)
35
+ throw new RangeError('Invalid poll interval')
36
+ const visibleOnly = options.visibleOnly ?? true
37
+ let timer: ReturnType<typeof setTimeout> | undefined
38
+ let controller: AbortController | undefined
39
+ let running = false
40
+ let active = false
41
+ let lastStart = Number.NEGATIVE_INFINITY
42
+
43
+ const clear = () => {
44
+ if (timer !== undefined) clearTimeout(timer)
45
+ timer = undefined
46
+ }
47
+ const schedule = () => {
48
+ clear()
49
+ if (!active || running || (visibleOnly && hidden())) return
50
+ const wait = Math.max(0, lastStart + options.intervalMs - performance.now())
51
+ timer = setTimeout(tick, wait)
52
+ }
53
+ const tick = () => {
54
+ clear()
55
+ if (!active || running) return
56
+ running = true
57
+ lastStart = performance.now()
58
+ const signal = controller!.signal
59
+ let result: unknown
60
+ try {
61
+ result = options.run(signal)
62
+ } catch (error) {
63
+ result = Promise.reject(error)
64
+ }
65
+ void Promise.resolve(result)
66
+ .catch((error: unknown) => {
67
+ if (!signal.aborted) options.onError?.(error)
68
+ })
69
+ .finally(() => {
70
+ // A stopped poll already reset its state; a restarted one owns a new tick.
71
+ if (signal.aborted) return
72
+ running = false
73
+ // Measure the interval from the settled tick so a slow run cannot stack.
74
+ lastStart = performance.now()
75
+ schedule()
76
+ })
77
+ }
78
+ const onVisibility = () => (hidden() ? clear() : schedule())
79
+
80
+ const start = () => {
81
+ active = true
82
+ controller = new AbortController()
83
+ if (visibleOnly && typeof document !== 'undefined')
84
+ document.addEventListener('visibilitychange', onVisibility)
85
+ if (options.immediate ?? true) {
86
+ if (visibleOnly && hidden()) lastStart = Number.NEGATIVE_INFINITY
87
+ else return tick()
88
+ } else lastStart = performance.now()
89
+ schedule()
90
+ }
91
+ const stop = () => {
92
+ active = false
93
+ clear()
94
+ controller?.abort()
95
+ controller = undefined
96
+ running = false
97
+ if (typeof document !== 'undefined')
98
+ document.removeEventListener('visibilitychange', onVisibility)
99
+ }
100
+
101
+ if (options.enabled) {
102
+ const enabled = options.enabled
103
+ createEffect(() => {
104
+ if (!enabled()) return
105
+ // A tick's own reads must not restart the poll.
106
+ untrack(start)
107
+ onCleanup(stop)
108
+ })
109
+ } else if (getOwner()) {
110
+ // Start after the owner's setup, like an effect, so the first tick sees settled state.
111
+ createEffect(() => {
112
+ untrack(start)
113
+ onCleanup(stop)
114
+ })
115
+ } else {
116
+ start()
117
+ }
118
+ return {
119
+ refresh() {
120
+ if (!active || running) return
121
+ tick()
122
+ },
123
+ stop,
124
+ }
125
+ }
@@ -1,8 +1,16 @@
1
- /** The update channel an installation follows. */
2
- export type UpdateChannel = 'stable' | 'pre-release' | 'dev'
1
+ /** The update channel an installation follows: stable, or daily pre-release builds. */
2
+ export type UpdateChannel = 'stable' | 'pre-release'
3
3
 
4
4
  export function isUpdateChannel(value: unknown): value is UpdateChannel {
5
- return value === 'stable' || value === 'pre-release' || value === 'dev'
5
+ return value === 'stable' || value === 'pre-release'
6
+ }
7
+
8
+ /**
9
+ * Read a channel from saved settings or a caller. The retired `dev` channel, which
10
+ * older installs saved and older channel pickers still send, reads as pre-release.
11
+ */
12
+ export function readUpdateChannel(value: unknown): UpdateChannel | null {
13
+ return value === 'dev' ? 'pre-release' : isUpdateChannel(value) ? value : null
6
14
  }
7
15
 
8
16
  /**
@@ -4,7 +4,7 @@ import type {
4
4
  UpdateState,
5
5
  } from '@adea-ai/ui/components/composites/update-dialog'
6
6
  import { isUpdateChannel } from './feed/release-version'
7
- import { toUpdateState, type NativeUpdateSnapshotOf, type NativeUpdateState } from './update-state'
7
+ import { toUpdateState, type NativeUpdateState } from './update-state'
8
8
 
9
9
  export type { UpdateAdapter, UpdateChannel, UpdateState }
10
10
 
@@ -90,48 +90,6 @@ export function mirrorUpdateState(
90
90
  }
91
91
  }
92
92
 
93
- /** A native updater snapshot in snake_case, as Rust and older desktop hosts report it. */
94
- export type NativeUpdateSnapshot = NativeUpdateSnapshotOf<UpdateState['phase'], string | null>
95
-
96
- /** A native updater that answers with snake_case snapshots. */
97
- export type NativeUpdateAdapter = Readonly<{
98
- check(): Promise<NativeUpdateSnapshot>
99
- getStatus(): Promise<NativeUpdateSnapshot>
100
- install(expectedVersion: string): Promise<NativeUpdateSnapshot>
101
- isDesktopRuntime(): boolean
102
- pollIntervalMs?: number
103
- }>
104
-
105
- /** Map a snake_case native snapshot to the shared update state. */
106
- export function updateStateFromNative(
107
- update: NativeUpdateSnapshot,
108
- options: { releaseNotes?: boolean } = {}
109
- ): UpdateState {
110
- return toUpdateState(update, { includeReleaseNotes: Boolean(options.releaseNotes) })
111
- }
112
-
113
- /**
114
- * Bridge a snake_case native updater to the shared adapter. Release notes are dropped
115
- * unless requested, which keeps the dialog's per-release notes section hidden. An accessor is
116
- * read when an operation or polling interval is requested, so it can provide a replacement.
117
- */
118
- export function nativeUpdateAdapter(
119
- native: NativeUpdateAdapter | (() => NativeUpdateAdapter),
120
- options: { releaseNotes?: boolean } = {}
121
- ): UpdateAdapter {
122
- const current = typeof native === 'function' ? native : () => native
123
- return {
124
- check: async () => updateStateFromNative(await current().check(), options),
125
- getStatus: async () => updateStateFromNative(await current().getStatus(), options),
126
- install: async (expectedVersion) =>
127
- updateStateFromNative(await current().install(expectedVersion), options),
128
- isDesktopRuntime: () => current().isDesktopRuntime(),
129
- get pollIntervalMs() {
130
- return current().pollIntervalMs
131
- },
132
- }
133
- }
134
-
135
93
  /** The adapter for a build with no installer: the dialog explains updates are desktop-only. */
136
94
  export function browserUpdateAdapter(currentVersion = ''): UpdateAdapter {
137
95
  const state: UpdateState = { phase: 'unavailable', currentVersion }
@@ -192,7 +150,9 @@ export function parseDesktopUpdateStatus(value: unknown): DesktopUpdateStatus {
192
150
  throw new Error('Invalid desktop update status')
193
151
  const record = value as Record<string, unknown>
194
152
  const releaseNotes = record.release_notes ?? null
153
+ const changelogDigest = record.changelog_digest
195
154
  if (
155
+ (changelogDigest !== undefined && (!isText(changelogDigest) || changelogDigest.length > 128)) ||
196
156
  !isText(record.current_version) ||
197
157
  !isNullableText(record.available_version) ||
198
158
  !isUpdatePhase(record.phase) ||
@@ -211,6 +171,7 @@ export function parseDesktopUpdateStatus(value: unknown): DesktopUpdateStatus {
211
171
  current_version: record.current_version,
212
172
  available_version: record.available_version,
213
173
  changelog: record.changelog,
174
+ ...(changelogDigest === undefined ? {} : { changelog_digest: changelogDigest }),
214
175
  release_notes: releaseNotes,
215
176
  release_date: record.release_date,
216
177
  downloaded_bytes: record.downloaded_bytes,
@@ -253,10 +214,32 @@ export function desktopUpdateAdapter(
253
214
  } = {}
254
215
  ): UpdateAdapter {
255
216
  let latest: DesktopUpdateStatus | undefined
217
+ // The host sends the changelog's digest with each status; fetch the text once per digest.
218
+ let changelog: { digest: string; text: Promise<string> } | undefined
219
+ const withChangelog = async (status: DesktopUpdateStatus): Promise<DesktopUpdateStatus> => {
220
+ const digest = status.changelog_digest
221
+ if (digest === undefined || status.changelog) return status
222
+ if (changelog?.digest !== digest) {
223
+ const text = invoke('desktop_update_changelog').then((value) => {
224
+ if (!isText(value)) throw new Error('Invalid desktop update changelog')
225
+ return value
226
+ })
227
+ changelog = { digest, text }
228
+ // A failed read is retried on the next status instead of being cached.
229
+ text.catch(() => {
230
+ if (changelog?.text === text) changelog = undefined
231
+ })
232
+ }
233
+ try {
234
+ return { ...status, changelog: await changelog.text }
235
+ } catch {
236
+ return status
237
+ }
238
+ }
256
239
  const view = (status: DesktopUpdateStatus) =>
257
240
  toUpdateState(status, { includeReleaseNotes: options.releaseNotes !== false })
258
241
  const call = async (command: string, args?: Record<string, unknown>) => {
259
- const status = parseDesktopUpdateStatus(await invoke(command, args))
242
+ const status = await withChangelog(parseDesktopUpdateStatus(await invoke(command, args)))
260
243
  latest = status
261
244
  try {
262
245
  options.onStatus?.(status)
@@ -3,7 +3,11 @@ export type NativeUpdateState<Phase extends string = string> = Readonly<{
3
3
  phase: Phase
4
4
  current_version: string
5
5
  available_version: string | null
6
+ /** Empty when the host serves the changelog separately; see `changelog_digest`. */
6
7
  changelog: string
8
+ /** Identifies the changelog `desktop_update_changelog` returns, so a client fetches it once
9
+ * instead of receiving it in every polled status. Absent when `changelog` carries it. */
10
+ changelog_digest?: string
7
11
  release_notes: string | null
8
12
  release_date: string | null
9
13
  downloaded_bytes: number
@@ -13,19 +17,9 @@ export type NativeUpdateState<Phase extends string = string> = Readonly<{
13
17
  restart_required: boolean
14
18
  }>
15
19
 
16
- /**
17
- * A native updater snapshot: the service fields, with a release URL that may be
18
- * absent (`Url`) and release notes that older hosts omit.
19
- */
20
- export type NativeUpdateSnapshotOf<
21
- Phase extends string = string,
22
- Url extends string | null = string,
23
- > = Omit<NativeUpdateState<Phase>, 'github_url' | 'release_notes'> &
24
- Readonly<{ github_url: Url; release_notes?: string | null }>
25
-
26
20
  /** Project a native snapshot into the shared UI update dialog contract. */
27
- export function toUpdateState<Phase extends string, Url extends string | null = string>(
28
- update: NativeUpdateSnapshotOf<Phase, Url>,
21
+ export function toUpdateState<Phase extends string>(
22
+ update: NativeUpdateState<Phase>,
29
23
  options: { includeReleaseNotes?: boolean } = {}
30
24
  ) {
31
25
  return {
@@ -33,7 +27,7 @@ export function toUpdateState<Phase extends string, Url extends string | null =
33
27
  currentVersion: update.current_version,
34
28
  availableVersion: update.available_version,
35
29
  changelog: update.changelog,
36
- releaseNotes: options.includeReleaseNotes === false ? null : (update.release_notes ?? null),
30
+ releaseNotes: options.includeReleaseNotes === false ? null : update.release_notes,
37
31
  releaseDate: update.release_date,
38
32
  downloadedBytes: update.downloaded_bytes,
39
33
  totalBytes: update.total_bytes,
@@ -3,7 +3,7 @@ import { ModalDialog } from '@adea-ai/ui/components/ui/modal-dialog'
3
3
  import type { Accessor } from 'solid-js'
4
4
  import { standardShortcuts, type HelpLink, type HelpShortcut } from '../shell/help-shortcuts'
5
5
 
6
- export * from '../shell/help-shortcuts'
6
+ export type { HelpLink, HelpShortcut }
7
7
 
8
8
  export type ApplicationHelpProps = {
9
9
  open: boolean
@@ -22,10 +22,12 @@ import {
22
22
  type AppearancePreferencesV2,
23
23
  } from '../appearance/appearance-preferences'
24
24
  import {
25
+ CUSTOM_THEME_LIBRARY_RECOVERED,
25
26
  readCustomThemeLibrary,
26
27
  removeCustomThemeAtomically,
27
28
  subscribeCustomThemes,
28
29
  } from '../appearance/custom-theme-library'
30
+ import { customThemes } from '../appearance/theme-library-store'
29
31
  import { useTheme } from '../appearance/appearance-host'
30
32
  import { mirrorWindowSurface } from '../appearance/window-surface'
31
33
  import { Button } from '@adea-ai/ui/components/ui/button'
@@ -95,9 +97,11 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
95
97
  })
96
98
  // Mirror the glass choice to the native window whenever it changes (the
97
99
  // desktop host registers the transport; everywhere else this is a no-op).
98
- // The mirror is idempotent, so firing on the restored draft is harmless.
100
+ // Through a memo: each mirror is a persisted host write, and accent, theme and
101
+ // font edits leave the surface as it was.
102
+ const draftSurface = createMemo(() => editor.draft().surface)
99
103
  createEffect(() => {
100
- const surface = editor.draft().surface
104
+ const surface = draftSurface()
101
105
  mirrorWindowSurface(surface === 'translucent' ? 'theme' : surface)
102
106
  })
103
107
  const [customAccent, setCustomAccent] = createSignal('')
@@ -113,9 +117,9 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
113
117
  const [library, setLibrary] = createSignal(readCustomThemeLibrary(defaultPreferenceStorage()))
114
118
  onMount(() => {
115
119
  setLibrary(readCustomThemeLibrary(defaultPreferenceStorage()))
116
- onCleanup(
117
- subscribeCustomThemes(() => setLibrary(readCustomThemeLibrary(defaultPreferenceStorage())))
118
- )
120
+ // Every notification follows an update of the shared snapshot (a commit, or a
121
+ // read that found new storage), so take it instead of re-reading storage.
122
+ onCleanup(subscribeCustomThemes(() => setLibrary(customThemes())))
119
123
  })
120
124
  // Imported records are a projection of the library, not of the draft. Keep
121
125
  // the catalogue stable while controls update; imports and removals invalidate it.
@@ -130,6 +134,23 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
130
134
  library()
131
135
  return draftVariants({ lightThemeId: lightThemeId(), darkThemeId: darkThemeId() })
132
136
  })
137
+ // The editor reads each preview theme many times per change (about 50 reads per edit,
138
+ // 100 on mount), and a custom accent resolves its contrast roles on every read.
139
+ const draftAccent = createMemo(() => editor.draft().accent)
140
+ const previewPair = createMemo(
141
+ () => ({ lightThemeId: lightThemeId(), darkThemeId: darkThemeId() }),
142
+ undefined,
143
+ {
144
+ equals: (left, right) =>
145
+ left.lightThemeId === right.lightThemeId && left.darkThemeId === right.darkThemeId,
146
+ }
147
+ )
148
+ const lightPreview = createMemo(() =>
149
+ appearanceThemeForPreview(miniatures().light, draftAccent(), previewPair())
150
+ )
151
+ const darkPreview = createMemo(() =>
152
+ appearanceThemeForPreview(miniatures().dark, draftAccent(), previewPair())
153
+ )
133
154
  const [importStatus, setImportStatus] = createSignal('')
134
155
  const [importPending, setImportPending] = createSignal(false)
135
156
  const themeActionFence = createThemeLibraryActionFence(setImportStatus)
@@ -323,10 +344,10 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
323
344
  return publishedDraft()
324
345
  },
325
346
  get lightTheme() {
326
- return appearanceThemeForPreview(miniatures().light, editor.draft().accent, editor.draft())
347
+ return lightPreview()
327
348
  },
328
349
  get darkTheme() {
329
- return appearanceThemeForPreview(miniatures().dark, editor.draft().accent, editor.draft())
350
+ return darkPreview()
330
351
  },
331
352
  get resolvedAppearance() {
332
353
  // The editor's `system` draft previews the appearance the provider is
@@ -480,7 +501,14 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
480
501
  return
481
502
  }
482
503
  const result = await removeCustomThemeAtomically(theme.id, storage)
483
- themeActionFence.report(action, result.ok ? '' : result.error)
504
+ themeActionFence.report(
505
+ action,
506
+ result.ok
507
+ ? result.recovered
508
+ ? CUSTOM_THEME_LIBRARY_RECOVERED
509
+ : ''
510
+ : result.error
511
+ )
484
512
  }}
485
513
  >
486
514
  Remove
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  UpdateChannelControl,
3
3
  UpdateDialog,
4
- type ChannelControlActions,
5
4
  type UpdateAdapter,
6
5
  type UpdateChannel,
7
6
  type UpdateState,
@@ -13,9 +12,6 @@ import {
13
12
  type UpdateChannelSource,
14
13
  } from '../updates/update-adapter'
15
14
 
16
- export * from '../updates/update-adapter'
17
- export type { ChannelControlActions }
18
-
19
15
  export type ApplicationUpdateSurfaceProps = {
20
16
  adapter: UpdateAdapter
21
17
  /** The application's name, icon and build version shown by the dialog. */
@@ -1,5 +1,5 @@
1
1
  name: Desktop release assets
2
- # Builds, qualifies, signs and publishes one dev or daily tag. release:cut dispatches it;
2
+ # Builds, qualifies, signs and publishes one daily tag. release:cut dispatches it;
3
3
  # the framework CLIs verify this file's path (releaseWorkflows.assets), its
4
4
  # workflow_dispatch event and this exact run name.
5
5
  run-name: framework-release-assets:${{ inputs.tag }}
@@ -7,7 +7,7 @@ on:
7
7
  workflow_dispatch:
8
8
  inputs:
9
9
  tag:
10
- description: Existing dev or daily release tag
10
+ description: Existing daily release tag
11
11
  required: true
12
12
  type: string
13
13
  permissions: {}