@molecule/app-ide-panel-logic 0.0.0-stage → 1.1.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/LICENSE +202 -0
- package/README.md +2927 -2
- package/dist/chatTimelineOrdering.d.ts +50 -0
- package/dist/chatTimelineOrdering.d.ts.map +1 -0
- package/dist/chatTimelineOrdering.js +46 -0
- package/dist/chatTimelineOrdering.js.map +1 -0
- package/dist/command-metadata.d.ts +117 -0
- package/dist/command-metadata.d.ts.map +1 -0
- package/dist/command-metadata.js +271 -0
- package/dist/command-metadata.js.map +1 -0
- package/dist/components/activity-utilities.d.ts +107 -0
- package/dist/components/activity-utilities.d.ts.map +1 -0
- package/dist/components/activity-utilities.js +154 -0
- package/dist/components/activity-utilities.js.map +1 -0
- package/dist/components/chat-autocommit-utilities.d.ts +172 -0
- package/dist/components/chat-autocommit-utilities.d.ts.map +1 -0
- package/dist/components/chat-autocommit-utilities.js +185 -0
- package/dist/components/chat-autocommit-utilities.js.map +1 -0
- package/dist/components/chat-card-style.d.ts +81 -0
- package/dist/components/chat-card-style.d.ts.map +1 -0
- package/dist/components/chat-card-style.js +78 -0
- package/dist/components/chat-card-style.js.map +1 -0
- package/dist/components/chat-commands.d.ts +17 -0
- package/dist/components/chat-commands.d.ts.map +1 -0
- package/dist/components/chat-commands.js +17 -0
- package/dist/components/chat-commands.js.map +1 -0
- package/dist/components/chat-commit-utilities.d.ts +29 -0
- package/dist/components/chat-commit-utilities.d.ts.map +1 -0
- package/dist/components/chat-commit-utilities.js +31 -0
- package/dist/components/chat-commit-utilities.js.map +1 -0
- package/dist/components/chat-cost-utilities.d.ts +62 -0
- package/dist/components/chat-cost-utilities.d.ts.map +1 -0
- package/dist/components/chat-cost-utilities.js +66 -0
- package/dist/components/chat-cost-utilities.js.map +1 -0
- package/dist/components/chat-effort-utilities.d.ts +104 -0
- package/dist/components/chat-effort-utilities.d.ts.map +1 -0
- package/dist/components/chat-effort-utilities.js +99 -0
- package/dist/components/chat-effort-utilities.js.map +1 -0
- package/dist/components/chat-help-utilities.d.ts +89 -0
- package/dist/components/chat-help-utilities.d.ts.map +1 -0
- package/dist/components/chat-help-utilities.js +131 -0
- package/dist/components/chat-help-utilities.js.map +1 -0
- package/dist/components/chat-model-mode-utilities.d.ts +169 -0
- package/dist/components/chat-model-mode-utilities.d.ts.map +1 -0
- package/dist/components/chat-model-mode-utilities.js +221 -0
- package/dist/components/chat-model-mode-utilities.js.map +1 -0
- package/dist/components/chat-models-utilities.d.ts +162 -0
- package/dist/components/chat-models-utilities.d.ts.map +1 -0
- package/dist/components/chat-models-utilities.js +302 -0
- package/dist/components/chat-models-utilities.js.map +1 -0
- package/dist/components/chat-report-utilities.d.ts +149 -0
- package/dist/components/chat-report-utilities.d.ts.map +1 -0
- package/dist/components/chat-report-utilities.js +151 -0
- package/dist/components/chat-report-utilities.js.map +1 -0
- package/dist/components/chat-scripts-utilities.d.ts +185 -0
- package/dist/components/chat-scripts-utilities.d.ts.map +1 -0
- package/dist/components/chat-scripts-utilities.js +199 -0
- package/dist/components/chat-scripts-utilities.js.map +1 -0
- package/dist/components/chat-settings-utilities.d.ts +72 -0
- package/dist/components/chat-settings-utilities.d.ts.map +1 -0
- package/dist/components/chat-settings-utilities.js +56 -0
- package/dist/components/chat-settings-utilities.js.map +1 -0
- package/dist/components/chat-share-utilities.d.ts +110 -0
- package/dist/components/chat-share-utilities.d.ts.map +1 -0
- package/dist/components/chat-share-utilities.js +90 -0
- package/dist/components/chat-share-utilities.js.map +1 -0
- package/dist/components/chat-skills-utilities.d.ts +242 -0
- package/dist/components/chat-skills-utilities.d.ts.map +1 -0
- package/dist/components/chat-skills-utilities.js +433 -0
- package/dist/components/chat-skills-utilities.js.map +1 -0
- package/dist/components/chat-stream-utilities.d.ts +74 -0
- package/dist/components/chat-stream-utilities.d.ts.map +1 -0
- package/dist/components/chat-stream-utilities.js +103 -0
- package/dist/components/chat-stream-utilities.js.map +1 -0
- package/dist/components/chat-timestamps-utilities.d.ts +123 -0
- package/dist/components/chat-timestamps-utilities.d.ts.map +1 -0
- package/dist/components/chat-timestamps-utilities.js +177 -0
- package/dist/components/chat-timestamps-utilities.js.map +1 -0
- package/dist/components/chat-tips-utilities.d.ts +108 -0
- package/dist/components/chat-tips-utilities.d.ts.map +1 -0
- package/dist/components/chat-tips-utilities.js +137 -0
- package/dist/components/chat-tips-utilities.js.map +1 -0
- package/dist/components/device-cycle.d.ts +84 -0
- package/dist/components/device-cycle.d.ts.map +1 -0
- package/dist/components/device-cycle.js +77 -0
- package/dist/components/device-cycle.js.map +1 -0
- package/dist/components/fileExplorerPersistence.d.ts +50 -0
- package/dist/components/fileExplorerPersistence.d.ts.map +1 -0
- package/dist/components/fileExplorerPersistence.js +63 -0
- package/dist/components/fileExplorerPersistence.js.map +1 -0
- package/dist/components/search-utilities.d.ts +15 -0
- package/dist/components/search-utilities.d.ts.map +1 -0
- package/dist/components/search-utilities.js +26 -0
- package/dist/components/search-utilities.js.map +1 -0
- package/dist/components/tests-bar-utilities.d.ts +106 -0
- package/dist/components/tests-bar-utilities.d.ts.map +1 -0
- package/dist/components/tests-bar-utilities.js +167 -0
- package/dist/components/tests-bar-utilities.js.map +1 -0
- package/dist/components/tests-card-utilities.d.ts +280 -0
- package/dist/components/tests-card-utilities.d.ts.map +1 -0
- package/dist/components/tests-card-utilities.js +591 -0
- package/dist/components/tests-card-utilities.js.map +1 -0
- package/dist/components/tool-call-utilities.d.ts +262 -0
- package/dist/components/tool-call-utilities.d.ts.map +1 -0
- package/dist/components/tool-call-utilities.js +1007 -0
- package/dist/components/tool-call-utilities.js.map +1 -0
- package/dist/components/user-avatar-utilities.d.ts +41 -0
- package/dist/components/user-avatar-utilities.d.ts.map +1 -0
- package/dist/components/user-avatar-utilities.js +56 -0
- package/dist/components/user-avatar-utilities.js.map +1 -0
- package/dist/components/workspace-layout-utilities.d.ts +37 -0
- package/dist/components/workspace-layout-utilities.d.ts.map +1 -0
- package/dist/components/workspace-layout-utilities.js +58 -0
- package/dist/components/workspace-layout-utilities.js.map +1 -0
- package/dist/customEventCards.d.ts +147 -0
- package/dist/customEventCards.d.ts.map +1 -0
- package/dist/customEventCards.js +36 -0
- package/dist/customEventCards.js.map +1 -0
- package/dist/icon-names.d.ts +26 -0
- package/dist/icon-names.d.ts.map +1 -0
- package/dist/icon-names.js +14 -0
- package/dist/icon-names.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard-shortcut-utilities.d.ts +63 -0
- package/dist/keyboard-shortcut-utilities.d.ts.map +1 -0
- package/dist/keyboard-shortcut-utilities.js +100 -0
- package/dist/keyboard-shortcut-utilities.js.map +1 -0
- package/dist/panels.d.ts +26 -0
- package/dist/panels.d.ts.map +1 -0
- package/dist/panels.js +26 -0
- package/dist/panels.js.map +1 -0
- package/dist/settings-metadata.d.ts +78 -0
- package/dist/settings-metadata.d.ts.map +1 -0
- package/dist/settings-metadata.js +137 -0
- package/dist/settings-metadata.js.map +1 -0
- package/dist/types.d.ts +588 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/viewport-queries.d.ts +19 -0
- package/dist/viewport-queries.d.ts.map +1 -0
- package/dist/viewport-queries.js +19 -0
- package/dist/viewport-queries.js.map +1 -0
- package/package.json +74 -4
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for dev-capture Activity cards and the Activity panel.
|
|
3
|
+
*
|
|
4
|
+
* The chat handler streams an `activity` SSE event for every captured outbound
|
|
5
|
+
* side effect (email/sms/push/webhook/channel). These helpers turn that event
|
|
6
|
+
* into the bits of UI state the inline card and the panel render — themed-icon
|
|
7
|
+
* name, one-line summary, status-pill styling — without any React/DOM dependency
|
|
8
|
+
* so they can be unit-tested in a node environment.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { t } from '@molecule/app-i18n';
|
|
13
|
+
/**
|
|
14
|
+
* Glyph NAME (in the bonded `@molecule/app-icons` set) per channel type, so the
|
|
15
|
+
* Activity card + panel render the same themed SVG `<Icon>` family as the rest
|
|
16
|
+
* of the IDE instead of raw emoji (the audit's IDE8 finding — emoji read as
|
|
17
|
+
* lower-quality than every other glyph and ignore the theme). Every value MUST
|
|
18
|
+
* resolve via `getIcon` (which throws on an unknown name): `mail`/`bell`/`link`
|
|
19
|
+
* are in the base set's required-icon contract, and `chat` (SMS) + `hash`
|
|
20
|
+
* (channel) were added to `@molecule/app-icons-molecule` for exactly these two
|
|
21
|
+
* channels the base set lacked a glyph for.
|
|
22
|
+
*/
|
|
23
|
+
const ACTIVITY_ICON_NAMES = {
|
|
24
|
+
email: 'mail',
|
|
25
|
+
sms: 'chat',
|
|
26
|
+
push: 'bell',
|
|
27
|
+
webhook: 'link',
|
|
28
|
+
channel: 'hash',
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Returns the bonded-icon-set glyph NAME for an activity type — pass it to
|
|
32
|
+
* `<Icon name={…} />` to render the themed SVG. Unknown/future types (which
|
|
33
|
+
* {@link activityFromEvent} normalizes to `webhook`) reuse the `link` glyph
|
|
34
|
+
* rather than risk a `getIcon` throw.
|
|
35
|
+
* @param type - The activity channel type.
|
|
36
|
+
* @returns The icon-set glyph name for the type.
|
|
37
|
+
*/
|
|
38
|
+
export function activityIconName(type) {
|
|
39
|
+
return ACTIVITY_ICON_NAMES[type] ?? ACTIVITY_ICON_NAMES.webhook;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Human-readable, translated label for a channel type (used as filter-tab labels).
|
|
43
|
+
* @param type - The activity channel type.
|
|
44
|
+
* @returns The translated channel label.
|
|
45
|
+
*/
|
|
46
|
+
export function activityTypeLabel(type) {
|
|
47
|
+
switch (type) {
|
|
48
|
+
case 'email':
|
|
49
|
+
return t('ide.activity.type.email', undefined, { defaultValue: 'Email' });
|
|
50
|
+
case 'sms':
|
|
51
|
+
return t('ide.activity.type.sms', undefined, { defaultValue: 'SMS' });
|
|
52
|
+
case 'push':
|
|
53
|
+
return t('ide.activity.type.push', undefined, { defaultValue: 'Push' });
|
|
54
|
+
case 'webhook':
|
|
55
|
+
return t('ide.activity.type.webhook', undefined, { defaultValue: 'Webhooks' });
|
|
56
|
+
case 'channel':
|
|
57
|
+
return t('ide.activity.type.channel', undefined, { defaultValue: 'Channel' });
|
|
58
|
+
default:
|
|
59
|
+
return type;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Human-readable, translated label for a status (shown in the status pill).
|
|
64
|
+
* @param status - The activity status.
|
|
65
|
+
* @returns The translated status label.
|
|
66
|
+
*/
|
|
67
|
+
export function activityStatusLabel(status) {
|
|
68
|
+
switch (status) {
|
|
69
|
+
case 'captured':
|
|
70
|
+
return t('ide.activity.status.captured', undefined, { defaultValue: 'Captured' });
|
|
71
|
+
case 'sent':
|
|
72
|
+
return t('ide.activity.status.sent', undefined, { defaultValue: 'Sent' });
|
|
73
|
+
case 'delivered':
|
|
74
|
+
return t('ide.activity.status.delivered', undefined, { defaultValue: 'Delivered' });
|
|
75
|
+
case 'failed':
|
|
76
|
+
return t('ide.activity.status.failed', undefined, { defaultValue: 'Failed' });
|
|
77
|
+
default:
|
|
78
|
+
return status;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Resolves the status-pill colors for a given status. Uses RGBA literals (not
|
|
83
|
+
* ClassMap classes) because these semantic status hues are not part of the
|
|
84
|
+
* surface/text token set — the same approach `VerificationBadge` takes for its
|
|
85
|
+
* pass/fail coloring.
|
|
86
|
+
* @param status - The activity status.
|
|
87
|
+
* @returns An object with `fg` (text) and `bg` (background) CSS color strings.
|
|
88
|
+
*/
|
|
89
|
+
export function activityStatusColors(status) {
|
|
90
|
+
switch (status) {
|
|
91
|
+
case 'failed':
|
|
92
|
+
return { fg: '#f85149', bg: 'rgba(248,81,73,0.12)' };
|
|
93
|
+
case 'delivered':
|
|
94
|
+
return { fg: '#3fb950', bg: 'rgba(63,185,80,0.12)' };
|
|
95
|
+
case 'sent':
|
|
96
|
+
return { fg: '#4070e0', bg: 'rgba(64,112,224,0.12)' };
|
|
97
|
+
case 'captured':
|
|
98
|
+
default:
|
|
99
|
+
return { fg: '#d4a017', bg: 'rgba(234,179,8,0.12)' };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Builds the one-line summary shown on the inline card: the activity's own
|
|
104
|
+
* summary, with the recipient appended after an arrow when present
|
|
105
|
+
* (e.g. `Welcome email → user@example.com`). Falls back to a translated,
|
|
106
|
+
* type-specific default when no summary was captured.
|
|
107
|
+
* @param activity - The activity to summarize.
|
|
108
|
+
* @returns The single-line summary string.
|
|
109
|
+
*/
|
|
110
|
+
export function activitySummaryLine(activity) {
|
|
111
|
+
const base = activity.summary?.trim() ||
|
|
112
|
+
t('ide.activity.defaultSummary', { type: activityTypeLabel(activity.type) }, { defaultValue: '{{type}} captured' });
|
|
113
|
+
if (activity.recipient?.trim()) {
|
|
114
|
+
return `${base} → ${activity.recipient.trim()}`;
|
|
115
|
+
}
|
|
116
|
+
return base;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Maps a raw SSE `activity` event payload into a normalized {@link Activity}.
|
|
120
|
+
* Tolerates missing optional fields and supplies an id/timestamp if absent.
|
|
121
|
+
* @param raw - The `activity` field from the SSE event.
|
|
122
|
+
* @param raw.id - Activity id; generated if absent.
|
|
123
|
+
* @param raw.type - Channel type; defaults to `webhook` if absent.
|
|
124
|
+
* @param raw.status - Lifecycle status; defaults to `captured` if absent.
|
|
125
|
+
* @param raw.recipient - Optional recipient.
|
|
126
|
+
* @param raw.summary - Optional short summary.
|
|
127
|
+
* @param raw.timestamp - ISO timestamp; defaults to now if absent.
|
|
128
|
+
* @returns A normalized Activity object.
|
|
129
|
+
*/
|
|
130
|
+
export function activityFromEvent(raw) {
|
|
131
|
+
return {
|
|
132
|
+
id: raw.id ?? (typeof crypto !== 'undefined' ? crypto.randomUUID() : String(Date.now())),
|
|
133
|
+
type: raw.type ?? 'webhook',
|
|
134
|
+
status: raw.status ?? 'captured',
|
|
135
|
+
recipient: raw.recipient,
|
|
136
|
+
summary: raw.summary,
|
|
137
|
+
timestamp: raw.timestamp ?? new Date().toISOString(),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** All channel types, in the order their filter tabs should appear. */
|
|
141
|
+
export const ACTIVITY_TYPES = ['email', 'sms', 'push', 'webhook', 'channel'];
|
|
142
|
+
/**
|
|
143
|
+
* Filters a list of activities by channel type. `null` (the "All" tab) returns
|
|
144
|
+
* every activity unchanged.
|
|
145
|
+
* @param activities - The activities to filter.
|
|
146
|
+
* @param type - The channel type to keep, or `null` for all.
|
|
147
|
+
* @returns The filtered list (a new array unless `type` is null).
|
|
148
|
+
*/
|
|
149
|
+
export function filterActivitiesByType(activities, type) {
|
|
150
|
+
if (!type)
|
|
151
|
+
return activities;
|
|
152
|
+
return activities.filter((a) => a.type === type);
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=activity-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity-utilities.js","sourceRoot":"","sources":["../../src/components/activity-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AA4BtC;;;;;;;;;GASG;AACH,MAAM,mBAAmB,GAAmC;IAC1D,KAAK,EAAE,MAAM;IACb,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,MAAM;CAChB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAkB;IACjD,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,mB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AC,GAAG,EAAE,CAAC,CAAC;QACxF,IAAI,EAAG,GAAG,CAAC,IAAqB,IAAI,SAAS;QAC7C,MAAM,EAAG,GAAG,CAAC,MAAyB,IAAI,UAAU;QACpD,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACrD,CAAA;AACH,CAAC;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,cAAc,GAAmB,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AAE5F;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAsB,EACtB,IAAyB;IAEzB,IAAI,CAAC,IAAI;QAAE,OAAO,UAAU,CAAA;IAC5B,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers backing the `/autocommit <seconds>` command and its countdown
|
|
3
|
+
* badge.
|
|
4
|
+
*
|
|
5
|
+
* `/autocommit <n>` arms a client-side, debounce-style countdown: every file
|
|
6
|
+
* change restarts an `n`-second timer, and when the timer reaches zero the chat
|
|
7
|
+
* fires the *existing* `/commit` path (no new backend). After a commit the timer
|
|
8
|
+
* disarms (pauses) until the next file change, so a clean tree is never
|
|
9
|
+
* committed in a loop. `/autocommit 0` cancels it entirely.
|
|
10
|
+
*
|
|
11
|
+
* Auto-commit is ON BY DEFAULT: a project that has never persisted
|
|
12
|
+
* `autoCommitSeconds` resolves to {@link DEFAULT_AUTO_COMMIT_SECONDS} (see
|
|
13
|
+
* {@link resolveAutoCommitSeconds}); only an explicit `0` keeps it off.
|
|
14
|
+
*
|
|
15
|
+
* The cadence is a PERSISTED project setting (`project.settings.autoCommitSeconds`),
|
|
16
|
+
* not a per-session toggle: the component debounce-PATCHes it whenever the user
|
|
17
|
+
* changes it and, on load, dispatches `hydrate` to restore it in the paused
|
|
18
|
+
* state — so it survives a reload/reconnect (it re-arms on the next file change).
|
|
19
|
+
*
|
|
20
|
+
* The countdown is modelled as a pure reducer here so the
|
|
21
|
+
* arm/hydrate/reset/tick/fire state machine can be unit tested without React,
|
|
22
|
+
* timers, or a backend. The component owns only the side effects: the GET that
|
|
23
|
+
* hydrates the persisted cadence, the debounced PATCH that persists changes, a
|
|
24
|
+
* 1s interval dispatching `tick`, a file-change effect dispatching `reset`, and
|
|
25
|
+
* a `fire`-when-due effect that runs `/commit` then dispatches `fired`. The
|
|
26
|
+
* component also owns the HOLD: while the agent is still working (a turn is
|
|
27
|
+
* streaming locally or remotely, or an auto-fix follow-up is pending) it
|
|
28
|
+
* suspends the tick interval and the fire effect, so a commit only ever happens
|
|
29
|
+
* once the agent and the user are actually finished — never mid-turn. Any
|
|
30
|
+
* user-facing prose lives in the component via `t()`, never here.
|
|
31
|
+
*
|
|
32
|
+
* @module
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* The countdown's state.
|
|
36
|
+
*
|
|
37
|
+
* `intervalSeconds` is the configured cadence (`0` = disabled). `remaining` is
|
|
38
|
+
* the live count: a positive number while counting down, `0` at the instant a
|
|
39
|
+
* commit is due, and `null` while disabled or paused (after a commit, awaiting
|
|
40
|
+
* the next file change to re-arm).
|
|
41
|
+
*/
|
|
42
|
+
export interface AutoCommitState {
|
|
43
|
+
/** Configured countdown length in seconds; `0` when auto-commit is off. */
|
|
44
|
+
intervalSeconds: number;
|
|
45
|
+
/** Seconds left until the next auto-commit; `null` when disabled or paused. */
|
|
46
|
+
remaining: number | null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Actions the countdown reducer accepts.
|
|
50
|
+
*
|
|
51
|
+
* - `set` — apply a `/autocommit <seconds>` command (`seconds <= 0` disables);
|
|
52
|
+
* arms AND starts a fresh countdown (an explicit, just-now user choice).
|
|
53
|
+
* - `hydrate` — restore a cadence persisted on the project (e.g. on reload),
|
|
54
|
+
* enabled but PAUSED (`seconds <= 0` disables). Unlike `set`, it does NOT
|
|
55
|
+
* start counting down — the countdown only re-arms on the next file change —
|
|
56
|
+
* so reopening a project never auto-commits a tree the user hasn't touched.
|
|
57
|
+
* - `reset` — a file changed; restart the full countdown (no-op when disabled).
|
|
58
|
+
* - `tick` — one second elapsed; decrement toward zero (no-op when paused).
|
|
59
|
+
* - `fired` — a commit was just dispatched; pause until the next file change.
|
|
60
|
+
*/
|
|
61
|
+
export type AutoCommitAction = {
|
|
62
|
+
type: 'set';
|
|
63
|
+
seconds: number;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'hydrate';
|
|
66
|
+
seconds: number;
|
|
67
|
+
} | {
|
|
68
|
+
type: 'reset';
|
|
69
|
+
} | {
|
|
70
|
+
type: 'tick';
|
|
71
|
+
} | {
|
|
72
|
+
type: 'fired';
|
|
73
|
+
};
|
|
74
|
+
/** The disabled (off) countdown state — the reducer's initial value. */
|
|
75
|
+
export declare const AUTO_COMMIT_DISABLED: AutoCommitState;
|
|
76
|
+
/**
|
|
77
|
+
* The default auto-commit cadence in seconds — auto-commit is ON by default.
|
|
78
|
+
* Projects that have never persisted `autoCommitSeconds` hydrate to this
|
|
79
|
+
* cadence (paused, arming on the first file change); only an explicit `0`
|
|
80
|
+
* (the user cancelled) keeps auto-commit off.
|
|
81
|
+
*
|
|
82
|
+
* The value is the TOTAL debounce after the last file change (once the agent's
|
|
83
|
+
* turn has finished): a short quiet period, then the final
|
|
84
|
+
* {@link AUTO_COMMIT_COUNTDOWN_VISIBLE_SECONDS} seconds render as a live
|
|
85
|
+
* countdown on the commit button. 5s = 2s quiet + 3s visible countdown.
|
|
86
|
+
*/
|
|
87
|
+
export declare const DEFAULT_AUTO_COMMIT_SECONDS = 5;
|
|
88
|
+
/**
|
|
89
|
+
* How many final seconds of the countdown are DISPLAYED as a live countdown.
|
|
90
|
+
* Until the countdown drops to this threshold, the commit-bar button stays a
|
|
91
|
+
* plain green "Commit" (a bare "12s" pill told users nothing); the countdown
|
|
92
|
+
* label only takes over for these last seconds, right before the auto-commit
|
|
93
|
+
* fires. Cadences at or below the threshold show the countdown the whole time.
|
|
94
|
+
*/
|
|
95
|
+
export declare const AUTO_COMMIT_COUNTDOWN_VISIBLE_SECONDS = 3;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the countdown is in its visible window — armed and within the final
|
|
98
|
+
* {@link AUTO_COMMIT_COUNTDOWN_VISIBLE_SECONDS} seconds — i.e. the commit
|
|
99
|
+
* button should render the live "Auto-commit in Ns" label instead of "Commit".
|
|
100
|
+
*
|
|
101
|
+
* @param state - The countdown state.
|
|
102
|
+
* @returns `true` when armed with at most the visible-window seconds left.
|
|
103
|
+
*/
|
|
104
|
+
export declare function isAutoCommitCountdownVisible(state: AutoCommitState): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Resolves the persisted `project.settings.autoCommitSeconds` value to the
|
|
107
|
+
* effective cadence. A finite number is an explicit user choice: positive
|
|
108
|
+
* values floor to whole seconds, non-positive values mean "the user turned
|
|
109
|
+
* auto-commit off" (`0`). Anything else — missing, never configured, or
|
|
110
|
+
* invalid — falls back to {@link DEFAULT_AUTO_COMMIT_SECONDS}, because
|
|
111
|
+
* auto-commit is on by default.
|
|
112
|
+
*
|
|
113
|
+
* @param saved - The raw persisted setting value.
|
|
114
|
+
* @returns The effective cadence in whole seconds (`0` = off).
|
|
115
|
+
*/
|
|
116
|
+
export declare function resolveAutoCommitSeconds(saved: unknown): number;
|
|
117
|
+
/**
|
|
118
|
+
* Pure reducer for the auto-commit countdown. Deterministic and side-effect
|
|
119
|
+
* free: the component performs the actual commit when {@link isAutoCommitDue}
|
|
120
|
+
* becomes true, then dispatches `fired`.
|
|
121
|
+
*
|
|
122
|
+
* @param state - The current countdown state.
|
|
123
|
+
* @param action - The action to apply.
|
|
124
|
+
* @returns The next countdown state.
|
|
125
|
+
*/
|
|
126
|
+
export declare function autoCommitReducer(state: AutoCommitState, action: AutoCommitAction): AutoCommitState;
|
|
127
|
+
/**
|
|
128
|
+
* Whether auto-commit is enabled (a positive cadence is configured), regardless
|
|
129
|
+
* of whether it is currently counting down or paused.
|
|
130
|
+
*
|
|
131
|
+
* @param state - The countdown state.
|
|
132
|
+
* @returns `true` when `intervalSeconds > 0`.
|
|
133
|
+
*/
|
|
134
|
+
export declare function isAutoCommitEnabled(state: AutoCommitState): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Whether the countdown is actively armed (counting down), i.e. a 1s tick
|
|
137
|
+
* interval should be running. False when disabled or paused after a commit.
|
|
138
|
+
*
|
|
139
|
+
* @param state - The countdown state.
|
|
140
|
+
* @returns `true` when `remaining` is a number.
|
|
141
|
+
*/
|
|
142
|
+
export declare function isAutoCommitArmed(state: AutoCommitState): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Whether a commit is due this instant (the countdown has reached zero). The
|
|
145
|
+
* component reacts to this by running `/commit` and dispatching `fired`.
|
|
146
|
+
*
|
|
147
|
+
* @param state - The countdown state.
|
|
148
|
+
* @returns `true` when `remaining === 0`.
|
|
149
|
+
*/
|
|
150
|
+
export declare function isAutoCommitDue(state: AutoCommitState): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Parses an `/autocommit [seconds]` command.
|
|
153
|
+
*
|
|
154
|
+
* Returns `{ seconds: null }` when `/autocommit` is typed with no argument (the
|
|
155
|
+
* caller shows usage/current state), `{ seconds: n }` for a non-negative integer
|
|
156
|
+
* argument (`0` cancels), or `null` when the input is not the command.
|
|
157
|
+
*
|
|
158
|
+
* @param input - The raw chat input.
|
|
159
|
+
* @returns The parsed command, or `null` when it is not `/autocommit`.
|
|
160
|
+
*/
|
|
161
|
+
export declare function parseAutoCommitCommand(input: string): {
|
|
162
|
+
seconds: number | null;
|
|
163
|
+
} | null;
|
|
164
|
+
/**
|
|
165
|
+
* Formats the countdown's remaining seconds for the compact badge (e.g. `"12s"`).
|
|
166
|
+
* Returns `''` when there is nothing to show (disabled or paused).
|
|
167
|
+
*
|
|
168
|
+
* @param state - The countdown state.
|
|
169
|
+
* @returns The badge label, or `''`.
|
|
170
|
+
*/
|
|
171
|
+
export declare function formatAutoCommitBadge(state: AutoCommitState): string;
|
|
172
|
+
//# sourceMappingURL=chat-autocommit-utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-autocommit-utilities.d.ts","sourceRoot":"","sources":["../../src/components/chat-autocommit-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,eAAe,EAAE,MAAM,CAAA;IACvB,+EAA+E;IAC/E,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAA;AAErB,wEAAwE;AACxE,eAAO,MAAM,oBAAoB,EAAE,eAAyD,CAAA;AAE5F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,IAAI,CAAA;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC,IAAI,CAAA;AAEtD;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAE5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAK/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,gBAAgB,GACvB,eAAe,CA0BjB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEnE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAE/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAKvF;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAGpE"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers backing the `/autocommit <seconds>` command and its countdown
|
|
3
|
+
* badge.
|
|
4
|
+
*
|
|
5
|
+
* `/autocommit <n>` arms a client-side, debounce-style countdown: every file
|
|
6
|
+
* change restarts an `n`-second timer, and when the timer reaches zero the chat
|
|
7
|
+
* fires the *existing* `/commit` path (no new backend). After a commit the timer
|
|
8
|
+
* disarms (pauses) until the next file change, so a clean tree is never
|
|
9
|
+
* committed in a loop. `/autocommit 0` cancels it entirely.
|
|
10
|
+
*
|
|
11
|
+
* Auto-commit is ON BY DEFAULT: a project that has never persisted
|
|
12
|
+
* `autoCommitSeconds` resolves to {@link DEFAULT_AUTO_COMMIT_SECONDS} (see
|
|
13
|
+
* {@link resolveAutoCommitSeconds}); only an explicit `0` keeps it off.
|
|
14
|
+
*
|
|
15
|
+
* The cadence is a PERSISTED project setting (`project.settings.autoCommitSeconds`),
|
|
16
|
+
* not a per-session toggle: the component debounce-PATCHes it whenever the user
|
|
17
|
+
* changes it and, on load, dispatches `hydrate` to restore it in the paused
|
|
18
|
+
* state — so it survives a reload/reconnect (it re-arms on the next file change).
|
|
19
|
+
*
|
|
20
|
+
* The countdown is modelled as a pure reducer here so the
|
|
21
|
+
* arm/hydrate/reset/tick/fire state machine can be unit tested without React,
|
|
22
|
+
* timers, or a backend. The component owns only the side effects: the GET that
|
|
23
|
+
* hydrates the persisted cadence, the debounced PATCH that persists changes, a
|
|
24
|
+
* 1s interval dispatching `tick`, a file-change effect dispatching `reset`, and
|
|
25
|
+
* a `fire`-when-due effect that runs `/commit` then dispatches `fired`. The
|
|
26
|
+
* component also owns the HOLD: while the agent is still working (a turn is
|
|
27
|
+
* streaming locally or remotely, or an auto-fix follow-up is pending) it
|
|
28
|
+
* suspends the tick interval and the fire effect, so a commit only ever happens
|
|
29
|
+
* once the agent and the user are actually finished — never mid-turn. Any
|
|
30
|
+
* user-facing prose lives in the component via `t()`, never here.
|
|
31
|
+
*
|
|
32
|
+
* @module
|
|
33
|
+
*/
|
|
34
|
+
/** The disabled (off) countdown state — the reducer's initial value. */
|
|
35
|
+
export const AUTO_COMMIT_DISABLED = { intervalSeconds: 0, remaining: null };
|
|
36
|
+
/**
|
|
37
|
+
* The default auto-commit cadence in seconds — auto-commit is ON by default.
|
|
38
|
+
* Projects that have never persisted `autoCommitSeconds` hydrate to this
|
|
39
|
+
* cadence (paused, arming on the first file change); only an explicit `0`
|
|
40
|
+
* (the user cancelled) keeps auto-commit off.
|
|
41
|
+
*
|
|
42
|
+
* The value is the TOTAL debounce after the last file change (once the agent's
|
|
43
|
+
* turn has finished): a short quiet period, then the final
|
|
44
|
+
* {@link AUTO_COMMIT_COUNTDOWN_VISIBLE_SECONDS} seconds render as a live
|
|
45
|
+
* countdown on the commit button. 5s = 2s quiet + 3s visible countdown.
|
|
46
|
+
*/
|
|
47
|
+
export const DEFAULT_AUTO_COMMIT_SECONDS = 5;
|
|
48
|
+
/**
|
|
49
|
+
* How many final seconds of the countdown are DISPLAYED as a live countdown.
|
|
50
|
+
* Until the countdown drops to this threshold, the commit-bar button stays a
|
|
51
|
+
* plain green "Commit" (a bare "12s" pill told users nothing); the countdown
|
|
52
|
+
* label only takes over for these last seconds, right before the auto-commit
|
|
53
|
+
* fires. Cadences at or below the threshold show the countdown the whole time.
|
|
54
|
+
*/
|
|
55
|
+
export const AUTO_COMMIT_COUNTDOWN_VISIBLE_SECONDS = 3;
|
|
56
|
+
/**
|
|
57
|
+
* Whether the countdown is in its visible window — armed and within the final
|
|
58
|
+
* {@link AUTO_COMMIT_COUNTDOWN_VISIBLE_SECONDS} seconds — i.e. the commit
|
|
59
|
+
* button should render the live "Auto-commit in Ns" label instead of "Commit".
|
|
60
|
+
*
|
|
61
|
+
* @param state - The countdown state.
|
|
62
|
+
* @returns `true` when armed with at most the visible-window seconds left.
|
|
63
|
+
*/
|
|
64
|
+
export function isAutoCommitCountdownVisible(state) {
|
|
65
|
+
return state.remaining !== null && state.remaining <= AUTO_COMMIT_COUNTDOWN_VISIBLE_SECONDS;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Resolves the persisted `project.settings.autoCommitSeconds` value to the
|
|
69
|
+
* effective cadence. A finite number is an explicit user choice: positive
|
|
70
|
+
* values floor to whole seconds, non-positive values mean "the user turned
|
|
71
|
+
* auto-commit off" (`0`). Anything else — missing, never configured, or
|
|
72
|
+
* invalid — falls back to {@link DEFAULT_AUTO_COMMIT_SECONDS}, because
|
|
73
|
+
* auto-commit is on by default.
|
|
74
|
+
*
|
|
75
|
+
* @param saved - The raw persisted setting value.
|
|
76
|
+
* @returns The effective cadence in whole seconds (`0` = off).
|
|
77
|
+
*/
|
|
78
|
+
export function resolveAutoCommitSeconds(saved) {
|
|
79
|
+
if (typeof saved === 'number' && Number.isFinite(saved)) {
|
|
80
|
+
return Math.max(0, Math.floor(saved));
|
|
81
|
+
}
|
|
82
|
+
return DEFAULT_AUTO_COMMIT_SECONDS;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Pure reducer for the auto-commit countdown. Deterministic and side-effect
|
|
86
|
+
* free: the component performs the actual commit when {@link isAutoCommitDue}
|
|
87
|
+
* becomes true, then dispatches `fired`.
|
|
88
|
+
*
|
|
89
|
+
* @param state - The current countdown state.
|
|
90
|
+
* @param action - The action to apply.
|
|
91
|
+
* @returns The next countdown state.
|
|
92
|
+
*/
|
|
93
|
+
export function autoCommitReducer(state, action) {
|
|
94
|
+
switch (action.type) {
|
|
95
|
+
case 'set':
|
|
96
|
+
// <= 0 cancels; a positive cadence arms and starts the first countdown.
|
|
97
|
+
if (action.seconds <= 0)
|
|
98
|
+
return AUTO_COMMIT_DISABLED;
|
|
99
|
+
return { intervalSeconds: action.seconds, remaining: action.seconds };
|
|
100
|
+
case 'hydrate':
|
|
101
|
+
// Restore a persisted cadence in the paused state: enabled (so the badge
|
|
102
|
+
// shows "on") but NOT counting down — it re-arms via `reset` on the next
|
|
103
|
+
// file change. <= 0 means auto-commit was off on the project.
|
|
104
|
+
if (action.seconds <= 0)
|
|
105
|
+
return AUTO_COMMIT_DISABLED;
|
|
106
|
+
return { intervalSeconds: action.seconds, remaining: null };
|
|
107
|
+
case 'reset':
|
|
108
|
+
// A file changed: re-arm the full countdown — but only when enabled.
|
|
109
|
+
if (state.intervalSeconds <= 0)
|
|
110
|
+
return state;
|
|
111
|
+
return { intervalSeconds: state.intervalSeconds, remaining: state.intervalSeconds };
|
|
112
|
+
case 'tick':
|
|
113
|
+
// Disabled or paused (remaining === null) ignores ticks.
|
|
114
|
+
if (state.remaining === null)
|
|
115
|
+
return state;
|
|
116
|
+
return { intervalSeconds: state.intervalSeconds, remaining: Math.max(0, state.remaining - 1) };
|
|
117
|
+
case 'fired':
|
|
118
|
+
// Commit dispatched: pause (don't re-fire on a clean tree) until the next
|
|
119
|
+
// file change re-arms via `reset`. Keep the configured cadence.
|
|
120
|
+
if (state.intervalSeconds <= 0)
|
|
121
|
+
return state;
|
|
122
|
+
return { intervalSeconds: state.intervalSeconds, remaining: null };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Whether auto-commit is enabled (a positive cadence is configured), regardless
|
|
127
|
+
* of whether it is currently counting down or paused.
|
|
128
|
+
*
|
|
129
|
+
* @param state - The countdown state.
|
|
130
|
+
* @returns `true` when `intervalSeconds > 0`.
|
|
131
|
+
*/
|
|
132
|
+
export function isAutoCommitEnabled(state) {
|
|
133
|
+
return state.intervalSeconds > 0;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Whether the countdown is actively armed (counting down), i.e. a 1s tick
|
|
137
|
+
* interval should be running. False when disabled or paused after a commit.
|
|
138
|
+
*
|
|
139
|
+
* @param state - The countdown state.
|
|
140
|
+
* @returns `true` when `remaining` is a number.
|
|
141
|
+
*/
|
|
142
|
+
export function isAutoCommitArmed(state) {
|
|
143
|
+
return state.remaining !== null;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Whether a commit is due this instant (the countdown has reached zero). The
|
|
147
|
+
* component reacts to this by running `/commit` and dispatching `fired`.
|
|
148
|
+
*
|
|
149
|
+
* @param state - The countdown state.
|
|
150
|
+
* @returns `true` when `remaining === 0`.
|
|
151
|
+
*/
|
|
152
|
+
export function isAutoCommitDue(state) {
|
|
153
|
+
return state.remaining === 0;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Parses an `/autocommit [seconds]` command.
|
|
157
|
+
*
|
|
158
|
+
* Returns `{ seconds: null }` when `/autocommit` is typed with no argument (the
|
|
159
|
+
* caller shows usage/current state), `{ seconds: n }` for a non-negative integer
|
|
160
|
+
* argument (`0` cancels), or `null` when the input is not the command.
|
|
161
|
+
*
|
|
162
|
+
* @param input - The raw chat input.
|
|
163
|
+
* @returns The parsed command, or `null` when it is not `/autocommit`.
|
|
164
|
+
*/
|
|
165
|
+
export function parseAutoCommitCommand(input) {
|
|
166
|
+
const match = input.trim().match(/^\/autocommit(?:\s+(\d+))?$/i);
|
|
167
|
+
if (!match)
|
|
168
|
+
return null;
|
|
169
|
+
if (match[1] === undefined)
|
|
170
|
+
return { seconds: null };
|
|
171
|
+
return { seconds: Number(match[1]) };
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Formats the countdown's remaining seconds for the compact badge (e.g. `"12s"`).
|
|
175
|
+
* Returns `''` when there is nothing to show (disabled or paused).
|
|
176
|
+
*
|
|
177
|
+
* @param state - The countdown state.
|
|
178
|
+
* @returns The badge label, or `''`.
|
|
179
|
+
*/
|
|
180
|
+
export function formatAutoCommitBadge(state) {
|
|
181
|
+
if (state.remaining === null)
|
|
182
|
+
return '';
|
|
183
|
+
return `${state.remaining}s`;
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=chat-autocommit-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-autocommit-utilities.js","sourceRoot":"","sources":["../../src/components/chat-autocommit-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAqCH,wEAAwE;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAoB,EAAE,eAAe,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;AAE5F;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,CAAC,CAAA;AAEtD;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAsB;IACjE,OAAO,KAAK,CAAC,SAAS,KAAK,IAAI,IAAI,KAAK,CAAC,SAAS,IAAI,qCAAqC,CAAA;AAC7F,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CA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,CAAC;gBAAE,OAAO,KAAK,CAAA;YAC5C,OAAO,EAAE,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;IACtE,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAsB;IACxD,OAAO,KAAK,CAAC,eAAe,GAAG,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAsB;IACtD,OAAO,KAAK,CAAC,SAAS,KAAK,IAAI,CAAA;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAsB;IACpD,OAAO,KAAK,CAAC,SAAS,KAAK,CAAC,CAAA;AAC9B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAA;IAChE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IACvB,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IACpD,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AACtC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAsB;IAC1D,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI;QAAE,OAAO,EAAE,CAAA;IACvC,OAAO,GAAG,KAAK,CAAC,SAAS,GAAG,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared visual treatment for the boxed "info" cards in the Synthase chat
|
|
3
|
+
* timeline (the notice / tip / upgrade card, the activity card, and the `/help`,
|
|
4
|
+
* `/settings`, `/skills`, `/scripts` slash-command cards).
|
|
5
|
+
*
|
|
6
|
+
* These cards used to drift — some sat on a flat gray `surfaceSecondary` surface,
|
|
7
|
+
* others on a tinted background; icon sizes, paddings and radii differed; and the
|
|
8
|
+
* notice card carried a 3px left accent bar while the rest had a plain 1px frame.
|
|
9
|
+
* This module is the single source of truth that makes them one consistent family:
|
|
10
|
+
*
|
|
11
|
+
* - a subtle color-mix **tint** (never a flat gray surface),
|
|
12
|
+
* - a full **1px border on ALL sides** — never a thicker left accent bar,
|
|
13
|
+
* - one padding, one radius, one leading-icon size.
|
|
14
|
+
*
|
|
15
|
+
* A single `accent` colour drives both the border and the background via
|
|
16
|
+
* `color-mix` (works with a CSS var OR a hex), so a semantic card passes its tone
|
|
17
|
+
* colour (success green, upgrade gold, …) and a neutral info card passes the
|
|
18
|
+
* default (the theme's primary). The tint stays subtle and recolors with the
|
|
19
|
+
* active theme/brand instead of clashing with it.
|
|
20
|
+
*
|
|
21
|
+
* Each framework's IDE package builds its cards from these values, so the family looks the
|
|
22
|
+
* same in all of them. React spreads {@link chatCardStyle} into `style` as is; a framework
|
|
23
|
+
* whose style objects take no unitless numbers writes `borderRadius` with `px`.
|
|
24
|
+
*
|
|
25
|
+
* Do NOT layer a `borderLeft` / left-accent override on top of {@link chatCardStyle}
|
|
26
|
+
* — the whole point is a uniform 1px frame. Callers own only layout
|
|
27
|
+
* (`display`/`gap`/`alignItems`) and the bottom-margin timeline rhythm.
|
|
28
|
+
*
|
|
29
|
+
* @module
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Neutral accent for non-semantic info cards: the theme's primary colour, so a
|
|
33
|
+
* card that has no status meaning is still subtly *tinted* (never a flat gray
|
|
34
|
+
* surface) and recolors with the brand.
|
|
35
|
+
*/
|
|
36
|
+
export declare const CHAT_CARD_NEUTRAL_ACCENT = "var(--mol-color-primary, #6366f1)";
|
|
37
|
+
/** Uniform leading-icon size (px) for every chat-timeline info card. */
|
|
38
|
+
export declare const CHAT_CARD_ICON_SIZE = 18;
|
|
39
|
+
/**
|
|
40
|
+
* Build the tinted border colour for a chat info card from its accent.
|
|
41
|
+
*
|
|
42
|
+
* @param accent - Accent source colour (CSS var or hex). Defaults to the theme primary.
|
|
43
|
+
* @param pct - Opacity of the accent in the mix (percent). Defaults to the resting 40.
|
|
44
|
+
* @returns A `color-mix` border colour.
|
|
45
|
+
*/
|
|
46
|
+
export declare function chatCardBorder(accent?: string, pct?: number): string;
|
|
47
|
+
/**
|
|
48
|
+
* Build the tinted background colour for a chat info card from its accent.
|
|
49
|
+
*
|
|
50
|
+
* @param accent - Accent source colour (CSS var or hex). Defaults to the theme primary.
|
|
51
|
+
* @param pct - Opacity of the accent in the mix (percent). Defaults to the resting 10.
|
|
52
|
+
* @returns A `color-mix` background colour.
|
|
53
|
+
*/
|
|
54
|
+
export declare function chatCardBg(accent?: string, pct?: number): string;
|
|
55
|
+
/**
|
|
56
|
+
* A chat info card's container chrome, as React's `style` takes it (a unitless
|
|
57
|
+
* `borderRadius` is pixels).
|
|
58
|
+
*/
|
|
59
|
+
export interface ChatCardStyle {
|
|
60
|
+
/** Inner padding. */
|
|
61
|
+
padding: string;
|
|
62
|
+
/** Corner radius in pixels. */
|
|
63
|
+
borderRadius: number;
|
|
64
|
+
/** The 1px tinted frame on all sides. */
|
|
65
|
+
border: string;
|
|
66
|
+
/** The tinted background. */
|
|
67
|
+
background: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The single container chrome shared by every boxed info card in the chat
|
|
71
|
+
* timeline: subtle tint, full 1px border on all sides, one padding, one radius.
|
|
72
|
+
*
|
|
73
|
+
* Spread it first, then add layout (`display`/`gap`/`alignItems`) and the
|
|
74
|
+
* bottom-margin rhythm at the call site — e.g.
|
|
75
|
+
* `style={{ display: 'flex', gap: 10, marginBottom: TIMELINE_ITEM_GAP, ...chatCardStyle(accent) }}`.
|
|
76
|
+
*
|
|
77
|
+
* @param accent - Tint/border source colour. Defaults to the theme primary (neutral cards).
|
|
78
|
+
* @returns The container `style` chrome (border, background, padding, radius).
|
|
79
|
+
*/
|
|
80
|
+
export declare function chatCardStyle(accent?: string): ChatCardStyle;
|
|
81
|
+
//# sourceMappingURL=chat-card-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-card-style.d.ts","sourceRoot":"","sources":["../../src/components/chat-card-style.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,sCAAsC,CAAA;AAE3E,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,MAAiC,EAAE,GAAG,SAAK,GAAG,MAAM,CAE1F;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,GAAE,MAAiC,EAAE,GAAG,SAAK,GAAG,MAAM,CAEtF;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,+BAA+B;IAC/B,YAAY,EAAE,MAAM,CAAA;IACpB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,MAAM,GAAE,MAAiC,GAAG,aAAa,CAOtF"}
|