@kabmo-labs/kabmo 0.18.0 → 0.19.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.
- package/README.md +10 -7
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +475 -474
- package/dist/client/static/js/{index-tc09dtca.js → index-fcee4c13.js} +766 -765
- package/dist/client/static/js/index-sxdw908m.css +1 -0
- package/marketplace/plugins/command-runner/package.json +3 -2
- package/marketplace/plugins/git-forge/package.json +3 -2
- package/marketplace/plugins/session-info/package.json +3 -2
- package/marketplace/plugins/stats/package.json +3 -2
- package/package.json +3 -1
- package/src/client/components/auth/login-screen/index.tsx +2 -1
- package/src/client/components/common/ComposerPicker.tsx +1 -1
- package/src/client/components/common/FolderPicker.tsx +2 -2
- package/src/client/components/common/Modal.tsx +2 -2
- package/src/client/components/common/PWAInstallButton.tsx +2 -2
- package/src/client/components/common/ViewportSelector.tsx +1 -1
- package/src/client/components/common/anchored-menu/index.tsx +5 -1
- package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
- package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
- package/src/client/components/common/brand-wordmark/index.tsx +13 -2
- package/src/client/components/common/checkbox/style.test.ts +139 -0
- package/src/client/components/common/checkbox/style.ts +51 -0
- package/src/client/components/common/context-usage-button/index.tsx +2 -2
- package/src/client/components/common/file-icon/index.tsx +23 -9
- package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
- package/src/client/components/common/markdown-review/ReviewPopover.tsx +1 -1
- package/src/client/components/common/panel-mark/index.tsx +97 -0
- package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
- package/src/client/components/common/provider-icon/index.test.ts +14 -0
- package/src/client/components/common/provider-icon/index.tsx +4 -0
- package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
- package/src/client/components/common/provider-icon/resolve.ts +16 -3
- package/src/client/components/common/session-actions-menu/index.tsx +1 -1
- package/src/client/components/common/toolbar-row/index.tsx +1 -1
- package/src/client/components/layout/ActivityBar.tsx +22 -3
- package/src/client/components/layout/LeftDock.tsx +9 -2
- package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
- package/src/client/components/layout/WindowAura.tsx +27 -0
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
- package/src/client/components/layout/desktop-layout/index.tsx +3 -1
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +3 -3
- package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
- package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +2 -2
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +13 -5
- package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
- package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
- package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/mobile/panel-chips.tsx +10 -2
- package/src/client/components/settings/Modal.tsx +4 -4
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
- package/src/client/components/settings/apply-side-effects.test.ts +30 -0
- package/src/client/components/settings/apply-side-effects.ts +14 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +2 -1
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +2 -2
- package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +51 -2
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +43 -10
- package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
- package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
- package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +2 -1
- package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +1 -1
- package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
- package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
- package/src/client/components/workspace/diff-panel/index.tsx +2 -2
- package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
- package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
- package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
- package/src/client/components/workspace/editor/Tabs.tsx +1 -1
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
- package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
- package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
- package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
- package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
- package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
- package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
- package/src/client/components/workspace/git-panel/index.tsx +7 -0
- package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
- package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
- package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
- package/src/client/components/workspace/search-panel/Body.tsx +1 -1
- package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
- package/src/client/glass.css +785 -0
- package/src/client/glass.test.ts +346 -0
- package/src/client/hooks/ui/glass-support.ts +57 -0
- package/src/client/hooks/ui/icon-style.ts +59 -0
- package/src/client/hooks/ui/stuck-header.test.ts +188 -0
- package/src/client/hooks/ui/stuck-header.ts +91 -0
- package/src/client/hooks/ui/style-attributes.test.ts +120 -0
- package/src/client/hooks/ui/surface-style.ts +56 -0
- package/src/client/hooks/workspace/panel-hues.ts +23 -0
- package/src/client/main.tsx +10 -0
- package/src/client/tailwind.css +264 -11
- package/src/server/lib/assets/shell-attributes.server.ts +80 -0
- package/src/server/lib/assets/shell-attributes.test.ts +86 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
- package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
- package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
- package/src/server/lib/omp/rpc/manager.ts +2 -2
- package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
- package/src/server/lib/omp/rpc/process.test.ts +106 -0
- package/src/server/lib/omp/rpc/process.ts +28 -4
- package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
- package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
- package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
- package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
- package/src/server/lib/omp/rpc/session-commands.ts +11 -0
- package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
- package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
- package/src/server/lib/panels/manifest.test.ts +20 -0
- package/src/server/lib/panels/manifest.ts +12 -0
- package/src/server/lib/panels/scan.server.ts +4 -0
- package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
- package/src/server/lib/queue/delivery-harness.ts +8 -4
- package/src/server/lib/queue/delivery.server.test.ts +29 -0
- package/src/server/lib/queue/delivery.server.ts +39 -0
- package/src/server/lib/queue/store.server.test.ts +22 -2
- package/src/server/lib/queue/store.server.ts +33 -11
- package/src/server/plugins/ssr.ts +22 -5
- package/src/shared/lib/icons/file-brand-color.ts +38 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +234 -0
- package/src/shared/lib/icons/icon-paint-css.ts +284 -0
- package/src/shared/lib/icons/icon-paint-panel.ts +100 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +230 -0
- package/src/shared/lib/icons/tint.test.ts +273 -0
- package/src/shared/lib/icons/tint.ts +219 -0
- package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
- package/src/shared/lib/models/provider/brand-color.ts +103 -0
- package/src/shared/lib/omp/rpc/frame.test.ts +65 -0
- package/src/shared/lib/omp/rpc/frame.ts +58 -3
- package/src/shared/lib/settings/defaults.ts +4 -0
- package/src/shared/lib/theme/catalog.test.ts +5 -4
- package/src/shared/lib/theme/catalog.ts +18 -3
- package/src/shared/lib/theme/glass-support.test.ts +38 -0
- package/src/shared/lib/theme/glass-support.ts +73 -0
- package/src/shared/lib/theme/icon-style.test.ts +74 -0
- package/src/shared/lib/theme/icon-style.ts +90 -0
- package/src/shared/lib/theme/legibility.ts +91 -0
- package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
- package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
- package/src/shared/lib/theme/surface-style.test.ts +68 -0
- package/src/shared/lib/theme/surface-style.ts +91 -0
- package/src/shared/lib/theme/theme.test.ts +11 -7
- package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
- package/src/shared/lib/workspace/panel-hues.ts +57 -0
- package/src/shared/types/panels-registry.ts +6 -0
- package/src/shared/types/panels.ts +14 -0
- package/src/shared/types/settings/state.ts +26 -0
- package/src/test-support/fake-omp-frames.ts +163 -0
- package/dist/client/static/js/index-hp75vsv9.css +0 -1
- /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
|
@@ -39,10 +39,32 @@ import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
|
39
39
|
import { publishSidebarStructure } from '@/server/lib/realtime/topics.server';
|
|
40
40
|
|
|
41
41
|
/** The wrapper surface a terminal settle touches. */
|
|
42
|
-
export interface TerminalSettleHost extends AutoTitleHost, QueueDeliveryHost {
|
|
42
|
+
export interface TerminalSettleHost extends AutoTitleHost, QueueDeliveryHost {
|
|
43
|
+
/** Abort verdict captured from `message_end` — see `SessionFrameHost.runAborted`. */
|
|
44
|
+
runAborted: boolean;
|
|
45
|
+
}
|
|
43
46
|
|
|
44
|
-
/**
|
|
45
|
-
|
|
47
|
+
/**
|
|
48
|
+
* True when the ending turn was a user abort rather than a natural stop.
|
|
49
|
+
*
|
|
50
|
+
* Two sources, because neither is sufficient alone. `host.runAborted` is read
|
|
51
|
+
* from `message_end`, where the message is still whole; `agent_end.messages` is
|
|
52
|
+
* a fallback for a host that attached mid-run (a reattached client, or a
|
|
53
|
+
* synthetic terminal frame from `run-settle.server.ts`), which never saw one.
|
|
54
|
+
*
|
|
55
|
+
* The frame's own array cannot be the primary source: omp compacts an oversized
|
|
56
|
+
* terminal frame by dropping every message it already delivered through
|
|
57
|
+
* `message_end` (keeping only `messageCount`), and the aborted assistant message
|
|
58
|
+
* is always among them — measured on 18.16.0, `message_end`
|
|
59
|
+
* (`role: "assistant"`, `stopReason: "aborted"`) arrives before `agent_end`.
|
|
60
|
+
* Reading only the frame therefore reports a stopped run as finished, and the
|
|
61
|
+
* settle then titles the session, audits the goal and releases the queue for a
|
|
62
|
+
* turn the operator cancelled. 12.7% of the runs in this workstation's own
|
|
63
|
+
* session store (494 of 3901) exceed the 1 MiB frame ceiling, so the trimmed
|
|
64
|
+
* case is routine, not exotic.
|
|
65
|
+
*/
|
|
66
|
+
function endedAborted(host: TerminalSettleHost, messages: unknown): boolean {
|
|
67
|
+
if (host.runAborted) return true;
|
|
46
68
|
return (
|
|
47
69
|
Array.isArray(messages) &&
|
|
48
70
|
messages.some((entry) => {
|
|
@@ -60,11 +82,11 @@ function endedAborted(messages: unknown): boolean {
|
|
|
60
82
|
* Re-check the current row and only upgrade `stream` rows, so a `finish`
|
|
61
83
|
* written here can never clobber a newer run's live `stream`/`abort`.
|
|
62
84
|
*/
|
|
63
|
-
async function markEndStatus(sessionId: string, messages: unknown): Promise<void> {
|
|
85
|
+
async function markEndStatus(sessionId: string, host: TerminalSettleHost, messages: unknown): Promise<void> {
|
|
64
86
|
if (!sessionId) return;
|
|
65
87
|
const current = await loadStreamStatuses();
|
|
66
88
|
if (current[sessionId] !== 'stream') return;
|
|
67
|
-
await markStreamStatus(sessionId, endedAborted(messages) ? 'abort' : 'finish');
|
|
89
|
+
await markStreamStatus(sessionId, endedAborted(host, messages) ? 'abort' : 'finish');
|
|
68
90
|
}
|
|
69
91
|
|
|
70
92
|
/**
|
|
@@ -75,8 +97,8 @@ async function markEndStatus(sessionId: string, messages: unknown): Promise<void
|
|
|
75
97
|
* machine, and this function only performs the work the settle triggers.
|
|
76
98
|
*/
|
|
77
99
|
export function settleTerminalRun(host: TerminalSettleHost, messages: unknown): void {
|
|
78
|
-
const aborted = endedAborted(messages);
|
|
79
|
-
if (host.sessionId) void markEndStatus(host.sessionId, messages);
|
|
100
|
+
const aborted = endedAborted(host, messages);
|
|
101
|
+
if (host.sessionId) void markEndStatus(host.sessionId, host, messages);
|
|
80
102
|
if (!aborted) {
|
|
81
103
|
void triggerAutoSessionTitle(host, 'settle');
|
|
82
104
|
void driveGoalAfterTurn({ host, messages });
|
|
@@ -46,6 +46,7 @@ export async function readBundledCatalog(bundledRoot: string, installed: Readonl
|
|
|
46
46
|
// details before the plugin is installed. Both come from the bundled
|
|
47
47
|
// directory, which the routes resolve through the same registry.
|
|
48
48
|
...(manifest.icon ? { iconUrl: await iconUrl(pluginDir, manifest.icon) } : {}),
|
|
49
|
+
...(manifest.color ? { color: manifest.color } : {}),
|
|
49
50
|
...(await readmeUrlFor(pluginDir, manifest)),
|
|
50
51
|
...(manifest.author ? { author: manifest.author } : {}),
|
|
51
52
|
...(manifest.homepage ? { homepage: manifest.homepage } : {}),
|
|
@@ -188,6 +188,26 @@ describe('toManifest', () => {
|
|
|
188
188
|
});
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
+
describe('the manifest colour', () => {
|
|
192
|
+
test('a #RRGGBB is kept, lowercased', () => {
|
|
193
|
+
expect(toManifest({ ...MANIFEST, color: '#34D399' }, ROOT)).toMatchObject({ color: '#34d399' });
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('every other form is refused, because the value reaches an inline style', () => {
|
|
197
|
+
// `color` becomes a custom property on the rail's mark, so anything that is
|
|
198
|
+
// not a hex is a refusal rather than a value the host has to escape.
|
|
199
|
+
for (const color of ['red', 'rgb(0 0 0)', '#abc', '#12345', 'url(x)', 'red; background: url(x)', 'var(--x)', '']) {
|
|
200
|
+
const result = toManifest({ ...MANIFEST, color }, ROOT);
|
|
201
|
+
if (color === '') {
|
|
202
|
+
// An empty string is "not declared", not a refusal.
|
|
203
|
+
expect(result).not.toMatchObject({ error: expect.any(String) });
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
expect(result, color).toMatchObject({ error: expect.stringContaining('is not a #RRGGBB hex') });
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
191
211
|
describe('toMarketplaceCatalog', () => {
|
|
192
212
|
|
|
193
213
|
test('accepts a catalog with no plugins array as empty', () => {
|
|
@@ -34,6 +34,9 @@ import { isRemoteGitUrl } from '@/shared/lib/git/url';
|
|
|
34
34
|
import { resolveInsideRoot } from '@/shared/lib/panels/resolve-asset';
|
|
35
35
|
|
|
36
36
|
/** An id segment: what a plugin id may look like. */
|
|
37
|
+
/** The only colour form a manifest may declare: `#RRGGBB`. */
|
|
38
|
+
const HEX_COLOR = /^#[0-9a-f]{6}$/i;
|
|
39
|
+
|
|
37
40
|
const ID_RE = /^[a-z0-9][a-z0-9._-]{0,63}$/i;
|
|
38
41
|
|
|
39
42
|
function trimmed(value: unknown): string | undefined {
|
|
@@ -87,6 +90,14 @@ export function toManifest(raw: unknown, root: string): PanelPluginManifest | {
|
|
|
87
90
|
return { error: `manifest readme "${readme}" escapes the plugin directory` };
|
|
88
91
|
}
|
|
89
92
|
|
|
93
|
+
// A mark colour reaches an inline custom property, so it is a HEX and nothing
|
|
94
|
+
// else: `color: url(...)`, `red; background: …` or a `var()` that resolves
|
|
95
|
+
// elsewhere are all refusals rather than values the host has to escape.
|
|
96
|
+
const color = trimmed(raw.color);
|
|
97
|
+
if (color && !HEX_COLOR.test(color)) {
|
|
98
|
+
return { error: `manifest color ${JSON.stringify(raw.color)} is not a #RRGGBB hex` };
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
const branding = isRecord(raw.branding) ? trimmed(raw.branding.icon) : undefined;
|
|
91
102
|
const engines = toEngines(raw.engines);
|
|
92
103
|
if ('error' in engines) return engines;
|
|
@@ -111,6 +122,7 @@ export function toManifest(raw: unknown, root: string): PanelPluginManifest | {
|
|
|
111
122
|
...(trimmed(raw.homepage) ? { homepage: trimmed(raw.homepage) } : {}),
|
|
112
123
|
...(icon ? { icon } : {}),
|
|
113
124
|
...(readme ? { readme } : {}),
|
|
125
|
+
...(color ? { color: color.toLowerCase() } : {}),
|
|
114
126
|
...(branding ? { branding: { icon: branding } } : {}),
|
|
115
127
|
...(author ? { author } : {}),
|
|
116
128
|
...(slots ? { slots } : {}),
|
|
@@ -127,6 +127,7 @@ export async function scanInstalledPlugins(options: {
|
|
|
127
127
|
...(manifest.author ? { author: manifest.author } : {}),
|
|
128
128
|
...(manifest.homepage ? { homepage: manifest.homepage } : {}),
|
|
129
129
|
...(manifest.slots ? { slots: manifest.slots } : {}),
|
|
130
|
+
...(manifest.color ? { color: manifest.color } : {}),
|
|
130
131
|
...(manifest.capabilities ? { capabilities: manifest.capabilities } : {}),
|
|
131
132
|
...(missingEntry ? { reason: `the build produced no ${missingEntry}` } : {}),
|
|
132
133
|
});
|
|
@@ -154,6 +155,9 @@ export async function scanInstalledPlugins(options: {
|
|
|
154
155
|
? { cssUrl: await cssUrl(pluginDir, manifest.css) }
|
|
155
156
|
: {}),
|
|
156
157
|
...(manifest.icon ? { iconUrl: await iconUrl(pluginDir, manifest.icon) } : {}),
|
|
158
|
+
// The plugin's own mark colour, so the activity bar can paint its brand
|
|
159
|
+
// instead of a hue hashed from its name.
|
|
160
|
+
...(manifest.color ? { color: manifest.color } : {}),
|
|
157
161
|
...(await readmeUrlFor(pluginDir, manifest)),
|
|
158
162
|
});
|
|
159
163
|
}
|
|
@@ -211,4 +211,52 @@ describe('queue dispatch', () => {
|
|
|
211
211
|
|
|
212
212
|
expect(delivered).toBe(false);
|
|
213
213
|
});
|
|
214
|
+
|
|
215
|
+
// omp refused the prompt because a turn was already in flight while the
|
|
216
|
+
// wrapper still read idle (a probe's stale answer had cleared its flags).
|
|
217
|
+
// Measured: 104 `agent_busy` failures in one session. The refusal is omp's
|
|
218
|
+
// own word that the session is busy, so the wrapper keeps `isBusy()` true and
|
|
219
|
+
// every later tick parks — one attempted dispatch, not one per retry — and the
|
|
220
|
+
// head keeps its place.
|
|
221
|
+
test('a busy refusal parks the queue instead of redispatching on every tick', async () => {
|
|
222
|
+
const sessionId = beginQueueTest();
|
|
223
|
+
queue.set(sessionId, [queueItem('a'), queueItem('b'), queueItem('c')]);
|
|
224
|
+
const { host, sent } = makeHost(sessionId);
|
|
225
|
+
// The wrapper's flags say idle; omp is actually mid-turn.
|
|
226
|
+
let wrapperBusy = false;
|
|
227
|
+
let ompBusy = true;
|
|
228
|
+
host.isBusy = () => wrapperBusy;
|
|
229
|
+
host.send = async (command) => {
|
|
230
|
+
if (command.type !== 'prompt') return {};
|
|
231
|
+
if (!ompBusy) {
|
|
232
|
+
sent.push(command);
|
|
233
|
+
return {};
|
|
234
|
+
}
|
|
235
|
+
// What the command dispatcher does with omp's `agent_busy` refusal: the
|
|
236
|
+
// typed error, and omp's verdict kept on the wrapper's own flags.
|
|
237
|
+
wrapperBusy = true;
|
|
238
|
+
throw new Error('agent_busy');
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const delivered = await deliverQueueNow(host);
|
|
242
|
+
await flush();
|
|
243
|
+
expect(delivered).toBe(false);
|
|
244
|
+
|
|
245
|
+
// The retry timer and a client nudge both arrive while omp is still busy:
|
|
246
|
+
// neither may dispatch at the child again.
|
|
247
|
+
jest.advanceTimersByTime(2_000);
|
|
248
|
+
await flush();
|
|
249
|
+
await deliverQueueNow(host);
|
|
250
|
+
await flush();
|
|
251
|
+
expect(sent).toEqual([]);
|
|
252
|
+
expect(queue.get(sessionId)?.map((item) => item.text)).toEqual(['a', 'b', 'c']);
|
|
253
|
+
|
|
254
|
+
// The run ends: the head goes out, ahead of everything queued behind it.
|
|
255
|
+
ompBusy = false;
|
|
256
|
+
wrapperBusy = false;
|
|
257
|
+
await deliverQueueNow(host);
|
|
258
|
+
await flush();
|
|
259
|
+
expect(sent.map((command) => command.message)).toEqual(['a']);
|
|
260
|
+
expect(queue.get(sessionId)?.map((item) => item.text)).toEqual(['b', 'c']);
|
|
261
|
+
});
|
|
214
262
|
});
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import { jest, mock } from 'bun:test';
|
|
23
23
|
import type { QueuedMessage } from '@/shared/types/chat';
|
|
24
|
+
import type { ClaimedQueueItem } from '@/server/lib/queue/store.server';
|
|
24
25
|
import type { QueueDeliveryHost } from '@/server/lib/queue/delivery.server';
|
|
25
26
|
|
|
26
27
|
// Hoisted above the registration, so spreading it here snapshots the REAL
|
|
@@ -40,14 +41,17 @@ export const queue = new Map<string, QueuedMessage[]>();
|
|
|
40
41
|
* after another has restored the real one. */
|
|
41
42
|
export function installStoreMock(): void {
|
|
42
43
|
mock.module('@/server/lib/queue/store.server', () => ({
|
|
43
|
-
claimHeadQueueItem: async (sessionId: string): Promise<
|
|
44
|
+
claimHeadQueueItem: async (sessionId: string): Promise<ClaimedQueueItem | null> => {
|
|
44
45
|
const items = queue.get(sessionId);
|
|
45
|
-
|
|
46
|
+
const head = items?.shift();
|
|
47
|
+
// The list index IS the position here, and the head is always index 0.
|
|
48
|
+
return head ? { ...head, position: 0 } : null;
|
|
46
49
|
},
|
|
47
50
|
hasQueuedItem: async (sessionId: string): Promise<boolean> => (queue.get(sessionId)?.length ?? 0) > 0,
|
|
48
|
-
requeueHeadQueueItem: async (sessionId: string, item:
|
|
51
|
+
requeueHeadQueueItem: async (sessionId: string, item: ClaimedQueueItem): Promise<void> => {
|
|
49
52
|
const items = queue.get(sessionId) ?? [];
|
|
50
|
-
|
|
53
|
+
const { position: _position, ...row } = item;
|
|
54
|
+
items.splice(0, 0, row);
|
|
51
55
|
queue.set(sessionId, items);
|
|
52
56
|
},
|
|
53
57
|
}));
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
import { afterAll, afterEach, beforeAll, describe, expect, jest, mock, test } from 'bun:test';
|
|
25
25
|
import {
|
|
26
26
|
beginQueueTest,
|
|
27
|
+
deliverQueueNow,
|
|
27
28
|
flush,
|
|
28
29
|
installStoreMock,
|
|
29
30
|
makeHost,
|
|
@@ -203,4 +204,32 @@ describe('queue delivery scheduling', () => {
|
|
|
203
204
|
expect(sent.filter((c) => c.type === 'prompt').length).toBe(1);
|
|
204
205
|
expect(queue.get(sessionId)).toEqual([]);
|
|
205
206
|
});
|
|
207
|
+
|
|
208
|
+
// The nudge path (`deliverQueueNow`) has no timer to dedupe it: a tab's 3s
|
|
209
|
+
// poll, a focus nudge and a run end can all be inside `deliverNext` at once.
|
|
210
|
+
// Two overlapping attempts claim two heads, and the requeues that follow
|
|
211
|
+
// decide which of the pair comes back first — measured on a live session as
|
|
212
|
+
// the panel's order changing on every `agent_busy` retry.
|
|
213
|
+
test('overlapping delivery attempts share one dispatch and leave the order alone', async () => {
|
|
214
|
+
const sessionId = beginQueueTest();
|
|
215
|
+
queue.set(sessionId, [queueItem('a'), queueItem('b'), queueItem('c')]);
|
|
216
|
+
const { host } = makeHost(sessionId);
|
|
217
|
+
let attempts = 0;
|
|
218
|
+
host.send = async () => {
|
|
219
|
+
attempts++;
|
|
220
|
+
throw new Error('agent_busy');
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const results = await Promise.all([
|
|
224
|
+
deliverQueueNow(host),
|
|
225
|
+
deliverQueueNow(host),
|
|
226
|
+
deliverQueueNow(host),
|
|
227
|
+
]);
|
|
228
|
+
await flush();
|
|
229
|
+
|
|
230
|
+
expect(results).toEqual([false, false, false]);
|
|
231
|
+
// One claim, one failed dispatch, one requeue — not three of each.
|
|
232
|
+
expect(attempts).toBe(1);
|
|
233
|
+
expect(queue.get(sessionId)?.map((item) => item.text)).toEqual(['a', 'b', 'c']);
|
|
234
|
+
});
|
|
206
235
|
});
|
|
@@ -70,6 +70,8 @@ interface PendingDelivery {
|
|
|
70
70
|
declare global {
|
|
71
71
|
// eslint-disable-next-line no-var
|
|
72
72
|
var __ompQueueDeliveryTimers: Map<string, PendingDelivery> | undefined;
|
|
73
|
+
// eslint-disable-next-line no-var
|
|
74
|
+
var __ompQueueDeliveryInFlight: Map<string, Promise<boolean>> | undefined;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
/** Per-session pending delivery timer, so a second agent_end while one is
|
|
@@ -93,6 +95,24 @@ function clearPendingTimer(sessionId: string): void {
|
|
|
93
95
|
pendingTimers.delete(sessionId);
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
/**
|
|
99
|
+
* The delivery currently running for a session, if any.
|
|
100
|
+
*
|
|
101
|
+
* Every trigger — a run end, the retry timer, a tab's nudge (which runs
|
|
102
|
+
* {@link deliverQueueNow} with no timer at all) — enters here, and they overlap
|
|
103
|
+
* freely: a nudge fires while the retry's dispatch is still awaiting the RPC.
|
|
104
|
+
* Two overlapping attempts claim two different heads, and each requeue then
|
|
105
|
+
* decides the order the pair comes back in. Serialized per session, so one
|
|
106
|
+
* dispatch is in flight at a time and the queue is only ever touched by it.
|
|
107
|
+
*
|
|
108
|
+
* On `globalThis` for the same reason as the timers: a `--hot` reload must not
|
|
109
|
+
* lose track of a running delivery.
|
|
110
|
+
*/
|
|
111
|
+
function getInFlightDeliveries(): Map<string, Promise<boolean>> {
|
|
112
|
+
if (!globalThis.__ompQueueDeliveryInFlight) globalThis.__ompQueueDeliveryInFlight = new Map();
|
|
113
|
+
return globalThis.__ompQueueDeliveryInFlight;
|
|
114
|
+
}
|
|
115
|
+
|
|
96
116
|
/** Send one queued item to the session as a normal prompt. The model snapshot
|
|
97
117
|
* rides first (set_model / set_thinking_level) exactly like the composer's
|
|
98
118
|
* queued delivery did. Returns false when the dispatch failed.
|
|
@@ -202,8 +222,27 @@ async function armRetryIfQueued(session: QueueDeliveryHost): Promise<void> {
|
|
|
202
222
|
* strand the queue permanently: the timer had already been deleted from the map
|
|
203
223
|
* by its own callback, so nothing remained to retry it and no later trigger was
|
|
204
224
|
* guaranteed to arrive. Re-arming keeps the retry owned by this module.
|
|
225
|
+
*
|
|
226
|
+
* Concurrent calls share the running attempt instead of starting a second one:
|
|
227
|
+
* the dispatches that provoke them (`agent_busy` from omp while `isBusy()` still
|
|
228
|
+
* reads idle) otherwise overlap, and two overlapping claims plus two requeues
|
|
229
|
+
* reorder the queue.
|
|
205
230
|
*/
|
|
206
231
|
async function deliverNext(session: QueueDeliveryHost): Promise<boolean> {
|
|
232
|
+
const sessionId = session.sessionId;
|
|
233
|
+
const inFlight = getInFlightDeliveries();
|
|
234
|
+
const running = inFlight.get(sessionId);
|
|
235
|
+
if (running) return running;
|
|
236
|
+
const attempt = runDelivery(session);
|
|
237
|
+
inFlight.set(sessionId, attempt);
|
|
238
|
+
try {
|
|
239
|
+
return await attempt;
|
|
240
|
+
} finally {
|
|
241
|
+
if (inFlight.get(sessionId) === attempt) inFlight.delete(sessionId);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
async function runDelivery(session: QueueDeliveryHost): Promise<boolean> {
|
|
207
246
|
const sessionId = session.sessionId;
|
|
208
247
|
if (!session.isAlive()) return false;
|
|
209
248
|
if (session.isBusy()) {
|
|
@@ -35,9 +35,9 @@ import {
|
|
|
35
35
|
requeueHeadQueueItem,
|
|
36
36
|
reorderQueue,
|
|
37
37
|
rowToQueuedMessage,
|
|
38
|
+
type ClaimedQueueItem,
|
|
38
39
|
} from '@/server/lib/queue/store.server';
|
|
39
40
|
import { restoreStore } from '@/server/lib/queue/delivery-harness';
|
|
40
|
-
import type { QueuedMessage } from '@/shared/types/chat';
|
|
41
41
|
import { removeDir } from '@/test-support/remove-dir';
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -240,7 +240,7 @@ describe('claim, requeue and presence', () => {
|
|
|
240
240
|
useTempDb();
|
|
241
241
|
await appendQueueItem('s1', { text: 'first' });
|
|
242
242
|
await appendQueueItem('s1', { text: 'second' });
|
|
243
|
-
const failed = (await claimHeadQueueItem('s1')) as
|
|
243
|
+
const failed = (await claimHeadQueueItem('s1')) as ClaimedQueueItem;
|
|
244
244
|
expect(failed.text).toBe('first');
|
|
245
245
|
|
|
246
246
|
await requeueHeadQueueItem('s1', failed);
|
|
@@ -248,6 +248,26 @@ describe('claim, requeue and presence', () => {
|
|
|
248
248
|
expect((await claimHeadQueueItem('s1'))?.text).toBe('first');
|
|
249
249
|
});
|
|
250
250
|
|
|
251
|
+
// Measured live: a busy session rejected each dispatch (`agent_busy`) once
|
|
252
|
+
// per retry while the client's 3s nudge kept entering `deliverNext`, so two
|
|
253
|
+
// claims were in flight at once. `MIN(position) - 1` then put each failed
|
|
254
|
+
// item one slot too low and the pair came back swapped — the panel's order
|
|
255
|
+
// changed on every retry, and positions walked to -8..-1.
|
|
256
|
+
test('a requeue returns the item to its own slot, not below the queue', async () => {
|
|
257
|
+
useTempDb();
|
|
258
|
+
await appendQueueItem('s1', { text: 'a' });
|
|
259
|
+
await appendQueueItem('s1', { text: 'b' });
|
|
260
|
+
await appendQueueItem('s1', { text: 'c' });
|
|
261
|
+
|
|
262
|
+
// Two overlapping attempts: the second claims while the first dispatches.
|
|
263
|
+
const first = (await claimHeadQueueItem('s1')) as ClaimedQueueItem;
|
|
264
|
+
const second = (await claimHeadQueueItem('s1')) as ClaimedQueueItem;
|
|
265
|
+
await requeueHeadQueueItem('s1', first);
|
|
266
|
+
await requeueHeadQueueItem('s1', second);
|
|
267
|
+
|
|
268
|
+
expect((await listQueue('s1')).map((item) => item.text)).toEqual(['a', 'b', 'c']);
|
|
269
|
+
});
|
|
270
|
+
|
|
251
271
|
test('hasQueuedItem reports presence without claiming', async () => {
|
|
252
272
|
useTempDb();
|
|
253
273
|
expect(await hasQueuedItem('s1')).toBe(false);
|
|
@@ -83,11 +83,28 @@ interface QueueItemInput {
|
|
|
83
83
|
model?: unknown;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* A claimed row plus the position it held. A failed dispatch puts the item
|
|
88
|
+
* back at exactly that slot: recomputing "one below the current minimum" from
|
|
89
|
+
* a queue two deliveries touched reorders the rest — measured as a live queue
|
|
90
|
+
* whose eight rows walked from positions 0..7 down to -8..-1 while a busy
|
|
91
|
+
* session rejected each dispatch (`agent_busy`) once per retry.
|
|
92
|
+
*/
|
|
93
|
+
export interface ClaimedQueueItem extends QueuedMessage {
|
|
94
|
+
position: number;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The session's queued follow-ups in delivery order.
|
|
99
|
+
*
|
|
100
|
+
* `rowid` breaks a position tie: two rows can share a position when a reorder
|
|
101
|
+
* ships a list that a concurrent append was not part of, and SQLite is free to
|
|
102
|
+
* return equal keys in any order — which reads as the panel shuffling itself.
|
|
103
|
+
*/
|
|
87
104
|
export async function listQueue(sessionId: string): Promise<QueuedMessage[]> {
|
|
88
105
|
const db = await getDb();
|
|
89
106
|
const rows = (await db.all(
|
|
90
|
-
'SELECT * FROM queued_messages WHERE session_id = ? ORDER BY position ASC',
|
|
107
|
+
'SELECT * FROM queued_messages WHERE session_id = ? ORDER BY position ASC, rowid ASC',
|
|
91
108
|
[sessionId],
|
|
92
109
|
)) as QueueRow[];
|
|
93
110
|
return rows.map(rowToQueuedMessage);
|
|
@@ -171,18 +188,18 @@ export async function reorderQueue(sessionId: string, orderedIds: string[]): Pro
|
|
|
171
188
|
* call and stranded the queue silently, with nudges failing the same way.
|
|
172
189
|
* `getDb()` re-initializes instead, so a delivery heals the state it needs.
|
|
173
190
|
*/
|
|
174
|
-
export async function claimHeadQueueItem(sessionId: string): Promise<
|
|
191
|
+
export async function claimHeadQueueItem(sessionId: string): Promise<ClaimedQueueItem | null> {
|
|
175
192
|
const db = await getDb();
|
|
176
193
|
return withTransaction(db, () => {
|
|
177
194
|
const row = db.raw
|
|
178
|
-
.query('SELECT * FROM queued_messages WHERE session_id = ? ORDER BY position ASC LIMIT 1')
|
|
195
|
+
.query('SELECT * FROM queued_messages WHERE session_id = ? ORDER BY position ASC, rowid ASC LIMIT 1')
|
|
179
196
|
.get(sessionId) as QueueRow | undefined;
|
|
180
197
|
if (!row) return null;
|
|
181
198
|
db.raw.run('DELETE FROM queued_messages WHERE id = ?', [row.id]);
|
|
182
199
|
// The head left the queue: a panel showing it must be told, or it keeps
|
|
183
200
|
// rendering an item that is already being sent.
|
|
184
201
|
emitRealtimeSignal('session-data-dirty', sessionId);
|
|
185
|
-
return rowToQueuedMessage(row);
|
|
202
|
+
return { ...rowToQueuedMessage(row), position: row.position };
|
|
186
203
|
});
|
|
187
204
|
}
|
|
188
205
|
|
|
@@ -203,16 +220,21 @@ export async function hasQueuedItem(sessionId: string): Promise<boolean> {
|
|
|
203
220
|
}
|
|
204
221
|
|
|
205
222
|
/**
|
|
206
|
-
* Put a failed delivery back
|
|
207
|
-
* so it is retried before anything
|
|
208
|
-
*
|
|
223
|
+
* Put a failed delivery back where it was: the position it was claimed from,
|
|
224
|
+
* so it is retried before anything queued after it.
|
|
225
|
+
*
|
|
226
|
+
* The position is carried by the claim rather than recomputed. `MIN(position)
|
|
227
|
+
* - 1` looks equivalent and is not: with two attempts in flight the second
|
|
228
|
+
* claim has already removed the next row, so the first requeue lands one slot
|
|
229
|
+
* too low and the pair swaps. Every retry against a busy session then permutes
|
|
230
|
+
* the queue again.
|
|
209
231
|
*/
|
|
210
|
-
export async function requeueHeadQueueItem(sessionId: string, item:
|
|
232
|
+
export async function requeueHeadQueueItem(sessionId: string, item: ClaimedQueueItem): Promise<void> {
|
|
211
233
|
const db = await getDb();
|
|
212
234
|
db.raw.run(
|
|
213
235
|
`INSERT INTO queued_messages (id, session_id, position, message, attachments, provider, model_id, thinking_level, access_mode)
|
|
214
|
-
VALUES (?, ?,
|
|
215
|
-
[item.id, sessionId,
|
|
236
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
237
|
+
[item.id, sessionId, item.position, item.text, serializeAttachments(item.attachments),
|
|
216
238
|
item.model?.provider ?? null, item.model?.modelId ?? null, item.model?.thinkingLevel ?? null, item.model?.accessMode ?? null],
|
|
217
239
|
);
|
|
218
240
|
emitRealtimeSignal('session-data-dirty', sessionId);
|
|
@@ -21,8 +21,15 @@ import {
|
|
|
21
21
|
} from '@/server/lib/assets/theme-shell.server';
|
|
22
22
|
import { readSettingsBlob } from '@/shared/lib/settings/keys';
|
|
23
23
|
import { resolveTheme } from '@/shared/lib/theme/catalog';
|
|
24
|
+
import { applyShellDocumentFacts } from '@/server/lib/assets/shell-attributes.server';
|
|
25
|
+
import { SURFACE_STYLE_SETTING_KEY } from '@/shared/lib/theme/surface-style';
|
|
26
|
+
import { ICON_STYLE_SETTING_KEY } from '@/shared/lib/theme/icon-style';
|
|
24
27
|
import { windowChromeColor } from '@/shared/lib/theme/chrome';
|
|
25
28
|
import { THEME_STYLE_ELEMENT_ID, themeStyleSheet } from '@/shared/lib/theme/css';
|
|
29
|
+
import {
|
|
30
|
+
ICON_PAINT_STYLE_ELEMENT_ID,
|
|
31
|
+
iconPaintStyleSheet,
|
|
32
|
+
} from '@/shared/lib/icons/icon-paint-css';
|
|
26
33
|
import { isAndroidDevice, shellVersion } from '@/shared/lib/updates/shell-ua';
|
|
27
34
|
|
|
28
35
|
/** HTML-escape a string for interpolation into the failure page's `<pre>`. */
|
|
@@ -92,6 +99,7 @@ function storedThemeId(settings: Record<string, unknown>): string | undefined {
|
|
|
92
99
|
return typeof theme === 'string' && theme.length > 0 ? theme : undefined;
|
|
93
100
|
}
|
|
94
101
|
|
|
102
|
+
|
|
95
103
|
/**
|
|
96
104
|
* The HTML shell is generated per request, so its cacheability is declared
|
|
97
105
|
* rather than left to the browser's heuristics.
|
|
@@ -216,6 +224,10 @@ export const ssrRoutes = new Elysia({ name: 'ssr' }).get('*', async ({ request }
|
|
|
216
224
|
// a second tag: with both present Chrome reads the first one, so an appended
|
|
217
225
|
// tag would leave a dark theme painting light browser chrome.
|
|
218
226
|
const themeStyle = `<style id="${THEME_STYLE_ELEMENT_ID}">${themeStyleSheet()}</style>`;
|
|
227
|
+
// The brand colours are generated from a TS table too, for the same reason:
|
|
228
|
+
// the bundler cannot carry a stylesheet derived from data, and a hand-written
|
|
229
|
+
// copy in `tailwind.css` would be 35 pairs that drift from the table.
|
|
230
|
+
const brandStyle = `<style id="${ICON_PAINT_STYLE_ELEMENT_ID}">${iconPaintStyleSheet()}</style>`;
|
|
219
231
|
// The frame the browser paints BEFORE the bundle's stylesheet lands: the UA's
|
|
220
232
|
// own canvas is white, and on a dark install that is a measured white flash
|
|
221
233
|
// for the length of the CSS request. The palette's ground is the only correct
|
|
@@ -243,11 +255,16 @@ export const ssrRoutes = new Elysia({ name: 'ssr' }).get('*', async ({ request }
|
|
|
243
255
|
|
|
244
256
|
return maybeCompress(
|
|
245
257
|
new Response(
|
|
246
|
-
shellHtml
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
258
|
+
applyShellDocumentFacts(shellHtml, {
|
|
259
|
+
palette: theme,
|
|
260
|
+
// The two presentation styles are read from the same blob as the
|
|
261
|
+
// palette, so the FIRST frame is already the material the user chose:
|
|
262
|
+
// without this a glass install paints one opaque frame and swaps.
|
|
263
|
+
surfaceStyle: readSettingsBlob(settings)[SURFACE_STYLE_SETTING_KEY],
|
|
264
|
+
iconStyle: readSettingsBlob(settings)[ICON_STYLE_SETTING_KEY],
|
|
265
|
+
chromeColor: chrome,
|
|
266
|
+
})
|
|
267
|
+
.replace('<!--app-head-->', firstFrame + themeStyle + brandStyle + fontLink)
|
|
251
268
|
.replace(SHELL_MARKER, `<script>window.__OMP_BOOTSTRAP__=${bootstrap}</script>`),
|
|
252
269
|
{ headers: HTML_HEADERS },
|
|
253
270
|
),
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The official colour of every file-type brand mark, resolved for both variants.
|
|
8
|
+
*
|
|
9
|
+
* `file-brand-paths.ts` carries Simple Icons' hex, which is chosen for the
|
|
10
|
+
* brand's own background. The same problem the provider marks have applies here
|
|
11
|
+
* — a `#F7DF1E` JavaScript yellow is 1.28:1 on the lightest paper — so the
|
|
12
|
+
* painted values come from the shared {@link legiblePair} rule instead of a
|
|
13
|
+
* second hand-maintained table.
|
|
14
|
+
*
|
|
15
|
+
* `dark: null` means "monochrome art": the mark is drawn in the theme's ink.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { BRAND_ICONS } from '@/shared/lib/icons/file-brand-paths';
|
|
19
|
+
import { legiblePair } from '@/shared/lib/theme/legibility';
|
|
20
|
+
|
|
21
|
+
export interface FileBrandColor {
|
|
22
|
+
/** The official Simple Icons hex, as published. */
|
|
23
|
+
base: string;
|
|
24
|
+
light: string;
|
|
25
|
+
dark: string | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const FILE_BRAND_COLORS: Readonly<Record<string, FileBrandColor>> = Object.fromEntries(
|
|
29
|
+
Object.entries(BRAND_ICONS).map(([name, brand]) => [name, { base: brand.color, ...legiblePair(brand.color) }]),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
/** The colour a file-type mark is painted in, or `null` for the theme ink. */
|
|
33
|
+
export function fileBrandColorFor(name: string | null | undefined, variant: 'light' | 'dark'): string | null {
|
|
34
|
+
if (!name) return null;
|
|
35
|
+
const entry = FILE_BRAND_COLORS[name];
|
|
36
|
+
if (!entry) return null;
|
|
37
|
+
return variant === 'dark' ? entry.dark : entry.light;
|
|
38
|
+
}
|