@molecule/app-ide-panel-logic 0.0.0-stage → 0.0.1-stage
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 +2925 -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 +256 -0
- package/dist/components/tool-call-utilities.d.ts.map +1 -0
- package/dist/components/tool-call-utilities.js +1004 -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,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat timestamp visibility + formatting — the pure half of the `/timestamps`
|
|
3
|
+
* feature (the hook lives in `hooks/useChatTimestampsVisible.ts`, the rendered
|
|
4
|
+
* label in `ChatTimestamp.tsx`).
|
|
5
|
+
*
|
|
6
|
+
* Visibility is a PER-DEVICE, per-user display preference, stored in
|
|
7
|
+
* localStorage like `/sounds` and `/mic` — never project settings, so a viewer
|
|
8
|
+
* can toggle it and it never changes what a teammate sees. A host's own
|
|
9
|
+
* settings UI toggles the same value through {@link setChatTimestampsVisible},
|
|
10
|
+
* and every mounted chat follows via {@link CHAT_TIMESTAMPS_EVENT} (same tab)
|
|
11
|
+
* and the `storage` event (other tabs).
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/** localStorage key holding `'true'` / `'false'`. Absent = the default (hidden). */
|
|
16
|
+
export declare const CHAT_TIMESTAMPS_STORAGE_KEY = "mol_chat_show_timestamps";
|
|
17
|
+
/** Window event dispatched (same tab) whenever the preference changes. */
|
|
18
|
+
export declare const CHAT_TIMESTAMPS_EVENT = "mol:chat-timestamps-changed";
|
|
19
|
+
/**
|
|
20
|
+
* Parses the stored preference. Only an explicit `'true'` shows every timestamp,
|
|
21
|
+
* so a missing or unreadable value keeps the default (off — only the user's own
|
|
22
|
+
* message headers and critical events carry a time; see {@link planChatTimestamps}).
|
|
23
|
+
*
|
|
24
|
+
* @param raw - The raw localStorage value.
|
|
25
|
+
* @returns Whether timestamps are visible on every item.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseChatTimestampsVisible(raw: string | null): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Reads this device's preference.
|
|
30
|
+
*
|
|
31
|
+
* @returns Whether chat timestamps are visible on every item (default `false`).
|
|
32
|
+
*/
|
|
33
|
+
export declare function getChatTimestampsVisible(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The active i18n locale, or the browser's when reading it throws.
|
|
36
|
+
*
|
|
37
|
+
* @deprecated A component that formats with this keeps the old language after a
|
|
38
|
+
* locale switch, because nothing re-renders it. Read the locale through the
|
|
39
|
+
* framework binding instead (`useLocale()` in React), which re-renders on a switch.
|
|
40
|
+
* `getLocale()` from `@molecule/app-i18n` does not throw: with no provider bonded
|
|
41
|
+
* it bonds a default one.
|
|
42
|
+
* @param getLocale - The i18n accessor.
|
|
43
|
+
* @returns A BCP 47 locale.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveChatLocale(getLocale: () => string): string;
|
|
46
|
+
/** A timeline item that can carry a timestamp, in render order. */
|
|
47
|
+
export interface ChatTimestampSlot {
|
|
48
|
+
/** The timeline item's id. */
|
|
49
|
+
id: string;
|
|
50
|
+
/** Epoch milliseconds of the item. */
|
|
51
|
+
timestamp: number;
|
|
52
|
+
/**
|
|
53
|
+
* Shown even with timestamps turned off — the user's own message headers (the
|
|
54
|
+
* time already fits in the header row) and critical events (a failure, a
|
|
55
|
+
* blocked connection, a limit that stopped work).
|
|
56
|
+
*/
|
|
57
|
+
alwaysShown: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Decides which timeline items actually render their timestamp. An item is a
|
|
61
|
+
* candidate when timestamps are on, or when its slot is {@link ChatTimestampSlot.alwaysShown}.
|
|
62
|
+
* A candidate renders only when its label differs from the last RENDERED label,
|
|
63
|
+
* so a run of items that would all read "3 minutes ago" shows it once, at the top
|
|
64
|
+
* of the run. Re-run on every minute tick: labels move with the clock, so the
|
|
65
|
+
* grouping does too.
|
|
66
|
+
*
|
|
67
|
+
* @param slots - One entry per rendered timeline item, in order (`null` = no timestamp).
|
|
68
|
+
* @param options - The visibility preference, the current time, and the locale.
|
|
69
|
+
* @param options.visible - Whether timestamps are turned on for every item.
|
|
70
|
+
* @param options.now - Epoch milliseconds to measure from.
|
|
71
|
+
* @param options.locale - BCP 47 locale for the labels.
|
|
72
|
+
* @returns The ids of the items whose timestamp renders.
|
|
73
|
+
*/
|
|
74
|
+
export declare function planChatTimestamps(slots: readonly (ChatTimestampSlot | null)[], options: {
|
|
75
|
+
visible: boolean;
|
|
76
|
+
now: number;
|
|
77
|
+
locale: string;
|
|
78
|
+
}): Set<string>;
|
|
79
|
+
/**
|
|
80
|
+
* Persists this device's preference and notifies every mounted chat in this tab.
|
|
81
|
+
*
|
|
82
|
+
* @param visible - Whether chat timestamps should be shown.
|
|
83
|
+
*/
|
|
84
|
+
export declare function setChatTimestampsVisible(visible: boolean): void;
|
|
85
|
+
/** Parsed `/timestamps` invocation: toggle, explicit on/off, or an unrecognized argument. */
|
|
86
|
+
export type TimestampsCommand = {
|
|
87
|
+
action: 'toggle' | 'on' | 'off';
|
|
88
|
+
} | {
|
|
89
|
+
action: 'invalid';
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Parses `/timestamps [on | off]`. `show`/`hide` are accepted as synonyms.
|
|
93
|
+
*
|
|
94
|
+
* @param input - The trimmed composer text.
|
|
95
|
+
* @returns The parsed command, or `null` when the text is not `/timestamps`.
|
|
96
|
+
*/
|
|
97
|
+
export declare function parseTimestampsCommand(input: string): TimestampsCommand | null;
|
|
98
|
+
/**
|
|
99
|
+
* Short, localized, MINUTE-precise time for a chat item: "now" and "5 minutes
|
|
100
|
+
* ago" within the hour, then the clock time ("9:25 AM") for earlier today, then
|
|
101
|
+
* the date and time ("Sep 12, 9:25 AM", with the year when it differs).
|
|
102
|
+
*
|
|
103
|
+
* Minute precision at every age is load-bearing: {@link planChatTimestamps}
|
|
104
|
+
* collapses runs of identical labels, so a coarse label ("1 hour ago", "3 days
|
|
105
|
+
* ago") would collapse a whole hour or day of history into one timestamp.
|
|
106
|
+
* Localized by `Intl`, so it needs no translation keys.
|
|
107
|
+
*
|
|
108
|
+
* @param ms - Epoch milliseconds of the item.
|
|
109
|
+
* @param now - Epoch milliseconds to measure from.
|
|
110
|
+
* @param locale - BCP 47 locale (e.g. `'en'`, `'fr'`).
|
|
111
|
+
* @returns The formatted label.
|
|
112
|
+
*/
|
|
113
|
+
export declare function formatChatRelativeTime(ms: number, now: number, locale: string): string;
|
|
114
|
+
/**
|
|
115
|
+
* Exact, localized date and time for a chat item's tooltip and `<time dateTime>`
|
|
116
|
+
* companion (e.g. "Sep 13, 2026, 2:05 PM").
|
|
117
|
+
*
|
|
118
|
+
* @param ms - Epoch milliseconds of the item.
|
|
119
|
+
* @param locale - BCP 47 locale.
|
|
120
|
+
* @returns The formatted date and time.
|
|
121
|
+
*/
|
|
122
|
+
export declare function formatChatFullTime(ms: number, locale: string): string;
|
|
123
|
+
//# sourceMappingURL=chat-timestamps-utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-timestamps-utilities.d.ts","sourceRoot":"","sources":["../../src/components/chat-timestamps-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,oFAAoF;AACpF,eAAO,MAAM,2BAA2B,6BAA6B,CAAA;AAErE,0EAA0E;AAC1E,eAAO,MAAM,qBAAqB,gCAAgC,CAAA;AAElE;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,OAAO,CAOlD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,MAAM,GAAG,MAAM,CAOjE;AAED,mEAAmE;AACnE,MAAM,WAAW,iBAAiB;IAChC,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,WAAW,EAAE,OAAO,CAAA;CACrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,EAAE,EAC5C,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzD,GAAG,CAAC,MAAM,CAAC,CAeb;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAS/D;AAED,6FAA6F;AAC7F,MAAM,MAAM,iBAAiB,GAAG;IAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,KAAK,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CAAA;AAE3F;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAQ9E;AAKD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAoBtF;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAErE"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat timestamp visibility + formatting — the pure half of the `/timestamps`
|
|
3
|
+
* feature (the hook lives in `hooks/useChatTimestampsVisible.ts`, the rendered
|
|
4
|
+
* label in `ChatTimestamp.tsx`).
|
|
5
|
+
*
|
|
6
|
+
* Visibility is a PER-DEVICE, per-user display preference, stored in
|
|
7
|
+
* localStorage like `/sounds` and `/mic` — never project settings, so a viewer
|
|
8
|
+
* can toggle it and it never changes what a teammate sees. A host's own
|
|
9
|
+
* settings UI toggles the same value through {@link setChatTimestampsVisible},
|
|
10
|
+
* and every mounted chat follows via {@link CHAT_TIMESTAMPS_EVENT} (same tab)
|
|
11
|
+
* and the `storage` event (other tabs).
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/** localStorage key holding `'true'` / `'false'`. Absent = the default (hidden). */
|
|
16
|
+
export const CHAT_TIMESTAMPS_STORAGE_KEY = 'mol_chat_show_timestamps';
|
|
17
|
+
/** Window event dispatched (same tab) whenever the preference changes. */
|
|
18
|
+
export const CHAT_TIMESTAMPS_EVENT = 'mol:chat-timestamps-changed';
|
|
19
|
+
/**
|
|
20
|
+
* Parses the stored preference. Only an explicit `'true'` shows every timestamp,
|
|
21
|
+
* so a missing or unreadable value keeps the default (off — only the user's own
|
|
22
|
+
* message headers and critical events carry a time; see {@link planChatTimestamps}).
|
|
23
|
+
*
|
|
24
|
+
* @param raw - The raw localStorage value.
|
|
25
|
+
* @returns Whether timestamps are visible on every item.
|
|
26
|
+
*/
|
|
27
|
+
export function parseChatTimestampsVisible(raw) {
|
|
28
|
+
return raw === 'true';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Reads this device's preference.
|
|
32
|
+
*
|
|
33
|
+
* @returns Whether chat timestamps are visible on every item (default `false`).
|
|
34
|
+
*/
|
|
35
|
+
export function getChatTimestampsVisible() {
|
|
36
|
+
try {
|
|
37
|
+
return parseChatTimestampsVisible(localStorage.getItem(CHAT_TIMESTAMPS_STORAGE_KEY));
|
|
38
|
+
}
|
|
39
|
+
catch (_error) {
|
|
40
|
+
// localStorage unavailable (private mode, SSR) — fall back to the default.
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The active i18n locale, or the browser's when reading it throws.
|
|
46
|
+
*
|
|
47
|
+
* @deprecated A component that formats with this keeps the old language after a
|
|
48
|
+
* locale switch, because nothing re-renders it. Read the locale through the
|
|
49
|
+
* framework binding instead (`useLocale()` in React), which re-renders on a switch.
|
|
50
|
+
* `getLocale()` from `@molecule/app-i18n` does not throw: with no provider bonded
|
|
51
|
+
* it bonds a default one.
|
|
52
|
+
* @param getLocale - The i18n accessor.
|
|
53
|
+
* @returns A BCP 47 locale.
|
|
54
|
+
*/
|
|
55
|
+
export function resolveChatLocale(getLocale) {
|
|
56
|
+
try {
|
|
57
|
+
return getLocale();
|
|
58
|
+
}
|
|
59
|
+
catch (_error) {
|
|
60
|
+
// A custom accessor that throws (no locale yet) — format in the browser's own locale.
|
|
61
|
+
return typeof navigator !== 'undefined' ? navigator.language : 'en';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Decides which timeline items actually render their timestamp. An item is a
|
|
66
|
+
* candidate when timestamps are on, or when its slot is {@link ChatTimestampSlot.alwaysShown}.
|
|
67
|
+
* A candidate renders only when its label differs from the last RENDERED label,
|
|
68
|
+
* so a run of items that would all read "3 minutes ago" shows it once, at the top
|
|
69
|
+
* of the run. Re-run on every minute tick: labels move with the clock, so the
|
|
70
|
+
* grouping does too.
|
|
71
|
+
*
|
|
72
|
+
* @param slots - One entry per rendered timeline item, in order (`null` = no timestamp).
|
|
73
|
+
* @param options - The visibility preference, the current time, and the locale.
|
|
74
|
+
* @param options.visible - Whether timestamps are turned on for every item.
|
|
75
|
+
* @param options.now - Epoch milliseconds to measure from.
|
|
76
|
+
* @param options.locale - BCP 47 locale for the labels.
|
|
77
|
+
* @returns The ids of the items whose timestamp renders.
|
|
78
|
+
*/
|
|
79
|
+
export function planChatTimestamps(slots, options) {
|
|
80
|
+
const shown = new Set();
|
|
81
|
+
let lastLabel;
|
|
82
|
+
for (const slot of slots) {
|
|
83
|
+
if (!slot || !(options.visible || slot.alwaysShown))
|
|
84
|
+
continue;
|
|
85
|
+
const label = formatChatRelativeTime(slot.timestamp, Math.max(options.now, slot.timestamp), options.locale);
|
|
86
|
+
if (label === lastLabel)
|
|
87
|
+
continue;
|
|
88
|
+
shown.add(slot.id);
|
|
89
|
+
lastLabel = label;
|
|
90
|
+
}
|
|
91
|
+
return shown;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Persists this device's preference and notifies every mounted chat in this tab.
|
|
95
|
+
*
|
|
96
|
+
* @param visible - Whether chat timestamps should be shown.
|
|
97
|
+
*/
|
|
98
|
+
export function setChatTimestampsVisible(visible) {
|
|
99
|
+
try {
|
|
100
|
+
localStorage.setItem(CHAT_TIMESTAMPS_STORAGE_KEY, String(visible));
|
|
101
|
+
}
|
|
102
|
+
catch (_error) {
|
|
103
|
+
// localStorage unavailable — the event below still applies it for this session.
|
|
104
|
+
}
|
|
105
|
+
if (typeof window !== 'undefined') {
|
|
106
|
+
window.dispatchEvent(new CustomEvent(CHAT_TIMESTAMPS_EVENT, { detail: visible }));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Parses `/timestamps [on | off]`. `show`/`hide` are accepted as synonyms.
|
|
111
|
+
*
|
|
112
|
+
* @param input - The trimmed composer text.
|
|
113
|
+
* @returns The parsed command, or `null` when the text is not `/timestamps`.
|
|
114
|
+
*/
|
|
115
|
+
export function parseTimestampsCommand(input) {
|
|
116
|
+
const match = input.trim().match(/^\/timestamps(?:\s+(.*))?$/i);
|
|
117
|
+
if (!match)
|
|
118
|
+
return null;
|
|
119
|
+
const arg = match[1]?.trim().toLowerCase() ?? '';
|
|
120
|
+
if (arg === '')
|
|
121
|
+
return { action: 'toggle' };
|
|
122
|
+
if (arg === 'on' || arg === 'show')
|
|
123
|
+
return { action: 'on' };
|
|
124
|
+
if (arg === 'off' || arg === 'hide')
|
|
125
|
+
return { action: 'off' };
|
|
126
|
+
return { action: 'invalid' };
|
|
127
|
+
}
|
|
128
|
+
const MINUTE = 60_000;
|
|
129
|
+
const HOUR = 60 * MINUTE;
|
|
130
|
+
/**
|
|
131
|
+
* Short, localized, MINUTE-precise time for a chat item: "now" and "5 minutes
|
|
132
|
+
* ago" within the hour, then the clock time ("9:25 AM") for earlier today, then
|
|
133
|
+
* the date and time ("Sep 12, 9:25 AM", with the year when it differs).
|
|
134
|
+
*
|
|
135
|
+
* Minute precision at every age is load-bearing: {@link planChatTimestamps}
|
|
136
|
+
* collapses runs of identical labels, so a coarse label ("1 hour ago", "3 days
|
|
137
|
+
* ago") would collapse a whole hour or day of history into one timestamp.
|
|
138
|
+
* Localized by `Intl`, so it needs no translation keys.
|
|
139
|
+
*
|
|
140
|
+
* @param ms - Epoch milliseconds of the item.
|
|
141
|
+
* @param now - Epoch milliseconds to measure from.
|
|
142
|
+
* @param locale - BCP 47 locale (e.g. `'en'`, `'fr'`).
|
|
143
|
+
* @returns The formatted label.
|
|
144
|
+
*/
|
|
145
|
+
export function formatChatRelativeTime(ms, now, locale) {
|
|
146
|
+
const elapsed = Math.max(0, now - ms);
|
|
147
|
+
if (elapsed < HOUR) {
|
|
148
|
+
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });
|
|
149
|
+
return elapsed < MINUTE
|
|
150
|
+
? rtf.format(0, 'second')
|
|
151
|
+
: rtf.format(-Math.floor(elapsed / MINUTE), 'minute');
|
|
152
|
+
}
|
|
153
|
+
const then = new Date(ms);
|
|
154
|
+
const current = new Date(now);
|
|
155
|
+
const clock = { hour: 'numeric', minute: '2-digit' };
|
|
156
|
+
if (then.toDateString() === current.toDateString()) {
|
|
157
|
+
return new Intl.DateTimeFormat(locale, clock).format(ms);
|
|
158
|
+
}
|
|
159
|
+
return new Intl.DateTimeFormat(locale, {
|
|
160
|
+
...clock,
|
|
161
|
+
month: 'short',
|
|
162
|
+
day: 'numeric',
|
|
163
|
+
...(then.getFullYear() === current.getFullYear() ? {} : { year: 'numeric' }),
|
|
164
|
+
}).format(ms);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Exact, localized date and time for a chat item's tooltip and `<time dateTime>`
|
|
168
|
+
* companion (e.g. "Sep 13, 2026, 2:05 PM").
|
|
169
|
+
*
|
|
170
|
+
* @param ms - Epoch milliseconds of the item.
|
|
171
|
+
* @param locale - BCP 47 locale.
|
|
172
|
+
* @returns The formatted date and time.
|
|
173
|
+
*/
|
|
174
|
+
export function formatChatFullTime(ms, locale) {
|
|
175
|
+
return new Intl.DateTimeFormat(locale, { dateStyle: 'medium', timeStyle: 'short' }).format(ms);
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=chat-timestamps-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-timestamps-utilities.js","sourceRoot":"","sources":["../../src/components/chat-timestamps-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,oFAAoF;AACpF,MAAM,CAAC,MAAM,2BAA2B,GAAG,0BAA0B,CAAA;AAErE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,qBAA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AC,EAAE,CAAC,CAAA;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAU,EAAE,MAAc;IAC3D,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAChG,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-tip selection + idle-gating for the dismissable chat tip cards.
|
|
3
|
+
*
|
|
4
|
+
* Two complementary surfaces, so a typical session reliably surfaces a tip
|
|
5
|
+
* (the previous idle-only gate was so conservative new users saw ZERO):
|
|
6
|
+
*
|
|
7
|
+
* 1. **Entry tip** ({@link ENTRY_TIP}) — one high-value onboarding hint shown
|
|
8
|
+
* once on a *fresh* conversation (before the first prompt), so a brand-new
|
|
9
|
+
* user always learns how to drive the agent. The caller shows it directly;
|
|
10
|
+
* no gate.
|
|
11
|
+
* 2. **Idle rotation** ({@link CHAT_TIPS}) — additional tips that MAY surface
|
|
12
|
+
* after the conversation has sat idle for a while, gated by a random roll and
|
|
13
|
+
* a cooldown so the timeline never fills with tips.
|
|
14
|
+
*
|
|
15
|
+
* {@link shouldShowIdleTip} and {@link pickIdleTip} are pure (the random roll is
|
|
16
|
+
* injected) so the behavior is unit-testable; {@link selectTip} remains a
|
|
17
|
+
* deterministic by-index helper.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
/** A single onboarding tip. */
|
|
22
|
+
export interface TipDef {
|
|
23
|
+
/** Stable id (also used as the i18n key suffix). */
|
|
24
|
+
id: string;
|
|
25
|
+
/**
|
|
26
|
+
* English default text, rendered via `t('ide.chat.tip.<id>', { agentName }, { defaultValue })`.
|
|
27
|
+
* May contain the `{{agentName}}` interpolation token, filled in by the caller
|
|
28
|
+
* from the host's agent identity (neutral default: "the assistant").
|
|
29
|
+
*/
|
|
30
|
+
text: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The single highest-value onboarding tip, shown once on a fresh conversation
|
|
34
|
+
* (see the module overview). It points at the two interactions that unlock
|
|
35
|
+
* everything else — the `/` command menu and `@`-mentioning a file — so a brand-
|
|
36
|
+
* new user is never left staring at an empty chat with no idea how to begin.
|
|
37
|
+
* Its `id` is also a locale key (`ide.chat.tip.getStarted`), like every entry in
|
|
38
|
+
* {@link CHAT_TIPS}.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ENTRY_TIP: TipDef;
|
|
41
|
+
/**
|
|
42
|
+
* The idle-rotation tip pool. Each covers a real, shipped slash command or
|
|
43
|
+
* affordance — file mentions, the command menu, plan vs execute, `/undo`,
|
|
44
|
+
* `/compact`, `/commit`, and `/report`. Surfaced occasionally
|
|
45
|
+
* while idle (in no fixed order — {@link pickIdleTip} chooses an unseen one at
|
|
46
|
+
* random), so a longer session keeps learning new features without the timeline
|
|
47
|
+
* filling with hints. The {@link ENTRY_TIP} (`getStarted`) is shown separately at
|
|
48
|
+
* onboarding and is intentionally NOT part of this rotation.
|
|
49
|
+
*/
|
|
50
|
+
export declare const CHAT_TIPS: readonly TipDef[];
|
|
51
|
+
/**
|
|
52
|
+
* How long the conversation must sit idle before a rotation tip may surface
|
|
53
|
+
* ("idle for a while"). Kept short enough that a typical pause in a real session
|
|
54
|
+
* reaches it.
|
|
55
|
+
*/
|
|
56
|
+
export declare const TIP_IDLE_MS = 45000;
|
|
57
|
+
/**
|
|
58
|
+
* Don't surface an *idle-rotation* tip until the conversation has at least this
|
|
59
|
+
* many messages (one real back-and-forth). The {@link ENTRY_TIP} is exempt — it
|
|
60
|
+
* is the onboarding hint shown before the first prompt.
|
|
61
|
+
*/
|
|
62
|
+
export declare const TIP_MIN_MESSAGES = 2;
|
|
63
|
+
/** Minimum gap between two idle tips, so the timeline never fills with them. */
|
|
64
|
+
export declare const TIP_COOLDOWN_MS = 150000;
|
|
65
|
+
/**
|
|
66
|
+
* Chance to surface a rotation tip once idle + cooldown allow it — high enough
|
|
67
|
+
* that an active session reliably sees one, but not every idle period.
|
|
68
|
+
*/
|
|
69
|
+
export declare const TIP_IDLE_PROBABILITY = 0.7;
|
|
70
|
+
/** Inputs to the idle-tip gate. All durations in milliseconds. */
|
|
71
|
+
export interface IdleTipState {
|
|
72
|
+
/** Total messages in the conversation. */
|
|
73
|
+
messageCount: number;
|
|
74
|
+
/** Time since the last message activity (the idle duration). */
|
|
75
|
+
msSinceLastActivity: number;
|
|
76
|
+
/** Time since the last tip was shown (`Infinity` if none yet). */
|
|
77
|
+
msSinceLastTip: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Decide whether to surface an idle tip. Pure: pass `rand` (0–1, e.g. `Math.random()`)
|
|
81
|
+
* so it is testable. Returns false unless the conversation has enough history (never
|
|
82
|
+
* on the first prompt), has been idle long enough, the cooldown since the last tip has
|
|
83
|
+
* elapsed, AND the random roll passes — so tips stay occasional and never pile up.
|
|
84
|
+
*
|
|
85
|
+
* @param state - Conversation idle state.
|
|
86
|
+
* @param rand - A random value in [0, 1) (injected for testability).
|
|
87
|
+
* @returns Whether a tip should be shown now.
|
|
88
|
+
*/
|
|
89
|
+
export declare function shouldShowIdleTip(state: IdleTipState, rand: number): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Pick a tip the user hasn't seen yet (falling back to the full pool once all have
|
|
92
|
+
* been shown). Pure: pass `rand` (0–1) for a testable random choice; out-of-range or
|
|
93
|
+
* non-finite values are clamped.
|
|
94
|
+
*
|
|
95
|
+
* @param shownIds - Ids of tips already shown this conversation.
|
|
96
|
+
* @param rand - A random value in [0, 1) (injected for testability).
|
|
97
|
+
* @returns The chosen tip definition.
|
|
98
|
+
*/
|
|
99
|
+
export declare function pickIdleTip(shownIds: readonly string[], rand: number): TipDef;
|
|
100
|
+
/**
|
|
101
|
+
* Deterministic by-index tip pick, cycling through {@link CHAT_TIPS} via modulo.
|
|
102
|
+
* Non-finite or negative indices clamp to slot 0.
|
|
103
|
+
*
|
|
104
|
+
* @param index - The tip index.
|
|
105
|
+
* @returns The tip definition for that index.
|
|
106
|
+
*/
|
|
107
|
+
export declare function selectTip(index: number): TipDef;
|
|
108
|
+
//# sourceMappingURL=chat-tips-utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-tips-utilities.d.ts","sourceRoot":"","sources":["../../src/components/chat-tips-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,+BAA+B;AAC/B,MAAM,WAAW,MAAM;IACrB,oDAAoD;IACpD,EAAE,EAAE,MAAM,CAAA;IACV;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,EAAE,MAGvB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EA6B7B,CAAA;AAEV;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAS,CAAA;AACjC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,IAAI,CAAA;AACjC,gFAAgF;AAChF,eAAO,MAAM,eAAe,SAAU,CAAA;AACtC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,MAAM,CAAA;AAEvC,kEAAkE;AAClE,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAA;IACpB,gEAAgE;IAChE,mBAAmB,EAAE,MAAM,CAAA;IAC3B,kEAAkE;IAClE,cAAc,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAK5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAK7E;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI/C"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-tip selection + idle-gating for the dismissable chat tip cards.
|
|
3
|
+
*
|
|
4
|
+
* Two complementary surfaces, so a typical session reliably surfaces a tip
|
|
5
|
+
* (the previous idle-only gate was so conservative new users saw ZERO):
|
|
6
|
+
*
|
|
7
|
+
* 1. **Entry tip** ({@link ENTRY_TIP}) — one high-value onboarding hint shown
|
|
8
|
+
* once on a *fresh* conversation (before the first prompt), so a brand-new
|
|
9
|
+
* user always learns how to drive the agent. The caller shows it directly;
|
|
10
|
+
* no gate.
|
|
11
|
+
* 2. **Idle rotation** ({@link CHAT_TIPS}) — additional tips that MAY surface
|
|
12
|
+
* after the conversation has sat idle for a while, gated by a random roll and
|
|
13
|
+
* a cooldown so the timeline never fills with tips.
|
|
14
|
+
*
|
|
15
|
+
* {@link shouldShowIdleTip} and {@link pickIdleTip} are pure (the random roll is
|
|
16
|
+
* injected) so the behavior is unit-testable; {@link selectTip} remains a
|
|
17
|
+
* deterministic by-index helper.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* The single highest-value onboarding tip, shown once on a fresh conversation
|
|
23
|
+
* (see the module overview). It points at the two interactions that unlock
|
|
24
|
+
* everything else — the `/` command menu and `@`-mentioning a file — so a brand-
|
|
25
|
+
* new user is never left staring at an empty chat with no idea how to begin.
|
|
26
|
+
* Its `id` is also a locale key (`ide.chat.tip.getStarted`), like every entry in
|
|
27
|
+
* {@link CHAT_TIPS}.
|
|
28
|
+
*/
|
|
29
|
+
export const ENTRY_TIP = {
|
|
30
|
+
id: 'getStarted',
|
|
31
|
+
text: 'Tip: type / to see every command, or @ a filename to give {{agentName}} a file to work from.',
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The idle-rotation tip pool. Each covers a real, shipped slash command or
|
|
35
|
+
* affordance — file mentions, the command menu, plan vs execute, `/undo`,
|
|
36
|
+
* `/compact`, `/commit`, and `/report`. Surfaced occasionally
|
|
37
|
+
* while idle (in no fixed order — {@link pickIdleTip} chooses an unseen one at
|
|
38
|
+
* random), so a longer session keeps learning new features without the timeline
|
|
39
|
+
* filling with hints. The {@link ENTRY_TIP} (`getStarted`) is shown separately at
|
|
40
|
+
* onboarding and is intentionally NOT part of this rotation.
|
|
41
|
+
*/
|
|
42
|
+
export const CHAT_TIPS = [
|
|
43
|
+
{
|
|
44
|
+
id: 'mention',
|
|
45
|
+
text: 'Tip: type @filename to attach a project file as context — {{agentName}} reads it directly.',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'slash',
|
|
49
|
+
text: 'Tip: type / to browse every command (commit, model, and more).',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'plan',
|
|
53
|
+
text: 'Tip: use /plan to have {{agentName}} research and propose a plan before it edits any files.',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'undo',
|
|
57
|
+
text: "Tip: use /undo to instantly revert the last AI turn's file changes if it went the wrong way.",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'compact',
|
|
61
|
+
text: 'Tip: long conversation? /compact compresses the context so you keep room to work.',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'commit',
|
|
65
|
+
text: 'Tip: use /commit to save your changes as a git commit you can always return to.',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'report',
|
|
69
|
+
text: 'Tip: something off? /report sends a bug or feedback to the team with your recent chat attached.',
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
/**
|
|
73
|
+
* How long the conversation must sit idle before a rotation tip may surface
|
|
74
|
+
* ("idle for a while"). Kept short enough that a typical pause in a real session
|
|
75
|
+
* reaches it.
|
|
76
|
+
*/
|
|
77
|
+
export const TIP_IDLE_MS = 45_000;
|
|
78
|
+
/**
|
|
79
|
+
* Don't surface an *idle-rotation* tip until the conversation has at least this
|
|
80
|
+
* many messages (one real back-and-forth). The {@link ENTRY_TIP} is exempt — it
|
|
81
|
+
* is the onboarding hint shown before the first prompt.
|
|
82
|
+
*/
|
|
83
|
+
export const TIP_MIN_MESSAGES = 2;
|
|
84
|
+
/** Minimum gap between two idle tips, so the timeline never fills with them. */
|
|
85
|
+
export const TIP_COOLDOWN_MS = 150_000;
|
|
86
|
+
/**
|
|
87
|
+
* Chance to surface a rotation tip once idle + cooldown allow it — high enough
|
|
88
|
+
* that an active session reliably sees one, but not every idle period.
|
|
89
|
+
*/
|
|
90
|
+
export const TIP_IDLE_PROBABILITY = 0.7;
|
|
91
|
+
/**
|
|
92
|
+
* Decide whether to surface an idle tip. Pure: pass `rand` (0–1, e.g. `Math.random()`)
|
|
93
|
+
* so it is testable. Returns false unless the conversation has enough history (never
|
|
94
|
+
* on the first prompt), has been idle long enough, the cooldown since the last tip has
|
|
95
|
+
* elapsed, AND the random roll passes — so tips stay occasional and never pile up.
|
|
96
|
+
*
|
|
97
|
+
* @param state - Conversation idle state.
|
|
98
|
+
* @param rand - A random value in [0, 1) (injected for testability).
|
|
99
|
+
* @returns Whether a tip should be shown now.
|
|
100
|
+
*/
|
|
101
|
+
export function shouldShowIdleTip(state, rand) {
|
|
102
|
+
if (state.messageCount < TIP_MIN_MESSAGES)
|
|
103
|
+
return false;
|
|
104
|
+
if (state.msSinceLastActivity < TIP_IDLE_MS)
|
|
105
|
+
return false;
|
|
106
|
+
if (state.msSinceLastTip < TIP_COOLDOWN_MS)
|
|
107
|
+
return false;
|
|
108
|
+
return rand < TIP_IDLE_PROBABILITY;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Pick a tip the user hasn't seen yet (falling back to the full pool once all have
|
|
112
|
+
* been shown). Pure: pass `rand` (0–1) for a testable random choice; out-of-range or
|
|
113
|
+
* non-finite values are clamped.
|
|
114
|
+
*
|
|
115
|
+
* @param shownIds - Ids of tips already shown this conversation.
|
|
116
|
+
* @param rand - A random value in [0, 1) (injected for testability).
|
|
117
|
+
* @returns The chosen tip definition.
|
|
118
|
+
*/
|
|
119
|
+
export function pickIdleTip(shownIds, rand) {
|
|
120
|
+
const fresh = CHAT_TIPS.filter((tip) => !shownIds.includes(tip.id));
|
|
121
|
+
const pool = fresh.length ? fresh : CHAT_TIPS;
|
|
122
|
+
const safe = Number.isFinite(rand) ? Math.min(Math.max(rand, 0), 0.999999) : 0;
|
|
123
|
+
return pool[Math.floor(safe * pool.length)];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Deterministic by-index tip pick, cycling through {@link CHAT_TIPS} via modulo.
|
|
127
|
+
* Non-finite or negative indices clamp to slot 0.
|
|
128
|
+
*
|
|
129
|
+
* @param index - The tip index.
|
|
130
|
+
* @returns The tip definition for that index.
|
|
131
|
+
*/
|
|
132
|
+
export function selectTip(index) {
|
|
133
|
+
const len = CHAT_TIPS.length;
|
|
134
|
+
const safe = Number.isFinite(index) && index > 0 ? Math.floor(index) : 0;
|
|
135
|
+
return CHAT_TIPS[safe % len];
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=chat-tips-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-tips-utilities.js","sourceRoot":"","sources":["../../src/components/chat-tips-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAcH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAW;IAC/B,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE,8FAA8F;CACrG,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C;QACE,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,4FAA4F;KACnG;IACD;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,gEAAgE;KACvE;IACD;QACE,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AQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9E,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,CAAA;IAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACxE,OAAO,SAAS,CAAC,IAAI,GAAG,GAAG,CAAC,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device-frame data + helpers for the preview panel.
|
|
3
|
+
*
|
|
4
|
+
* The preview header exposes a {@link DeviceFrameSelector} dropdown that lists
|
|
5
|
+
* every device frame, plus a "Rotate" control that swaps a fixed-frame device
|
|
6
|
+
* between portrait and landscape. The frame order, the icon + human label for
|
|
7
|
+
* each frame, the fixed pixel DIMENSIONS used to size the preview iframe, and
|
|
8
|
+
* the orientation-aware size resolver all live here as pure data/functions so
|
|
9
|
+
* they can be unit tested and reused.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import type { IconName } from '@molecule/app-icons';
|
|
14
|
+
import type { DeviceFrame } from '@molecule/app-live-preview';
|
|
15
|
+
/**
|
|
16
|
+
* The device frames the selector dropdown lists, in display order.
|
|
17
|
+
* `none` = responsive (no fixed frame, full width).
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEVICE_FRAMES: readonly DeviceFrame[];
|
|
20
|
+
/**
|
|
21
|
+
* Per-frame display metadata: the icon-set glyph name and the i18n label
|
|
22
|
+
* (key + English default) shown in the dropdown trigger + menu items.
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEVICE_META: Record<DeviceFrame, {
|
|
25
|
+
readonly icon: IconName;
|
|
26
|
+
readonly labelKey: string;
|
|
27
|
+
readonly label: string;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Preview-only iframe orientation. Portrait is the natural orientation of a
|
|
31
|
+
* fixed-frame device; landscape swaps its width/height. This is a visual
|
|
32
|
+
* preview concern that lives in {@link PreviewPanel}'s local state — it is NOT
|
|
33
|
+
* part of the live-preview core state.
|
|
34
|
+
*/
|
|
35
|
+
export type DeviceOrientation = 'portrait' | 'landscape';
|
|
36
|
+
/**
|
|
37
|
+
* Per-frame iframe sizing. `width`/`height` are the PORTRAIT CSS sizes; a
|
|
38
|
+
* fixed-frame (`rotatable`) device swaps them in landscape. `'100%'` width with
|
|
39
|
+
* a `null` height means "fluid" — fill the available preview area (responsive /
|
|
40
|
+
* desktop have no fixed frame to rotate).
|
|
41
|
+
*/
|
|
42
|
+
export interface DeviceDimensions {
|
|
43
|
+
/** Portrait CSS width (e.g. `'768px'`, or `'100%'` for a fluid frame). */
|
|
44
|
+
readonly width: string;
|
|
45
|
+
/** Portrait CSS height in px (e.g. `'1024px'`), or `null` to fill the area. */
|
|
46
|
+
readonly height: string | null;
|
|
47
|
+
/** Whether the frame has a fixed size that can be rotated portrait ⇄ landscape. */
|
|
48
|
+
readonly rotatable: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The fixed pixel frame each device renders the preview iframe at. `none`
|
|
52
|
+
* (responsive) and `desktop` are fluid — full width, full height, nothing to
|
|
53
|
+
* rotate. `tablet` (768×1024) and `mobile` (375×667) are fixed frames that can
|
|
54
|
+
* be rotated to landscape (swapping width/height).
|
|
55
|
+
*/
|
|
56
|
+
export declare const DEVICE_DIMENSIONS: Record<DeviceFrame, DeviceDimensions>;
|
|
57
|
+
/**
|
|
58
|
+
* Whether a device frame can be rotated (true only for fixed-frame devices —
|
|
59
|
+
* tablet and mobile). Responsive and desktop are full-width with nothing to
|
|
60
|
+
* rotate, so the "Rotate" control is enabled only "where possible".
|
|
61
|
+
* @param device - The device frame.
|
|
62
|
+
* @returns `true` if the frame has a fixed size that can be rotated.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isDeviceRotatable(device: DeviceFrame): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Resolves the concrete iframe `width`/`height` for a device frame at a given
|
|
67
|
+
* orientation. Fluid frames (responsive/desktop) ignore orientation and fill
|
|
68
|
+
* the preview area (`width` from dims, `height: '100%'`). Fixed frames render
|
|
69
|
+
* at their pixel size in portrait and at the swapped size in landscape.
|
|
70
|
+
* @param device - The device frame.
|
|
71
|
+
* @param orientation - The preview orientation.
|
|
72
|
+
* @returns The CSS `width` and `height` to apply to the preview iframe.
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveDeviceSize(device: DeviceFrame, orientation: DeviceOrientation): {
|
|
75
|
+
width: string;
|
|
76
|
+
height: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Returns the icon-set glyph name for a device frame.
|
|
80
|
+
* @param device - The device frame.
|
|
81
|
+
* @returns The icon name registered in the bonded icon set.
|
|
82
|
+
*/
|
|
83
|
+
export declare function deviceIconName(device: DeviceFrame): string;
|
|
84
|
+
//# sourceMappingURL=device-cycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-cycle.d.ts","sourceRoot":"","sources":["../../src/components/device-cycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE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