@adea-ai/app-framework 0.30.0 → 0.32.0

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 (148) hide show
  1. package/README.md +26 -11
  2. package/dist/app/application.js +4 -2
  3. package/dist/app/create-application.js +4 -3
  4. package/dist/app/serial-queue.d.ts +5 -0
  5. package/dist/app/serial-queue.js +14 -0
  6. package/dist/app/value-guards.d.ts +15 -0
  7. package/dist/app/value-guards.js +29 -0
  8. package/dist/appearance/appearance-host.js +6 -0
  9. package/dist/appearance/appearance-preferences.js +6 -2
  10. package/dist/appearance/composition.d.ts +1 -1
  11. package/dist/appearance/custom-theme-import.js +12 -19
  12. package/dist/appearance/custom-theme-library.d.ts +5 -4
  13. package/dist/appearance/custom-theme-library.js +20 -2
  14. package/dist/appearance/editor.js +4 -1
  15. package/dist/appearance/legacy-imported-theme-token-projection.d.ts +84 -0
  16. package/dist/appearance/legacy-imported-theme-token-projection.js +142 -0
  17. package/dist/appearance/theme-record-adapter.js +37 -9
  18. package/dist/ci/toolchain-identity.js +1 -1
  19. package/dist/desktop/channel-proof.js +2 -1
  20. package/dist/desktop/client-asset-stream.js +6 -12
  21. package/dist/desktop/desktop-host.d.ts +25 -5
  22. package/dist/desktop/desktop-host.js +75 -20
  23. package/dist/framework-source.json +1 -1
  24. package/dist/installer/command-artifact.js +4 -3
  25. package/dist/installer/command-qualification-command.js +6 -5
  26. package/dist/installer/hosted-runner.d.ts +9 -2
  27. package/dist/installer/hosted-runner.js +18 -5
  28. package/dist/installer/installed-payload.js +20 -46
  29. package/dist/installer/installer-archive.d.ts +33 -0
  30. package/dist/installer/installer-archive.js +116 -0
  31. package/dist/installer/installer-ci-bootstrap.js +10 -6
  32. package/dist/installer/installer-extraction.js +54 -120
  33. package/dist/installer/installer-identity.js +33 -111
  34. package/dist/installer/installer-observation.js +3 -2
  35. package/dist/installer/installer-process-cleanup.js +7 -46
  36. package/dist/installer/installer-qualification-command.js +6 -5
  37. package/dist/installer/installer-upgrade-command.js +5 -5
  38. package/dist/installer/installer-worker-guard.js +2 -1
  39. package/dist/native/canonical-path.d.ts +5 -0
  40. package/dist/native/canonical-path.js +10 -0
  41. package/dist/native/cef-helper.js +5 -4
  42. package/dist/native/electrobun-source-patch.js +3 -2
  43. package/dist/native/{directory-exchange.d.ts → native-rename.d.ts} +2 -0
  44. package/dist/native/native-rename.js +126 -0
  45. package/dist/native/native-secret-store.js +2 -6
  46. package/dist/native/native-utilities.js +4 -4
  47. package/dist/native/posix-launcher-build.js +1 -1
  48. package/dist/native/posix-tree-removal.js +2 -2
  49. package/dist/native/windows-process.d.ts +9 -0
  50. package/dist/native/windows-process.js +60 -0
  51. package/dist/release/feed-release-cut.js +2 -1
  52. package/dist/release/framework-package-publish.js +1 -1
  53. package/dist/release/framework-update-lock.js +2 -1
  54. package/dist/release/github-cli.d.ts +18 -0
  55. package/dist/release/github-cli.js +13 -1
  56. package/dist/release/github-release-cut.js +3 -2
  57. package/dist/release/github-release-provenance.js +2 -1
  58. package/dist/release/github-release-publisher.js +2 -1
  59. package/dist/release/local-provenance.js +3 -2
  60. package/dist/release/local-release.js +6 -6
  61. package/dist/release/qualification-run.d.ts +25 -0
  62. package/dist/release/qualification-run.js +43 -0
  63. package/dist/release/release-artifact.js +3 -11
  64. package/dist/release/release-assets-plan.js +16 -6
  65. package/dist/release/release-config.js +14 -14
  66. package/dist/release/release-cut-command.js +14 -4
  67. package/dist/release/release-cut.js +3 -2
  68. package/dist/release/release-descriptor-staging.js +13 -27
  69. package/dist/release/release-finalize.js +2 -1
  70. package/dist/release/release-publication.js +3 -11
  71. package/dist/release/release-publish-command.js +15 -6
  72. package/dist/release/release-qualification.js +3 -2
  73. package/dist/release/retained-release-build.js +12 -12
  74. package/dist/shell/app-shell.js +76 -48
  75. package/dist/shell/app-utilities.d.ts +5 -3
  76. package/dist/shell/app-utilities.js +15 -7
  77. package/dist/shell/help-shortcuts.d.ts +4 -0
  78. package/dist/shell/help-shortcuts.js +38 -7
  79. package/dist/shell/keyboard-target.d.ts +2 -0
  80. package/dist/shell/keyboard-target.js +54 -0
  81. package/dist/shell/settings-sections.d.ts +5 -0
  82. package/dist/shell/settings-shortcuts.d.ts +10 -0
  83. package/dist/shell/settings-shortcuts.js +67 -0
  84. package/dist/update-helper.bundle.js +250 -190
  85. package/dist/updates/desktop-updater.js +53 -58
  86. package/dist/updates/packaged-launch-admission.js +3 -2
  87. package/dist/updates/packaged-release-config.js +6 -5
  88. package/dist/updates/release-feed.js +9 -9
  89. package/dist/updates/signed-release.js +5 -5
  90. package/dist/updates/stable-file.d.ts +18 -0
  91. package/dist/updates/stable-file.js +54 -1
  92. package/dist/updates/update-adapter.d.ts +2 -13
  93. package/dist/updates/update-arm.js +7 -5
  94. package/dist/updates/update-channel-store.js +7 -9
  95. package/dist/updates/update-discovery.js +30 -34
  96. package/dist/updates/update-download-cleanup.js +2 -1
  97. package/dist/updates/update-download.js +2 -4
  98. package/dist/updates/update-extraction.js +1 -1
  99. package/dist/updates/update-generation-lease.js +4 -3
  100. package/dist/updates/update-handoff-plan.js +3 -2
  101. package/dist/updates/update-helper.js +8 -6
  102. package/dist/updates/update-instance-lease.js +3 -2
  103. package/dist/updates/update-launch-gate.js +12 -25
  104. package/dist/updates/update-launch.js +3 -2
  105. package/dist/updates/update-lock.js +3 -2
  106. package/dist/updates/update-marker.js +3 -2
  107. package/dist/updates/update-process-fence.js +10 -39
  108. package/dist/updates/update-process-liveness.js +2 -1
  109. package/dist/updates/update-resume.js +26 -22
  110. package/dist/updates/update-retention-marker.js +7 -5
  111. package/dist/updates/update-retention-plan.js +2 -2
  112. package/dist/updates/update-retirement.js +40 -39
  113. package/dist/updates/update-state-store.js +29 -37
  114. package/dist/updates/update-state.d.ts +8 -3
  115. package/dist/updates/update-swap-stage.js +6 -5
  116. package/dist/updates/update-swap.d.ts +1 -1
  117. package/dist/updates/update-swap.js +8 -6
  118. package/dist/views/app-help.js +2 -1
  119. package/dist/views/app-settings.js +5 -2
  120. package/dist/views/appearance-surface.js +33 -19
  121. package/package.json +7 -13
  122. package/src/app/application.tsx +3 -1
  123. package/src/appearance/appearance-host.tsx +6 -0
  124. package/src/appearance/appearance-preferences.ts +7 -1
  125. package/src/appearance/composition.ts +3 -1
  126. package/src/appearance/custom-theme-import.ts +21 -37
  127. package/src/appearance/custom-theme-library.ts +21 -5
  128. package/src/appearance/editor.ts +7 -6
  129. package/src/appearance/legacy-imported-theme-token-projection.ts +51 -0
  130. package/src/appearance/theme-record-adapter.ts +58 -11
  131. package/src/desktop/client-asset-stream.ts +6 -12
  132. package/src/shell/app-shell.tsx +88 -58
  133. package/src/shell/app-utilities.tsx +29 -17
  134. package/src/shell/help-shortcuts.ts +77 -6
  135. package/src/shell/keyboard-target.ts +74 -0
  136. package/src/shell/settings-sections.ts +5 -0
  137. package/src/shell/settings-shortcuts.ts +116 -0
  138. package/src/updates/update-adapter.ts +2 -14
  139. package/src/updates/update-state.ts +11 -2
  140. package/src/views/app-settings.tsx +5 -3
  141. package/src/views/appearance-surface.tsx +63 -27
  142. package/dist/native/directory-exchange.js +0 -90
  143. package/dist/native/exclusive-rename.d.ts +0 -2
  144. package/dist/native/exclusive-rename.js +0 -52
  145. package/dist/release/retention-dry-run.d.ts +0 -46
  146. package/dist/release/retention-dry-run.js +0 -94
  147. package/dist/updates/update-exclusive-rename.d.ts +0 -3
  148. package/dist/updates/update-exclusive-rename.js +0 -5
@@ -1,10 +1,10 @@
1
+ import { isGitSha, isRecord } from "../app/value-guards.js";
1
2
  import { githubCli } from "./github-cli.js";
2
3
  import { lookupRelease } from "./github-release-lookup.js";
3
4
  import { parseReleaseConfig, platformPayloads, workflowFile } from "./release-config.js";
4
5
  import { createGitHubReleaseCutProvider } from "./github-release-cut.js";
5
6
  import { planReleaseAssets, releasePlanGitHubEnvironment } from "./release-assets-plan.js";
6
7
  // src/release/retained-release-build.ts
7
- var record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8
8
  var id = (value) => {
9
9
  if (typeof value === "number" && !Number.isSafeInteger(value)) throw new Error("Invalid GitHub identity");
10
10
  const text = String(value);
@@ -18,7 +18,7 @@ async function selectRetainedReleaseBuild(options) {
18
18
  "macos-arm64",
19
19
  "windows-x64",
20
20
  "linux-x64"
21
- ].includes(platform) || !record(config) || typeof config.appName !== "string" || env.RELEASE_TAG !== tag) throw new Error("Invalid retained build context");
21
+ ].includes(platform) || !isRecord(config) || typeof config.appName !== "string" || env.RELEASE_TAG !== tag) throw new Error("Invalid retained build context");
22
22
  const run = options.run ?? githubCli(releasePlanGitHubEnvironment(env));
23
23
  const plan = await planReleaseAssets({
24
24
  env,
@@ -39,7 +39,7 @@ async function selectRetainedReleaseBuild(options) {
39
39
  includeDraft: true
40
40
  });
41
41
  const hiddenDraft = release === null;
42
- if (!hiddenDraft && (!record(release) || release.tag_name !== tag)) throw new Error("Invalid release assets");
42
+ if (!hiddenDraft && (!isRecord(release) || release.tag_name !== tag)) throw new Error("Invalid release assets");
43
43
  const releaseAssets = [];
44
44
  if (!hiddenDraft) {
45
45
  const releaseId = id(release.id);
@@ -51,7 +51,7 @@ async function selectRetainedReleaseBuild(options) {
51
51
  if (page === 10) throw new Error("Too many release assets");
52
52
  }
53
53
  }
54
- if (releaseAssets.some((asset) => !record(asset) || typeof asset.name !== "string") || new Set(releaseAssets.map((asset) => asset.name)).size !== releaseAssets.length) throw new Error("Invalid release assets");
54
+ if (releaseAssets.some((asset) => !isRecord(asset) || typeof asset.name !== "string") || new Set(releaseAssets.map((asset) => asset.name)).size !== releaseAssets.length) throw new Error("Invalid release assets");
55
55
  const published = expected.some((name) => releaseAssets.some((asset) => asset.name === name));
56
56
  const provider = createGitHubReleaseCutProvider({
57
57
  repository,
@@ -64,35 +64,35 @@ async function selectRetainedReleaseBuild(options) {
64
64
  const candidates = [], seenArtifacts = /* @__PURE__ */ new Set(), seenRuns = /* @__PURE__ */ new Set();
65
65
  for (let page = 1; page <= 10; page++) {
66
66
  const response = await read(`${base}/actions/workflows/${workflowFile(assetsWorkflow)}/runs?event=workflow_dispatch&per_page=100&page=${page}`);
67
- if (!record(response) || !Array.isArray(response.workflow_runs) || response.workflow_runs.length > 100) throw new Error("Invalid release workflow listing");
67
+ if (!isRecord(response) || !Array.isArray(response.workflow_runs) || response.workflow_runs.length > 100) throw new Error("Invalid release workflow listing");
68
68
  for (const value of response.workflow_runs) {
69
- if (!record(value) || value.display_title !== `framework-release-assets:${tag}` || value.head_branch !== "main" || value.event !== "workflow_dispatch" || value.path !== assetsWorkflow) continue;
69
+ if (!isRecord(value) || value.display_title !== `framework-release-assets:${tag}` || value.head_branch !== "main" || value.event !== "workflow_dispatch" || value.path !== assetsWorkflow) continue;
70
70
  const runId = id(value.id);
71
71
  if (seenRuns.has(runId)) throw new Error("Duplicate workflow run");
72
72
  seenRuns.add(runId);
73
73
  if (value.status !== "completed" && runId !== env.GITHUB_RUN_ID) continue;
74
- if (typeof value.head_sha !== "string" || !/^[a-f0-9]{40}$/.test(value.head_sha) || !await provider.isMainAncestor(value.head_sha)) throw new Error("Untrusted retained workflow");
74
+ if (typeof value.head_sha !== "string" || !isGitSha(value.head_sha) || !await provider.isMainAncestor(value.head_sha)) throw new Error("Untrusted retained workflow");
75
75
  for (let artifactPage = 1; artifactPage <= 10; artifactPage++) {
76
76
  const listing = await read(`${base}/actions/runs/${runId}/artifacts?per_page=100&page=${artifactPage}`);
77
- if (!record(listing) || !Array.isArray(listing.artifacts) || listing.artifacts.length > 100) throw new Error("Invalid retained artifact listing");
77
+ if (!isRecord(listing) || !Array.isArray(listing.artifacts) || listing.artifacts.length > 100) throw new Error("Invalid retained artifact listing");
78
78
  for (const artifact of listing.artifacts) {
79
- if (!record(artifact) || typeof artifact.name !== "string") throw new Error("Invalid retained artifact");
79
+ if (!isRecord(artifact) || typeof artifact.name !== "string") throw new Error("Invalid retained artifact");
80
80
  const prefix = `framework-build-${tag}-${platform}-${plan.sourceSha}-r${runId}-a`;
81
81
  if (!artifact.name.startsWith(prefix)) continue;
82
82
  const attemptText = artifact.name.slice(prefix.length);
83
83
  if (artifact.expired === true) continue;
84
- if (!/^[1-9]\d{0,8}$/.test(attemptText) || artifact.expired !== false || typeof artifact.digest !== "string" || !/^sha256:[a-f0-9]{64}$/.test(artifact.digest) || !Number.isSafeInteger(artifact.size_in_bytes) || Number(artifact.size_in_bytes) < 1 || !record(artifact.workflow_run) || id(artifact.workflow_run.id) !== runId || artifact.workflow_run.head_sha !== value.head_sha || artifact.workflow_run.head_branch !== "main") throw new Error("Invalid retained artifact provenance");
84
+ if (!/^[1-9]\d{0,8}$/.test(attemptText) || artifact.expired !== false || typeof artifact.digest !== "string" || !/^sha256:[a-f0-9]{64}$/.test(artifact.digest) || !Number.isSafeInteger(artifact.size_in_bytes) || Number(artifact.size_in_bytes) < 1 || !isRecord(artifact.workflow_run) || id(artifact.workflow_run.id) !== runId || artifact.workflow_run.head_sha !== value.head_sha || artifact.workflow_run.head_branch !== "main") throw new Error("Invalid retained artifact provenance");
85
85
  const artifactId = id(artifact.id);
86
86
  if (seenArtifacts.has(artifactId)) throw new Error("Duplicate retained artifact");
87
87
  seenArtifacts.add(artifactId);
88
88
  const attempt = Number(attemptText);
89
89
  if (runId === env.GITHUB_RUN_ID && attempt >= Number(env.GITHUB_RUN_ATTEMPT)) continue;
90
90
  const attemptRun = await read(`${base}/actions/runs/${runId}/attempts/${attempt}`);
91
- if (!record(attemptRun) || id(attemptRun.id) !== runId || attemptRun.run_attempt !== attempt || attemptRun.head_sha !== value.head_sha || attemptRun.head_branch !== "main" || attemptRun.event !== "workflow_dispatch" || attemptRun.path !== assetsWorkflow || attemptRun.display_title !== `framework-release-assets:${tag}` || !record(attemptRun.repository) || attemptRun.repository.full_name !== repository || attemptRun.status !== "completed") throw new Error("Retained attempt provenance mismatch");
91
+ if (!isRecord(attemptRun) || id(attemptRun.id) !== runId || attemptRun.run_attempt !== attempt || attemptRun.head_sha !== value.head_sha || attemptRun.head_branch !== "main" || attemptRun.event !== "workflow_dispatch" || attemptRun.path !== assetsWorkflow || attemptRun.display_title !== `framework-release-assets:${tag}` || !isRecord(attemptRun.repository) || attemptRun.repository.full_name !== repository || attemptRun.status !== "completed") throw new Error("Retained attempt provenance mismatch");
92
92
  const jobs = [];
93
93
  for (let jobPage = 1; jobPage <= 10; jobPage++) {
94
94
  const data = await read(`${base}/actions/runs/${runId}/attempts/${attempt}/jobs?per_page=100&page=${jobPage}`);
95
- if (!record(data) || !Array.isArray(data.jobs) || data.jobs.length > 100 || data.jobs.some((job) => !record(job))) throw new Error("Invalid retained job listing");
95
+ if (!isRecord(data) || !Array.isArray(data.jobs) || data.jobs.length > 100 || data.jobs.some((job) => !isRecord(job))) throw new Error("Invalid retained job listing");
96
96
  jobs.push(...data.jobs);
97
97
  if (data.jobs.length < 100) break;
98
98
  if (jobPage === 10) throw new Error("Too many retained jobs");
@@ -1,5 +1,6 @@
1
+ import { hasEditableKeyboardTarget } from "./keyboard-target.js";
1
2
  import { className, createComponent, effect, insert, memo, mergeProps, template } from "solid-js/web";
2
- import { For, Show, Suspense, createEffect, createSignal, lazy, onCleanup, onMount } from "solid-js";
3
+ import { For, Show, Suspense, createComputed, createEffect, createSignal, lazy, onCleanup, onMount, untrack } from "solid-js";
3
4
  import { AppShell, AppShellBody, AppShellContent, AppShellMain, SkipLink } from "@adea-ai/ui/components/layout/app-shell";
4
5
  import { ContextualSidebar } from "@adea-ai/ui/components/layout/contextual-sidebar";
5
6
  import { PixelPane } from "@adea-ai/ui/components/layout/pixel-pane";
@@ -26,52 +27,72 @@ function createNarrow(query) {
26
27
  });
27
28
  return narrow;
28
29
  }
29
- var nonTextInputTypes = /* @__PURE__ */ new Set([
30
- "button",
31
- "checkbox",
32
- "color",
33
- "file",
34
- "hidden",
35
- "image",
36
- "radio",
37
- "range",
38
- "reset",
39
- "submit"
40
- ]);
41
- /** Whether an element or an ancestor in its composed path accepts text editing. */
42
- function isEditableElementPath(path) {
43
- let inheritedEditable = false;
44
- for (const target of path) {
45
- if (!(target instanceof Element)) continue;
46
- if (target instanceof HTMLInputElement) {
47
- if (!target.disabled && !target.readOnly && !nonTextInputTypes.has(target.type)) return true;
48
- } else if (target instanceof HTMLTextAreaElement) {
49
- if (!target.disabled && !target.readOnly) return true;
50
- }
51
- const contentEditable = target.getAttribute("contenteditable")?.toLowerCase();
52
- if (contentEditable === "false") return false;
53
- if (contentEditable === "" || contentEditable === "true" || contentEditable === "plaintext-only") return true;
54
- if (target instanceof HTMLElement && target.isContentEditable) inheritedEditable = true;
55
- if (target.ownerDocument.designMode?.toLowerCase() === "on") inheritedEditable = true;
56
- }
57
- return inheritedEditable;
58
- }
59
- function hasEditableTarget(event) {
60
- const path = event.composedPath();
61
- if (path.some((target) => target instanceof Element)) return isEditableElementPath(path);
62
- const activePath = [];
63
- let activeElement = document.activeElement;
64
- while (activeElement) {
65
- activePath.push(activeElement);
66
- activeElement = activeElement.shadowRoot?.activeElement ?? null;
30
+ function getSidebarResponsiveMode(sidebar) {
31
+ if (sidebar && "responsiveMode" in sidebar) {
32
+ const mode = sidebar.responsiveMode;
33
+ if (mode === "auto" || mode === "desktop" || mode === "mobile") return mode;
67
34
  }
68
- return isEditableElementPath(activePath);
69
35
  }
70
36
  /** Shared chrome and navigation composition; applications own routes and services. */
71
37
  function ApplicationShell(props) {
72
38
  let sidebarToggle;
73
39
  const narrow = createNarrow(() => props.drawer ? props.narrowQuery ?? "(max-width: 799px)" : void 0);
74
40
  const sidebarMobile = createNarrow(() => !props.drawer && props.sidebar ? "(max-width: 48rem)" : void 0);
41
+ const [sidebarElementMobile, setSidebarElementMobile] = createSignal();
42
+ const sidebarElements = /* @__PURE__ */ new Map();
43
+ const sidebarElementCallbacks = /* @__PURE__ */ new Map();
44
+ createEffect(() => {
45
+ const nextCallback = props.sidebar?.onSidebarElement;
46
+ for (const [mobile, element] of sidebarElements) {
47
+ const previousCallback = sidebarElementCallbacks.get(mobile);
48
+ if (previousCallback === nextCallback) continue;
49
+ previousCallback?.(void 0, mobile);
50
+ nextCallback?.(element, mobile);
51
+ sidebarElementCallbacks.set(mobile, nextCallback);
52
+ }
53
+ });
54
+ const isSidebarMobile = () => {
55
+ const mountedMode = sidebarElementMobile();
56
+ if (mountedMode !== void 0) return mountedMode;
57
+ const mode = getSidebarResponsiveMode(props.sidebar);
58
+ if (mode === "mobile") return true;
59
+ if (mode === "desktop") return false;
60
+ return sidebarMobile();
61
+ };
62
+ const restoreSidebarFocus = (sidebar) => {
63
+ const active = sidebar?.ownerDocument.activeElement;
64
+ if (!props.sidebar || sidebar?.dataset.open !== "true" || !sidebar.isConnected || !active || !sidebar.contains(active)) return;
65
+ const target = props.sidebar.restoreFocusRef ? props.sidebar.restoreFocusRef() : sidebarToggle;
66
+ if (target?.isConnected) target.focus({ preventScroll: true });
67
+ };
68
+ let requestedModeInitialized = false;
69
+ let previousRequestedMode;
70
+ createComputed(() => {
71
+ const next = getSidebarResponsiveMode(props.sidebar);
72
+ const shouldRestore = requestedModeInitialized && next === "mobile" && previousRequestedMode !== "mobile";
73
+ previousRequestedMode = next;
74
+ requestedModeInitialized = true;
75
+ if (shouldRestore) untrack(() => restoreSidebarFocus(sidebarElements.get(false)));
76
+ });
77
+ const handleSidebarModeTransition = (event) => {
78
+ props.sidebar?.onResponsiveModeTransition?.(event);
79
+ if (event.phase === "before" && event.from === "desktop" && event.to === "mobile") restoreSidebarFocus(event.desktopSidebar);
80
+ };
81
+ const handleSidebarElement = (element, mobile) => {
82
+ if (element) {
83
+ sidebarElements.set(mobile, element);
84
+ const callback = props.sidebar?.onSidebarElement;
85
+ sidebarElementCallbacks.set(mobile, callback);
86
+ setSidebarElementMobile(mobile);
87
+ callback?.(element, mobile);
88
+ return;
89
+ }
90
+ const callback = sidebarElementCallbacks.get(mobile);
91
+ sidebarElements.delete(mobile);
92
+ sidebarElementCallbacks.delete(mobile);
93
+ setSidebarElementMobile(void 0);
94
+ callback?.(void 0, mobile);
95
+ };
75
96
  const [drawerOpen, setDrawerOpen] = createSignal(false);
76
97
  const [drawerMounted, setDrawerMounted] = createSignal(false);
77
98
  createEffect(() => {
@@ -92,14 +113,14 @@ function ApplicationShell(props) {
92
113
  current?.onOpenChange(!current.open);
93
114
  };
94
115
  const handleToggle = (event) => {
95
- if (event.defaultPrevented || !toggleVisible() || !(event.metaKey || event.ctrlKey) || event.altKey || event.shiftKey || event.key.toLowerCase() !== "b" || hasEditableTarget(event)) return;
116
+ if (event.defaultPrevented || !toggleVisible() || !(event.metaKey || event.ctrlKey) || event.altKey || event.shiftKey || event.key.toLowerCase() !== "b" || hasEditableKeyboardTarget(event)) return;
96
117
  event.preventDefault();
97
- toggle();
118
+ if (!event.repeat) toggle();
98
119
  };
99
120
  const handleSearch = (event) => {
100
121
  if (!props.onSearch || event.defaultPrevented || !(event.metaKey || event.ctrlKey) || event.altKey || event.shiftKey || event.key.toLowerCase() !== "k") return;
101
122
  event.preventDefault();
102
- props.onSearch();
123
+ if (!event.repeat) props.onSearch();
103
124
  };
104
125
  onMount(() => {
105
126
  window.addEventListener("keydown", handleSearch);
@@ -130,7 +151,10 @@ function ApplicationShell(props) {
130
151
  return props.workspace;
131
152
  },
132
153
  get sidebarOpen() {
133
- return memo(() => !!!narrow())() && leading()?.open;
154
+ return memo(() => !!(!narrow() && leading()?.open))() && !isSidebarMobile();
155
+ },
156
+ get alignSidebarAtNarrow() {
157
+ return getSidebarResponsiveMode(props.sidebar) === "desktop";
134
158
  },
135
159
  get sidebarWidth() {
136
160
  return leading()?.width;
@@ -287,7 +311,7 @@ function ApplicationShell(props) {
287
311
  children: (sidebar) => createComponent(PixelPane, {
288
312
  "class": "overflow-visible",
289
313
  get hidden() {
290
- return narrow() || sidebarMobile();
314
+ return narrow() || isSidebarMobile();
291
315
  },
292
316
  get width() {
293
317
  return memo(() => !!sidebar().open)() ? sidebar().width : 0;
@@ -298,9 +322,13 @@ function ApplicationShell(props) {
298
322
  return !props.drawer || !narrow();
299
323
  },
300
324
  get children() {
301
- return createComponent(ContextualSidebar, mergeProps(sidebar, { get restoreFocusRef() {
302
- return sidebar().restoreFocusRef ?? (() => sidebarToggle);
303
- } }));
325
+ return createComponent(ContextualSidebar, mergeProps(sidebar, {
326
+ onSidebarElement: handleSidebarElement,
327
+ onResponsiveModeTransition: handleSidebarModeTransition,
328
+ get restoreFocusRef() {
329
+ return sidebar().restoreFocusRef ?? (() => sidebarToggle);
330
+ }
331
+ }));
304
332
  }
305
333
  });
306
334
  }
@@ -2,7 +2,7 @@ import { type AccountMenuItem } from '@adea-ai/ui/components/composites/account-
2
2
  import type { UpdateAdapter, UpdateState } from '@adea-ai/ui/components/composites/update-dialog';
3
3
  import { type ThemeProviderProps } from '@adea-ai/ui/components/theme/lazy';
4
4
  import { type JSX } from 'solid-js';
5
- import type { HelpLink, HelpShortcut } from './help-shortcuts';
5
+ import { type HelpLink, type HelpShortcut } from './help-shortcuts';
6
6
  import { type ApplicationSettingsSection } from './settings-sections';
7
7
  import { type ShortcutPlatform } from './shortcut-platform';
8
8
  import { type UpdateChannelSource } from '../updates/update-adapter';
@@ -64,8 +64,10 @@ export type ApplicationHelpConfig = Readonly<{
64
64
  links: readonly HelpLink[];
65
65
  /** App-specific shortcuts, listed before the ones the framework binds. */
66
66
  shortcuts?: readonly HelpShortcut[];
67
- /** Whether the host binds the framework search chord. */
67
+ /** Whether Help lists Open search; defaults to whether the Application binds it. */
68
68
  search?: boolean;
69
+ /** Whether the enclosing Application shell consumes Meta/Ctrl+K despite hiding its help row. */
70
+ searchBinding?: boolean;
69
71
  }>;
70
72
  export type ApplicationAccountMenuConfig = Readonly<{
71
73
  /** The trigger's accessible name; defaults to `Application settings`. */
@@ -76,7 +78,7 @@ export type ApplicationAccountMenuConfig = Readonly<{
76
78
  onIntent?(): void;
77
79
  /** A chord drawn on the Settings row, e.g. `settingsShortcutLabel('mac')`. */
78
80
  settingsShortcut?: string;
79
- /** The parseable chord behind `settingsShortcut`; defaults to `Meta+, Control+,`. */
81
+ /** Space-separated ARIA chords behind `settingsShortcut`; defaults to `Meta+, Control+,`. */
80
82
  settingsKeyshortcuts?: string;
81
83
  /** Show the Appearance item (the default). Apps with their own control can hide it. */
82
84
  appearance?: boolean;
@@ -1,5 +1,7 @@
1
- import { defineSettingsSections, settingsSectionFromHash } from "./settings-sections.js";
1
+ import { hasEditableKeyboardTarget } from "./keyboard-target.js";
2
2
  import { detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey } from "./shortcut-platform.js";
3
+ import { matchesSettingsKeyshortcuts, parseSettingsKeyshortcuts } from "./settings-shortcuts.js";
4
+ import { defineSettingsSections, settingsSectionFromHash } from "./settings-sections.js";
3
5
  import { browserUpdateAdapter } from "../updates/update-adapter.js";
4
6
  import { createComponent, memo, mergeProps, template } from "solid-js/web";
5
7
  import { Show, Suspense, createEffect, createMemo, createSignal, lazy, on, onCleanup, onMount } from "solid-js";
@@ -21,10 +23,6 @@ function ApplicationThemeProvider(props) {
21
23
  } }));
22
24
  }
23
25
  var appearanceSectionId = "appearance";
24
- var settingsKeyshortcuts = "Meta+, Control+,";
25
- function isSettingsChord(event) {
26
- return !event.defaultPrevented && (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey && event.key === ",";
27
- }
28
26
  function placeAppearance(sections, appearance, position) {
29
27
  const index = position === "end" ? sections.length : typeof position === "number" ? Math.max(0, Math.min(sections.length, Math.trunc(position))) : 0;
30
28
  return [
@@ -119,8 +117,16 @@ function ApplicationUtilities(props) {
119
117
  openHelp: () => open("help"),
120
118
  openUpdates: () => openUpdates()
121
119
  }));
120
+ const settingsKeyshortcuts = createMemo(() => {
121
+ const value = props.accountMenu?.settingsKeyshortcuts ?? "Meta+, Control+,";
122
+ return {
123
+ value,
124
+ chords: parseSettingsKeyshortcuts(value)
125
+ };
126
+ });
122
127
  const onKeyDown = (event) => {
123
- if (!props.settings || !isSettingsChord(event)) return;
128
+ const { value, chords } = settingsKeyshortcuts();
129
+ if (!props.settings || !matchesSettingsKeyshortcuts(event, chords, value === "Meta+, Control+,", hasEditableKeyboardTarget)) return;
124
130
  event.preventDefault();
125
131
  if (!event.repeat) openSettings();
126
132
  };
@@ -153,7 +159,7 @@ function ApplicationUtilities(props) {
153
159
  }).map((item) => {
154
160
  if (item.id === "settings" && item.shortcut) return {
155
161
  ...item,
156
- keyshortcuts: menu?.settingsKeyshortcuts ?? settingsKeyshortcuts
162
+ keyshortcuts: menu?.settingsKeyshortcuts ?? "Meta+, Control+,"
157
163
  };
158
164
  if (item.id === "updates" && updatesAlways()) return {
159
165
  ...item,
@@ -265,7 +271,9 @@ function ApplicationUtilities(props) {
265
271
  get standard() {
266
272
  return {
267
273
  search: help().search,
274
+ searchBinding: help().searchBinding,
268
275
  settings: Boolean(props.settings),
276
+ settingsKeyshortcuts: props.accountMenu?.settingsKeyshortcuts ?? "Meta+, Control+,",
269
277
  shortcutPlatform: resolveShortcutPlatform(props.identity)
270
278
  };
271
279
  },
@@ -4,9 +4,13 @@ export type { HelpLink, HelpShortcut };
4
4
  /** Shortcuts the framework binds itself, drawn with the running platform's modifier. */
5
5
  export declare function standardShortcuts(options: {
6
6
  search?: boolean;
7
+ /** Whether the enclosing application shell actually consumes its search chord. */
8
+ searchBinding?: boolean;
7
9
  settings?: boolean;
10
+ settingsKeyshortcuts?: string;
8
11
  /** A navigator-style platform string; ignored when `shortcutPlatform` is supplied. */
9
12
  platform?: string;
10
13
  shortcutPlatform?: ShortcutPlatform;
11
14
  }): HelpShortcut[];
15
+ export { DEFAULT_SETTINGS_KEYSHORTCUTS } from './settings-shortcuts';
12
16
  export * from './shortcut-platform';
@@ -1,22 +1,53 @@
1
1
  import { detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey } from "./shortcut-platform.js";
2
- import { platformModifierKey } from "@adea-ai/ui/components/ui/kbd";
2
+ import { DEFAULT_SETTINGS_KEYSHORTCUTS, parseSettingsKeyshortcuts } from "./settings-shortcuts.js";
3
3
  // src/shell/help-shortcuts.ts
4
+ function shortcutKeyLabel(key) {
5
+ if (key === "Space") return "Space";
6
+ if (key === "Plus") return "+";
7
+ return /^[a-z]$/i.test(key) ? key.toUpperCase() : key;
8
+ }
9
+ function modifierKeyLabel(modifier, platform) {
10
+ switch (modifier) {
11
+ case "Meta": return platform === "mac" ? shortcutModifierKey(platform) : "Meta";
12
+ case "Control": return "Ctrl";
13
+ case "Alt": return platform === "mac" ? "⌥" : "Alt";
14
+ case "Shift": return platform === "mac" ? "⇧" : "Shift";
15
+ case "AltGraph": return "AltGr";
16
+ case "FnLock": return "Fn Lock";
17
+ case "NumLock": return "Num Lock";
18
+ case "ScrollLock": return "Scroll Lock";
19
+ case "SymbolLock": return "Symbol Lock";
20
+ default: return modifier;
21
+ }
22
+ }
23
+ function settingsShortcuts(keyshortcuts, platform, searchBinding) {
24
+ const seen = /* @__PURE__ */ new Set();
25
+ return parseSettingsKeyshortcuts(keyshortcuts).flatMap(({ key, modifiers }) => {
26
+ if (key.toLowerCase() === "k" && searchBinding && modifiers.some((modifier) => modifier === "Meta" || modifier === "Control") && !modifiers.includes("Alt") && !modifiers.includes("Shift")) return [];
27
+ const keys = [...modifiers.map((modifier) => modifierKeyLabel(modifier, platform)), shortcutKeyLabel(key)];
28
+ const identity = JSON.stringify([modifiers.toSorted(), shortcutKeyLabel(key)]);
29
+ if (seen.has(identity)) return [];
30
+ seen.add(identity);
31
+ return [{
32
+ label: "Open settings",
33
+ keys
34
+ }];
35
+ });
36
+ }
4
37
  /** Shortcuts the framework binds itself, drawn with the running platform's modifier. */
5
38
  function standardShortcuts(options) {
6
- const mod = options.shortcutPlatform ? shortcutModifierKey(options.shortcutPlatform) : platformModifierKey(options.platform);
39
+ const platform = resolveShortcutPlatform(options);
40
+ const mod = shortcutModifierKey(platform);
7
41
  return [
8
42
  ...options.search ? [{
9
43
  label: "Open search",
10
44
  keys: [mod, "K"]
11
45
  }] : [],
12
- ...options.settings ? [{
13
- label: "Open settings",
14
- keys: [mod, ","]
15
- }] : [],
46
+ ...options.settings ? settingsShortcuts(options.settingsKeyshortcuts ?? "Meta+, Control+,", platform, options.searchBinding ?? Boolean(options.search)) : [],
16
47
  {
17
48
  label: "Close panels and dialogs",
18
49
  keys: ["Esc"]
19
50
  }
20
51
  ];
21
52
  }
22
- export { detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey, standardShortcuts };
53
+ export { DEFAULT_SETTINGS_KEYSHORTCUTS, detectShortcutPlatform, resolveShortcutPlatform, settingsShortcutLabel, shortcutModifierKey, standardShortcuts };
@@ -0,0 +1,2 @@
1
+ /** Whether a keyboard event originated in a control that accepts text editing. */
2
+ export declare function hasEditableKeyboardTarget(event: KeyboardEvent): boolean;
@@ -0,0 +1,54 @@
1
+ // src/shell/keyboard-target.ts
2
+ var nonTextInputTypes = /* @__PURE__ */ new Set([
3
+ "button",
4
+ "checkbox",
5
+ "color",
6
+ "file",
7
+ "hidden",
8
+ "image",
9
+ "radio",
10
+ "range",
11
+ "reset",
12
+ "submit"
13
+ ]);
14
+ var textEntryRoles = /* @__PURE__ */ new Set([
15
+ "combobox",
16
+ "searchbox",
17
+ "spinbutton",
18
+ "textbox"
19
+ ]);
20
+ /** Whether an element or an ancestor in its composed path accepts text editing. */
21
+ function isEditableElementPath(path) {
22
+ let inheritedEditable = false;
23
+ for (const target of path) {
24
+ if (!(target instanceof Element)) continue;
25
+ if (target instanceof HTMLInputElement) {
26
+ if (!target.disabled && !target.readOnly && !nonTextInputTypes.has(target.type)) return true;
27
+ } else if (target instanceof HTMLTextAreaElement) {
28
+ if (!target.disabled && !target.readOnly) return true;
29
+ }
30
+ const contentEditable = target.getAttribute("contenteditable")?.toLowerCase();
31
+ if (contentEditable === "false") return false;
32
+ if (contentEditable === "" || contentEditable === "true" || contentEditable === "plaintext-only") return true;
33
+ const role = target.getAttribute("role")?.trim().toLowerCase().split(/\s+/)[0];
34
+ if (role && textEntryRoles.has(role) && target.getAttribute("aria-readonly")?.toLowerCase() !== "true" && target.getAttribute("aria-disabled")?.toLowerCase() !== "true") return true;
35
+ if (target instanceof HTMLElement && target.isContentEditable) inheritedEditable = true;
36
+ if (target.ownerDocument.designMode?.toLowerCase() === "on") inheritedEditable = true;
37
+ }
38
+ return inheritedEditable;
39
+ }
40
+ /** Whether a keyboard event originated in a control that accepts text editing. */
41
+ function hasEditableKeyboardTarget(event) {
42
+ const path = event.composedPath();
43
+ if (path.some((target) => target instanceof Element)) return isEditableElementPath(path);
44
+ const activePath = [];
45
+ let activeElement = document.activeElement;
46
+ while (activeElement?.shadowRoot?.activeElement) activeElement = activeElement.shadowRoot.activeElement;
47
+ while (activeElement) {
48
+ activePath.push(activeElement);
49
+ const root = activeElement.getRootNode();
50
+ activeElement = activeElement.assignedSlot ?? activeElement.parentElement ?? (root instanceof ShadowRoot ? root.host : null);
51
+ }
52
+ return isEditableElementPath(activePath);
53
+ }
54
+ export { hasEditableKeyboardTarget };
@@ -7,6 +7,11 @@ export type ApplicationSettingsSection = Readonly<{
7
7
  group: string;
8
8
  icon?: JSX.Element;
9
9
  description?: string;
10
+ /**
11
+ * Creates the active panel. Rebuilding the section list with the same id keeps
12
+ * that panel mounted and does not invoke a replacement renderer. Pass changing
13
+ * context through reactive values in the returned view.
14
+ */
10
15
  render(): JSX.Element;
11
16
  }>;
12
17
  /** Validate section identifiers, labels and groups before the dialog mounts. */
@@ -0,0 +1,10 @@
1
+ export declare const DEFAULT_SETTINGS_KEYSHORTCUTS = "Meta+, Control+,";
2
+ declare const settingsShortcutModifiers: readonly ['Alt', 'AltGraph', 'CapsLock', 'Control', 'Fn', 'FnLock', 'Hyper', 'Meta', 'NumLock', 'ScrollLock', 'Shift', 'Super', 'Symbol', 'SymbolLock'];
3
+ type SettingsShortcutModifier = (typeof settingsShortcutModifiers)[number];
4
+ export type ParsedSettingsShortcut = Readonly<{
5
+ key: string;
6
+ modifiers: readonly SettingsShortcutModifier[];
7
+ }>;
8
+ export declare function parseSettingsKeyshortcuts(value: string): ParsedSettingsShortcut[];
9
+ export declare function matchesSettingsKeyshortcuts(event: KeyboardEvent, value: string | readonly ParsedSettingsShortcut[], allowDefaultMetaControlOverlap: boolean, hasEditableTarget: (event: KeyboardEvent) => boolean): boolean;
10
+ export {};
@@ -0,0 +1,67 @@
1
+ // src/shell/settings-shortcuts.ts
2
+ var DEFAULT_SETTINGS_KEYSHORTCUTS = "Meta+, Control+,";
3
+ var supportedModifiers = /* @__PURE__ */ new Set([
4
+ "Alt",
5
+ "AltGraph",
6
+ "CapsLock",
7
+ "Control",
8
+ "Fn",
9
+ "FnLock",
10
+ "Hyper",
11
+ "Meta",
12
+ "NumLock",
13
+ "ScrollLock",
14
+ "Shift",
15
+ "Super",
16
+ "Symbol",
17
+ "SymbolLock"
18
+ ]);
19
+ var exactSettingsShortcutModifiers = [
20
+ "Alt",
21
+ "AltGraph",
22
+ "Control",
23
+ "Fn",
24
+ "Hyper",
25
+ "Meta",
26
+ "Shift",
27
+ "Super",
28
+ "Symbol"
29
+ ];
30
+ function parseSettingsShortcutChord(chord) {
31
+ const parts = chord.split("+");
32
+ const key = parts.pop();
33
+ if (!key || key.trim() !== key || supportedModifiers.has(key)) return;
34
+ const modifiers = [];
35
+ for (const part of parts) {
36
+ if (!supportedModifiers.has(part) || modifiers.includes(part)) return;
37
+ modifiers.push(part);
38
+ }
39
+ return {
40
+ key,
41
+ modifiers
42
+ };
43
+ }
44
+ function parseSettingsKeyshortcuts(value) {
45
+ return value.trim().split(/\s+/).filter(Boolean).flatMap((chord) => {
46
+ const parsed = parseSettingsShortcutChord(chord);
47
+ return parsed ? [parsed] : [];
48
+ });
49
+ }
50
+ function normalizeShortcutKey(key) {
51
+ if (key === "Space") return " ";
52
+ if (key === "Plus") return "+";
53
+ return /^[a-z]$/i.test(key) ? key.toLowerCase() : key;
54
+ }
55
+ function matchesSettingsShortcut(event, chord, allowDefaultMetaControlOverlap, hasEditableTarget) {
56
+ if (normalizeShortcutKey(event.key) !== normalizeShortcutKey(chord.key)) return false;
57
+ const requiredModifiers = new Set(chord.modifiers);
58
+ const allowMetaControlOverlap = allowDefaultMetaControlOverlap && event.metaKey && event.ctrlKey && (requiredModifiers.has("Meta") || requiredModifiers.has("Control"));
59
+ if (exactSettingsShortcutModifiers.some((modifier) => !(allowMetaControlOverlap && (modifier === "Meta" || modifier === "Control")) && event.getModifierState(modifier) !== requiredModifiers.has(modifier))) return false;
60
+ if (chord.modifiers.some((modifier) => !exactSettingsShortcutModifiers.includes(modifier) && !event.getModifierState(modifier))) return false;
61
+ if (requiredModifiers.size === 0 && hasEditableTarget(event)) return false;
62
+ return true;
63
+ }
64
+ function matchesSettingsKeyshortcuts(event, value, allowDefaultMetaControlOverlap, hasEditableTarget) {
65
+ return !event.defaultPrevented && (typeof value === "string" ? parseSettingsKeyshortcuts(value) : value).some((chord) => matchesSettingsShortcut(event, chord, allowDefaultMetaControlOverlap, hasEditableTarget));
66
+ }
67
+ export { DEFAULT_SETTINGS_KEYSHORTCUTS, matchesSettingsKeyshortcuts, parseSettingsKeyshortcuts };