@flamingo-stack/openframe-frontend-core 0.0.647 → 0.0.648-snapshot.20260917211410
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/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/{chunk-RXIFYEL7.js → chunk-4OAG7752.js} +5 -5
- package/dist/{chunk-MKGAIWQ5.cjs → chunk-742HTNAE.cjs} +3 -3
- package/dist/{chunk-MKGAIWQ5.cjs.map → chunk-742HTNAE.cjs.map} +1 -1
- package/dist/{chunk-IBTOED4M.cjs → chunk-C3CJJC2A.cjs} +7 -7
- package/dist/{chunk-IBTOED4M.cjs.map → chunk-C3CJJC2A.cjs.map} +1 -1
- package/dist/{chunk-ZNSBWM2D.js → chunk-C4VPCRSI.js} +4 -4
- package/dist/{chunk-RUEVZAPN.js → chunk-CZVFFD3P.js} +5 -5
- package/dist/{chunk-V33TSVUR.js → chunk-DVD4CMKB.js} +3 -3
- package/dist/{chunk-ABVOAYYS.cjs → chunk-EDDAU2BP.cjs} +44 -44
- package/dist/{chunk-ABVOAYYS.cjs.map → chunk-EDDAU2BP.cjs.map} +1 -1
- package/dist/{chunk-SS2RN4TU.cjs → chunk-EUGIXBAC.cjs} +13 -24
- package/dist/chunk-EUGIXBAC.cjs.map +1 -0
- package/dist/{chunk-IKMETQWQ.js → chunk-H6ND7FKB.js} +5 -5
- package/dist/{chunk-H3EJDISW.js → chunk-IEM2Z6K6.js} +10 -2
- package/dist/chunk-IEM2Z6K6.js.map +1 -0
- package/dist/{chunk-VXG43NJD.js → chunk-J2T3XDZX.js} +4 -4
- package/dist/{chunk-QPAQEPA3.js → chunk-J5VVA2KW.js} +2 -2
- package/dist/{chunk-AKM4AIZY.cjs → chunk-JYFCKQ2K.cjs} +22 -22
- package/dist/{chunk-AKM4AIZY.cjs.map → chunk-JYFCKQ2K.cjs.map} +1 -1
- package/dist/{chunk-T7NBMDDE.js → chunk-KQGTQXG2.js} +2 -2
- package/dist/{chunk-YCSYKAT2.cjs → chunk-KUCBDDQB.cjs} +248 -248
- package/dist/{chunk-YCSYKAT2.cjs.map → chunk-KUCBDDQB.cjs.map} +1 -1
- package/dist/{chunk-5XBO6URE.cjs → chunk-M2FFL6OG.cjs} +25 -25
- package/dist/{chunk-5XBO6URE.cjs.map → chunk-M2FFL6OG.cjs.map} +1 -1
- package/dist/{chunk-DLJHXLFG.js → chunk-MAFPT6GS.js} +6 -6
- package/dist/{chunk-ASPNYVGE.cjs → chunk-MB33V5S6.cjs} +51 -51
- package/dist/{chunk-ASPNYVGE.cjs.map → chunk-MB33V5S6.cjs.map} +1 -1
- package/dist/{chunk-ERLGZPCY.js → chunk-MXGGYW2R.js} +7 -7
- package/dist/{chunk-EG3PA7L2.cjs → chunk-N72F2XWZ.cjs} +10 -10
- package/dist/{chunk-EG3PA7L2.cjs.map → chunk-N72F2XWZ.cjs.map} +1 -1
- package/dist/{chunk-L6ES7O6B.js → chunk-O3B34KLC.js} +4 -4
- package/dist/{chunk-5YW3GAUR.cjs → chunk-OE6KUWRA.cjs} +424 -305
- package/dist/chunk-OE6KUWRA.cjs.map +1 -0
- package/dist/{chunk-DIGCERY4.js → chunk-OHNBWBZH.js} +7 -18
- package/dist/chunk-OHNBWBZH.js.map +1 -0
- package/dist/{chunk-VIAMEQM2.cjs → chunk-OWPMODYT.cjs} +5 -5
- package/dist/{chunk-VIAMEQM2.cjs.map → chunk-OWPMODYT.cjs.map} +1 -1
- package/dist/{chunk-DWJREJRA.cjs → chunk-PSXUY4K5.cjs} +10 -2
- package/dist/chunk-PSXUY4K5.cjs.map +1 -0
- package/dist/{chunk-TO4UY3P5.cjs → chunk-QFWZIXJ3.cjs} +75 -75
- package/dist/{chunk-TO4UY3P5.cjs.map → chunk-QFWZIXJ3.cjs.map} +1 -1
- package/dist/{chunk-GB2RYIVM.js → chunk-QG3ZNNKG.js} +2 -2
- package/dist/{chunk-5DCRDV7Y.js → chunk-QVAFZGCF.js} +7 -7
- package/dist/{chunk-N6ZYJXVJ.js → chunk-QVKRSUGB.js} +125 -6
- package/dist/chunk-QVKRSUGB.js.map +1 -0
- package/dist/{chunk-6Z4GSQPB.js → chunk-RHJ4NU3W.js} +2 -2
- package/dist/{chunk-RIOWS34T.js → chunk-UOOXFD74.js} +3 -3
- package/dist/{chunk-F4I46MKF.cjs → chunk-W554ING6.cjs} +12 -12
- package/dist/{chunk-F4I46MKF.cjs.map → chunk-W554ING6.cjs.map} +1 -1
- package/dist/{chunk-Q2XH3HW6.cjs → chunk-W7KFDHIU.cjs} +37 -37
- package/dist/{chunk-Q2XH3HW6.cjs.map → chunk-W7KFDHIU.cjs.map} +1 -1
- package/dist/{chunk-RSRYEVGZ.cjs → chunk-XIBBDYJK.cjs} +5 -5
- package/dist/{chunk-RSRYEVGZ.cjs.map → chunk-XIBBDYJK.cjs.map} +1 -1
- package/dist/{chunk-EZ6HGRLP.cjs → chunk-Y5EEPXT3.cjs} +33 -33
- package/dist/{chunk-EZ6HGRLP.cjs.map → chunk-Y5EEPXT3.cjs.map} +1 -1
- package/dist/{chunk-DBSU5RAE.cjs → chunk-YCBGEHWC.cjs} +3 -3
- package/dist/{chunk-DBSU5RAE.cjs.map → chunk-YCBGEHWC.cjs.map} +1 -1
- package/dist/components/case-studies/index.cjs +20 -20
- package/dist/components/case-studies/index.js +5 -5
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +3 -3
- package/dist/components/chat/index.js +2 -2
- package/dist/components/chat/types/message.types.d.ts +5 -0
- package/dist/components/chat/types/message.types.d.ts.map +1 -1
- package/dist/components/chat/utils/cited-sources.d.ts +5 -0
- package/dist/components/chat/utils/cited-sources.d.ts.map +1 -1
- package/dist/components/chat/utils/source-row-cta.d.ts +2 -7
- package/dist/components/chat/utils/source-row-cta.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +6 -6
- package/dist/components/contact/index.js +5 -5
- package/dist/components/docs/index.cjs +9 -9
- package/dist/components/docs/index.js +8 -8
- package/dist/components/embeds/index.cjs +6 -6
- package/dist/components/embeds/index.js +5 -5
- package/dist/components/faq/index.cjs +6 -6
- package/dist/components/faq/index.js +5 -5
- package/dist/components/features/index.cjs +5 -5
- package/dist/components/features/index.js +4 -4
- package/dist/components/help-center-pages/index.cjs +25 -25
- package/dist/components/help-center-pages/index.js +16 -16
- package/dist/components/icons/index.cjs +4 -2
- package/dist/components/icons/index.cjs.map +1 -1
- package/dist/components/icons/index.d.ts +1 -0
- package/dist/components/icons/index.d.ts.map +1 -1
- package/dist/components/icons/index.js +3 -1
- package/dist/components/icons/quickbooks-icon.d.ts +7 -0
- package/dist/components/icons/quickbooks-icon.d.ts.map +1 -0
- package/dist/components/index.cjs +44 -42
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +17 -15
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +28 -28
- package/dist/components/meeting-scheduler/index.js +4 -4
- package/dist/components/navigation/index.cjs +8 -8
- package/dist/components/navigation/index.js +7 -7
- package/dist/components/onboarding-guides/index.cjs +8 -8
- package/dist/components/onboarding-guides/index.js +7 -7
- package/dist/components/shared/doc-search/map-doc-search-results.d.ts.map +1 -1
- package/dist/components/tickets/index.cjs +9 -9
- package/dist/components/tickets/index.js +8 -8
- package/dist/components/ui/index.cjs +5 -5
- package/dist/components/ui/index.js +4 -4
- package/dist/hooks/index.cjs +3 -3
- package/dist/hooks/index.js +2 -2
- package/dist/index.cjs +23 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -8
- package/dist/index.js.map +1 -1
- package/dist/utils/index.cjs +163 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +158 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/source-grouping.d.ts +86 -0
- package/dist/utils/source-grouping.d.ts.map +1 -0
- package/dist/utils/source-icons.d.ts +7 -0
- package/dist/utils/source-icons.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/embeddable-chat.tsx +10 -2
- package/src/components/chat/types/message.types.ts +5 -0
- package/src/components/chat/utils/cited-sources.ts +7 -1
- package/src/components/chat/utils/source-row-cta.ts +4 -7
- package/src/components/icons/index.ts +1 -0
- package/src/components/icons/quickbooks-icon.tsx +13 -0
- package/src/components/shared/doc-search/__tests__/map-doc-search-results.test.ts +48 -0
- package/src/components/shared/doc-search/map-doc-search-results.ts +6 -16
- package/src/components/ui/markdown/__tests__/mermaid-zoom.test.tsx +2 -0
- package/src/utils/__tests__/source-grouping.test.ts +240 -0
- package/src/utils/index.ts +11 -0
- package/src/utils/source-grouping.ts +215 -0
- package/src/utils/source-icons.ts +13 -0
- package/dist/chunk-5YW3GAUR.cjs.map +0 -1
- package/dist/chunk-DIGCERY4.js.map +0 -1
- package/dist/chunk-DWJREJRA.cjs.map +0 -1
- package/dist/chunk-H3EJDISW.js.map +0 -1
- package/dist/chunk-N6ZYJXVJ.js.map +0 -1
- package/dist/chunk-SS2RN4TU.cjs.map +0 -1
- /package/dist/{chunk-RXIFYEL7.js.map → chunk-4OAG7752.js.map} +0 -0
- /package/dist/{chunk-ZNSBWM2D.js.map → chunk-C4VPCRSI.js.map} +0 -0
- /package/dist/{chunk-RUEVZAPN.js.map → chunk-CZVFFD3P.js.map} +0 -0
- /package/dist/{chunk-V33TSVUR.js.map → chunk-DVD4CMKB.js.map} +0 -0
- /package/dist/{chunk-IKMETQWQ.js.map → chunk-H6ND7FKB.js.map} +0 -0
- /package/dist/{chunk-VXG43NJD.js.map → chunk-J2T3XDZX.js.map} +0 -0
- /package/dist/{chunk-QPAQEPA3.js.map → chunk-J5VVA2KW.js.map} +0 -0
- /package/dist/{chunk-T7NBMDDE.js.map → chunk-KQGTQXG2.js.map} +0 -0
- /package/dist/{chunk-DLJHXLFG.js.map → chunk-MAFPT6GS.js.map} +0 -0
- /package/dist/{chunk-ERLGZPCY.js.map → chunk-MXGGYW2R.js.map} +0 -0
- /package/dist/{chunk-L6ES7O6B.js.map → chunk-O3B34KLC.js.map} +0 -0
- /package/dist/{chunk-GB2RYIVM.js.map → chunk-QG3ZNNKG.js.map} +0 -0
- /package/dist/{chunk-5DCRDV7Y.js.map → chunk-QVAFZGCF.js.map} +0 -0
- /package/dist/{chunk-6Z4GSQPB.js.map → chunk-RHJ4NU3W.js.map} +0 -0
- /package/dist/{chunk-RIOWS34T.js.map → chunk-UOOXFD74.js.map} +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grouped source chips: THE one owner, for every producer.
|
|
3
|
+
*
|
|
4
|
+
* "ClickUp Tasks (14 records)" with a per-row dropdown is built in exactly one
|
|
5
|
+
* place, `buildGroupedSource`, and WHICH rows group is decided in exactly one
|
|
6
|
+
* place, `groupsByTable`. Three producers call them:
|
|
7
|
+
*
|
|
8
|
+
* 1. the hub's web chat (`buildSourcesMeta`), server-side, over the rows it
|
|
9
|
+
* retrieved;
|
|
10
|
+
* 2. the hub's side-channel chips (my-tickets / my-tasks), server-side, over
|
|
11
|
+
* rows a strategy injected;
|
|
12
|
+
* 3. this chat's strip, client-side, over the FLAT sources a remote MCP tool
|
|
13
|
+
* returns (`groupSourcesByTable`).
|
|
14
|
+
*
|
|
15
|
+
* Why the third one is client-side: an MCP tool result is one self-describing
|
|
16
|
+
* citation per record, which is what a citation contract should be, and a turn
|
|
17
|
+
* that calls several tools yields several flat lists only the client ever sees
|
|
18
|
+
* merged. Grouping is presentation. It is the SAME presentation everywhere
|
|
19
|
+
* because it is the same two functions everywhere.
|
|
20
|
+
*
|
|
21
|
+
* Server-safe: no React, no browser APIs. The hub imports it from the `utils`
|
|
22
|
+
* barrel next to `getSourceLabel`.
|
|
23
|
+
*/
|
|
24
|
+
import type { ChatSource } from '../components/chat/types/message.types';
|
|
25
|
+
/**
|
|
26
|
+
* Doc-table documentTypes: whole documents with their own viewer (markdown =
|
|
27
|
+
* product docs, data_room_doc = data room). They carry an in-app `path`, an
|
|
28
|
+
* embedder keys `docPlatformTargets` by them, and they NEVER group: one chip
|
|
29
|
+
* per document. The hub's per-source contract test pins this list to its
|
|
30
|
+
* doc-table configs.
|
|
31
|
+
*/
|
|
32
|
+
export declare const DOC_TABLE_TYPES: readonly ["markdown", "data_room_doc"];
|
|
33
|
+
/** THE rule: rows of a knowledge table share one chip unless they are whole
|
|
34
|
+
* documents. Decided by `documentType`, the one fact every producer has. */
|
|
35
|
+
export declare function groupsByTable(documentType: string | null | undefined): boolean;
|
|
36
|
+
/** `(1 record)` / `(14 records)`: the count every grouped chip states. */
|
|
37
|
+
export declare function recordCountLabel(count: number): string;
|
|
38
|
+
type GroupedItem = NonNullable<ChatSource['items']>[number];
|
|
39
|
+
/** One row of a group. `index` is set only when the row was cited on its own
|
|
40
|
+
* (a flat MCP source); a server-grouped row shares the group's number. */
|
|
41
|
+
export type GroupedSourceRow = GroupedItem;
|
|
42
|
+
/**
|
|
43
|
+
* THE grouped-chip constructor. Order-preserving: a producer that wants its
|
|
44
|
+
* dropdown by date sorts `rows` first.
|
|
45
|
+
*
|
|
46
|
+
* `items` is ALWAYS populated, rows without a public URL included: per-row
|
|
47
|
+
* `id` + `documentType` is what gives every dropdown row its Ask action, and a
|
|
48
|
+
* chip with `items` never navigates to `path`, which for an entity table is
|
|
49
|
+
* mapper bookkeeping and not a route.
|
|
50
|
+
*/
|
|
51
|
+
export declare function buildGroupedSource(spec: {
|
|
52
|
+
/** The chip's citation number (and React key). */
|
|
53
|
+
index: number;
|
|
54
|
+
sourceRepo: string;
|
|
55
|
+
rows: GroupedSourceRow[];
|
|
56
|
+
/** Chip-level link, when it is not the first row's own. */
|
|
57
|
+
externalUrl?: string;
|
|
58
|
+
targetPlatform?: string | null;
|
|
59
|
+
}): ChatSource;
|
|
60
|
+
/**
|
|
61
|
+
* Flat sources in, the strip's chips out: ONE chip per table.
|
|
62
|
+
*
|
|
63
|
+
* Every row that names its table joins that table's chip, a lone record and a
|
|
64
|
+
* row missing its `id` or `documentType` included, exactly as the hub's web chat draws it. Each flat row
|
|
65
|
+
* keeps the citation number it was given, so `[3]` in the answer still
|
|
66
|
+
* resolves inside the group. The chip sits where its table first appeared and
|
|
67
|
+
* takes that source's `index` (unique, members are disjoint), so the strip
|
|
68
|
+
* keeps the order it was handed: reading order for cited sources.
|
|
69
|
+
*
|
|
70
|
+
* A chip the server already grouped passes through UNTOUCHED when it is its
|
|
71
|
+
* table's only source. When flat rows of the same table arrive beside it (a
|
|
72
|
+
* hub-injected chip plus MCP-cited rows in one answer), they merge into it:
|
|
73
|
+
* its rows first, its chip-level link kept, the count restated. Whole
|
|
74
|
+
* documents and rows naming no table pass through as their own chips.
|
|
75
|
+
*/
|
|
76
|
+
export declare function groupSourcesByTable(sources: ChatSource[]): ChatSource[];
|
|
77
|
+
/**
|
|
78
|
+
* The citation numbers a chip answers to, as compact text: `1-3, 7`.
|
|
79
|
+
*
|
|
80
|
+
* A chip grouped from flat sources stands for several `[N]` markers, so it
|
|
81
|
+
* shows all of them. Consecutive numbers fold into a range, which keeps a
|
|
82
|
+
* 25-row group readable.
|
|
83
|
+
*/
|
|
84
|
+
export declare function formatCitationIndices(indices: number[]): string;
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=source-grouping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-grouping.d.ts","sourceRoot":"","sources":["../../src/utils/source-grouping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAGzE;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,wCAAyC,CAAC;AAEtE;6EAC6E;AAC7E,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAE9E;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,KAAK,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D;2EAC2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAE3C;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,GAAG,UAAU,CAcb;AA0DD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAqCvE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAU/D"}
|
|
@@ -75,4 +75,11 @@ export declare const DEFAULT_DOCUMENT_TYPE_TO_TABLE_ID: Record<string, string>;
|
|
|
75
75
|
* still short-circuits gracefully on stale or custom types.
|
|
76
76
|
*/
|
|
77
77
|
export declare function defaultTableIdForDocumentType(documentType: string): string | null;
|
|
78
|
+
/**
|
|
79
|
+
* The reverse lookup: a table's canonical `documentType`. The map above is
|
|
80
|
+
* 1:1 (the hub's per-source contract test pins one type per table), so a row
|
|
81
|
+
* that names its table but arrived with no type still has one. `null` for a
|
|
82
|
+
* table the map does not list.
|
|
83
|
+
*/
|
|
84
|
+
export declare function defaultDocumentTypeForTableId(tableId: string): string | null;
|
|
78
85
|
//# sourceMappingURL=source-icons.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-icons.d.ts","sourceRoot":"","sources":["../../src/utils/source-icons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsDpD,CAAC;AAEF;;6DAE6D;AAC7D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGxF;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA4DzD,CAAC;AAEF;;kEAEkE;AAClE,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsDpE,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEjF"}
|
|
1
|
+
{"version":3,"file":"source-icons.d.ts","sourceRoot":"","sources":["../../src/utils/source-icons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsDpD,CAAC;AAEF;;6DAE6D;AAC7D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGxF;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA4DzD,CAAC;AAEF;;kEAEkE;AAClE,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsDpE,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK5E"}
|
package/package.json
CHANGED
|
@@ -41,6 +41,7 @@ import { useRequiredChatRuntime } from '../../contexts/chat-runtime-context';
|
|
|
41
41
|
import { useRouter } from '../../embed-shims/next-navigation';
|
|
42
42
|
import { useIsHydrated } from '../../hooks/ui/use-is-hydrated';
|
|
43
43
|
import { cn } from '../../utils/cn';
|
|
44
|
+
import { formatCitationIndices } from '../../utils/source-grouping';
|
|
44
45
|
import { EntityIcon } from '../icon-display';
|
|
45
46
|
import { MingoIcon } from '../icons';
|
|
46
47
|
import {
|
|
@@ -668,7 +669,9 @@ function SourceChip({
|
|
|
668
669
|
// value is what keeps the handler assertion-free.
|
|
669
670
|
const itemChatRef = itemCta.chatRef;
|
|
670
671
|
return {
|
|
671
|
-
|
|
672
|
+
// A client-built group keeps each row's own citation number, so the
|
|
673
|
+
// `[3]` in the answer is findable inside the dropdown.
|
|
674
|
+
label: item.index === undefined ? item.name : `[${item.index}] ${item.name}`,
|
|
672
675
|
icon: <ItemIcon className="h-3.5 w-3.5" />,
|
|
673
676
|
href: itemCta.href ?? undefined,
|
|
674
677
|
targetPlatform: itemCta.targetPlatform,
|
|
@@ -684,6 +687,11 @@ function SourceChip({
|
|
|
684
687
|
};
|
|
685
688
|
});
|
|
686
689
|
|
|
690
|
+
// A server-grouped chip answers to one number; a client-built one answers
|
|
691
|
+
// to every number its rows were cited by.
|
|
692
|
+
const itemIndices = src.items.flatMap(item => (item.index === undefined ? [] : [item.index]));
|
|
693
|
+
const groupIndices = itemIndices.length > 0 ? formatCitationIndices(itemIndices) : `${src.index}`;
|
|
694
|
+
|
|
687
695
|
return (
|
|
688
696
|
<HoverDropdown
|
|
689
697
|
items={dropdownItems}
|
|
@@ -701,7 +709,7 @@ function SourceChip({
|
|
|
701
709
|
<span className={`${chipClass} cursor-pointer`}>
|
|
702
710
|
{icon}
|
|
703
711
|
<span className="max-w-[160px] truncate">
|
|
704
|
-
[{
|
|
712
|
+
[{groupIndices}] {src.name}
|
|
705
713
|
</span>
|
|
706
714
|
</span>
|
|
707
715
|
</HoverDropdown>
|
|
@@ -424,6 +424,11 @@ export interface ChatSource {
|
|
|
424
424
|
id?: string;
|
|
425
425
|
/** Per-row items for grouped chips. */
|
|
426
426
|
items?: Array<{
|
|
427
|
+
/** The row's own citation number. Present when the group was built
|
|
428
|
+
* client-side from flat sources (`groupSourcesByTable`), so `[N]` in the
|
|
429
|
+
* answer still resolves to a row; absent on a server-grouped chip, whose
|
|
430
|
+
* rows share the group's one number. */
|
|
431
|
+
index?: number;
|
|
427
432
|
id: string;
|
|
428
433
|
documentType: string;
|
|
429
434
|
name: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { groupSourcesByTable } from '../../../utils/source-grouping';
|
|
1
2
|
import type { ChatSource } from '../types/message.types';
|
|
2
3
|
|
|
3
4
|
/** How many retrieved sources to show when the answer cited none of them. */
|
|
@@ -40,6 +41,11 @@ function withoutCode(content: string): string {
|
|
|
40
41
|
* even when the model numbered it `[3]`. A number cited twice is placed once,
|
|
41
42
|
* at its first mention.
|
|
42
43
|
*
|
|
44
|
+
* Each half is then grouped by knowledge table (`groupSourcesByTable`): AFTER
|
|
45
|
+
* the split, because cited-ness belongs to a citation number, and a table whose
|
|
46
|
+
* rows were only partly cited is honestly two chips, the cited rows under
|
|
47
|
+
* "Sources" and the rest behind the expander.
|
|
48
|
+
*
|
|
43
49
|
* `content` is the flat answer text. A segmented message has to be flattened by
|
|
44
50
|
* the caller — citation markers live in text segments, and this function
|
|
45
51
|
* deliberately does not know what a segment is.
|
|
@@ -57,5 +63,5 @@ export function splitCitedSources(sources: ChatSource[] | undefined, content: st
|
|
|
57
63
|
.filter(source => firstMentionAt.has(source.index))
|
|
58
64
|
.sort((a, b) => (firstMentionAt.get(a.index) ?? 0) - (firstMentionAt.get(b.index) ?? 0));
|
|
59
65
|
const uncited = sources.filter(source => !firstMentionAt.has(source.index));
|
|
60
|
-
return { cited, uncited };
|
|
66
|
+
return { cited: groupSourcesByTable(cited), uncited: groupSourcesByTable(uncited) };
|
|
61
67
|
}
|
|
@@ -26,6 +26,7 @@ import type React from 'react';
|
|
|
26
26
|
import { getPlatformUrl } from '../../../platform-domains';
|
|
27
27
|
import type { ComposeContentUrl } from '../../../utils/content-href';
|
|
28
28
|
import { canonicalContentRefType } from '../../../utils/list-url';
|
|
29
|
+
import { DOC_TABLE_TYPES } from '../../../utils/source-grouping';
|
|
29
30
|
import type { ChatRef } from '../chat-ref.types';
|
|
30
31
|
import { safeHref } from './compact-card-classes';
|
|
31
32
|
import { getIconComponent } from './icon-registry';
|
|
@@ -154,13 +155,9 @@ function pickSourceIcon(sourceRepo: string | null, documentType: string | null |
|
|
|
154
155
|
return { icon, iconLabel };
|
|
155
156
|
}
|
|
156
157
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
* `docPlatformTargets` map by (markdown = product docs, data_room_doc = data room),
|
|
161
|
-
* declared once so the two can't silently diverge.
|
|
162
|
-
*/
|
|
163
|
-
export const DOC_TABLE_TYPES = ['markdown', 'data_room_doc'] as const;
|
|
158
|
+
// Declared once in `utils/source-grouping`; re-exported so embedders that key
|
|
159
|
+
// `docPlatformTargets` by it keep their import.
|
|
160
|
+
export { DOC_TABLE_TYPES };
|
|
164
161
|
|
|
165
162
|
/**
|
|
166
163
|
* Only doc-table rows (DOC_TABLE_TYPES) fall back to doc-viewer navigation when no
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface QuickBooksIconProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
color?: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const QuickBooksIcon = ({
|
|
7
|
+
className = 'w-6 h-6',
|
|
8
|
+
color = 'var(--ods-system-greys-white)',
|
|
9
|
+
}: QuickBooksIconProps) => (
|
|
10
|
+
<svg viewBox="0 0 24 24" fill={color} xmlns="http://www.w3.org/2000/svg" className={className}>
|
|
11
|
+
<path d="M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm.642 4.1335c.9554 0 1.7296.776 1.7296 1.7332v9.0667h1.6c1.614 0 2.9275-1.3156 2.9275-2.933 0-1.6173-1.3136-2.9333-2.9276-2.9333h-.6654V7.3334h.6654c2.5722 0 4.6577 2.0897 4.6577 4.667 0 2.5774-2.0855 4.6666-4.6577 4.6666H12.642zM7.9837 7.333h3.3291v12.533c-.9555 0-1.73-.7759-1.73-1.7332V9.0662H7.9837c-1.6146 0-2.9277 1.316-2.9277 2.9334 0 1.6175 1.3131 2.9333 2.9277 2.9333h.6654v1.7332h-.6654c-2.5725 0-4.6577-2.0892-4.6577-4.6665 0-2.5771 2.0852-4.6666 4.6577-4.6666Z" />
|
|
12
|
+
</svg>
|
|
13
|
+
);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The search bar folds the financial tables into one row each, titled with the
|
|
3
|
+
* SHARED table label and count (the same owners the chat's grouped chip uses).
|
|
4
|
+
* It used to carry its own label map; this pins that every table it folds has a
|
|
5
|
+
* real label in the shared one, so a title can never decay to a raw table slug.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, expect, it } from 'vitest';
|
|
9
|
+
|
|
10
|
+
import { SOURCE_LABELS_BY_TABLE } from '../../../../utils/source-icons';
|
|
11
|
+
import { mapDocSearchResults } from '../map-doc-search-results';
|
|
12
|
+
import type { DocSearchResult } from '../types';
|
|
13
|
+
|
|
14
|
+
const FOLDED_TABLES = [
|
|
15
|
+
'financial-cap-table',
|
|
16
|
+
'financial-kpis',
|
|
17
|
+
'financial-pnl',
|
|
18
|
+
'financial-balance-sheet',
|
|
19
|
+
'financial-cash-flow',
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const row = (sourceRepo: string, n: number): DocSearchResult =>
|
|
23
|
+
({
|
|
24
|
+
path: `${sourceRepo}/${n}`,
|
|
25
|
+
name: `Row ${n}`,
|
|
26
|
+
snippet: '',
|
|
27
|
+
type: 'file',
|
|
28
|
+
matchType: 'content',
|
|
29
|
+
documentType: 'cap_table',
|
|
30
|
+
sourceRepo,
|
|
31
|
+
entityId: `${n}`,
|
|
32
|
+
}) as DocSearchResult;
|
|
33
|
+
|
|
34
|
+
describe('mapDocSearchResults', () => {
|
|
35
|
+
it.each(FOLDED_TABLES)('titles the folded %s row with its shared label and count', table => {
|
|
36
|
+
expect(SOURCE_LABELS_BY_TABLE[table]).toEqual(expect.any(String));
|
|
37
|
+
|
|
38
|
+
const [group, ...rest] = mapDocSearchResults([row(table, 1), row(table, 2)]);
|
|
39
|
+
expect(rest).toEqual([]);
|
|
40
|
+
expect(group.title).toBe(`${SOURCE_LABELS_BY_TABLE[table]} (2 records)`);
|
|
41
|
+
expect(group.title.startsWith(table)).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('leaves every other table as one row per result', () => {
|
|
45
|
+
const results = mapDocSearchResults([row('blog-posts', 1), row('blog-posts', 2)]);
|
|
46
|
+
expect(results.map(result => result.title)).toEqual(['Row 1', 'Row 2']);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -10,10 +10,14 @@
|
|
|
10
10
|
* dropped — callers that want logging can wrap this helper).
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { recordCountLabel } from '../../../utils/source-grouping';
|
|
14
|
+
import { getSourceLabel } from '../../../utils/source-icons';
|
|
13
15
|
import type { SearchResult } from '../../ui/search-input';
|
|
14
16
|
import type { DocSearchResult } from './types';
|
|
15
17
|
|
|
16
18
|
/** Source repos that should be collapsed into grouped results in the search bar.
|
|
19
|
+
* A SEARCH rule, deliberately narrower than the chat strip's `groupsByTable`:
|
|
20
|
+
* a search result is a destination, so only rows that share one are folded.
|
|
17
21
|
* Only financial tables (all rows link to the same admin page).
|
|
18
22
|
* Content tables (blog, webinar, podcast, etc.) stay individual since each has a unique URL. */
|
|
19
23
|
const SEARCH_GROUP_REPOS = new Set([
|
|
@@ -24,20 +28,6 @@ const SEARCH_GROUP_REPOS = new Set([
|
|
|
24
28
|
'financial-cash-flow',
|
|
25
29
|
]);
|
|
26
30
|
|
|
27
|
-
const ENTITY_LABELS: Record<string, string> = {
|
|
28
|
-
'financial-cap-table': 'Cap Table',
|
|
29
|
-
'financial-kpis': 'Financial KPIs',
|
|
30
|
-
'financial-pnl': 'Profit & Loss',
|
|
31
|
-
'financial-balance-sheet': 'Balance Sheets',
|
|
32
|
-
'financial-cash-flow': 'Cash Flow',
|
|
33
|
-
'blog-posts': 'Blog Posts',
|
|
34
|
-
'product-releases': 'Product Releases',
|
|
35
|
-
'case-studies': 'Case Studies',
|
|
36
|
-
webinars: 'Webinars',
|
|
37
|
-
events: 'Events',
|
|
38
|
-
podcasts: 'Podcasts',
|
|
39
|
-
};
|
|
40
|
-
|
|
41
31
|
export function mapDocSearchResults(docs: DocSearchResult[]): SearchResult[] {
|
|
42
32
|
const entityGroups = new Map<string, DocSearchResult[]>();
|
|
43
33
|
// Track insertion order — groups appear where the FIRST row of that
|
|
@@ -67,10 +57,10 @@ export function mapDocSearchResults(docs: DocSearchResult[]): SearchResult[] {
|
|
|
67
57
|
// whole search dropdown if that ever stops holding.
|
|
68
58
|
const rows = entityGroups.get(entry.repo);
|
|
69
59
|
if (!rows || rows.length === 0) continue;
|
|
70
|
-
const label = ENTITY_LABELS[entry.repo] || entry.repo;
|
|
71
60
|
results.push({
|
|
72
61
|
id: `group-${entry.repo}`,
|
|
73
|
-
|
|
62
|
+
// Same table label and count as the chat's grouped chip: one owner each.
|
|
63
|
+
title: `${getSourceLabel(entry.repo)} ${recordCountLabel(rows.length)}`,
|
|
74
64
|
path: rows[0].path,
|
|
75
65
|
type: 'file',
|
|
76
66
|
metadata: {
|
|
@@ -38,6 +38,8 @@ const mountRendered = async (props: { zoomable?: boolean } = {}) => {
|
|
|
38
38
|
await flushUntil(() => renders.length >= 1, 'a mermaid.render call');
|
|
39
39
|
await act(async () => {
|
|
40
40
|
renders[0].resolve({ svg: '<svg width="10" height="10"><g/></svg>' });
|
|
41
|
+
// Let the resolved render settle inside `act` (and give the async callback its await).
|
|
42
|
+
await Promise.resolve();
|
|
41
43
|
});
|
|
42
44
|
await flushUntil(() => !!screen.queryByTestId('mermaid-svg-container'), 'the rendered diagram');
|
|
43
45
|
};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One rule and one constructor draw every grouped source chip: the hub's web
|
|
3
|
+
* chat, its side-channel chips, and this chat's strip over flat MCP sources.
|
|
4
|
+
* These pin the rule, the chip's shape, and what grouping must leave alone.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, expect, it } from 'vitest';
|
|
8
|
+
|
|
9
|
+
import type { ChatSource } from '../../components/chat/types/message.types';
|
|
10
|
+
import { splitCitedSources } from '../../components/chat/utils/cited-sources';
|
|
11
|
+
import {
|
|
12
|
+
buildGroupedSource,
|
|
13
|
+
formatCitationIndices,
|
|
14
|
+
groupSourcesByTable,
|
|
15
|
+
groupsByTable,
|
|
16
|
+
recordCountLabel,
|
|
17
|
+
} from '../source-grouping';
|
|
18
|
+
|
|
19
|
+
const row = (table: string, documentType: string, index: number): ChatSource => ({
|
|
20
|
+
index,
|
|
21
|
+
name: `${table} ${index}`,
|
|
22
|
+
path: `${table}/${index}`,
|
|
23
|
+
documentType,
|
|
24
|
+
externalUrl: `/${table}?search=${index}`,
|
|
25
|
+
targetPlatform: 'product-hub',
|
|
26
|
+
id: `${index}`,
|
|
27
|
+
sourceRepo: table,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const task = (index: number) => row('clickup-tasks-internal', 'internal_task', index);
|
|
31
|
+
const blog = (index: number) => row('blog-posts', 'blog_post', index);
|
|
32
|
+
const webinar = (index: number) => row('webinars', 'webinar', index);
|
|
33
|
+
|
|
34
|
+
const doc = (index: number): ChatSource => ({
|
|
35
|
+
index,
|
|
36
|
+
name: `Doc ${index}`,
|
|
37
|
+
path: `guides/doc-${index}`,
|
|
38
|
+
documentType: 'markdown',
|
|
39
|
+
id: `doc-${index}`,
|
|
40
|
+
sourceRepo: 'openframe-docs',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('groupsByTable', () => {
|
|
44
|
+
it('groups every table except whole documents', () => {
|
|
45
|
+
expect(groupsByTable('internal_task')).toBe(true);
|
|
46
|
+
expect(groupsByTable(undefined)).toBe(true);
|
|
47
|
+
expect(groupsByTable('markdown')).toBe(false);
|
|
48
|
+
expect(groupsByTable('data_room_doc')).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('buildGroupedSource', () => {
|
|
53
|
+
it('names the chip by table and count, and heads it with its first row', () => {
|
|
54
|
+
const chip = buildGroupedSource({
|
|
55
|
+
index: 4,
|
|
56
|
+
sourceRepo: 'clickup-tasks-internal',
|
|
57
|
+
rows: [
|
|
58
|
+
{
|
|
59
|
+
id: 'a',
|
|
60
|
+
documentType: 'internal_task',
|
|
61
|
+
name: 'A',
|
|
62
|
+
externalUrl: '/a',
|
|
63
|
+
targetPlatform: 'product-hub',
|
|
64
|
+
path: 'p/a',
|
|
65
|
+
},
|
|
66
|
+
{ id: 'b', documentType: 'internal_task', name: 'B', path: null },
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
expect(chip).toMatchObject({
|
|
71
|
+
index: 4,
|
|
72
|
+
name: 'ClickUp Tasks (2 records)',
|
|
73
|
+
path: 'p/a',
|
|
74
|
+
documentType: 'internal_task',
|
|
75
|
+
externalUrl: '/a',
|
|
76
|
+
targetPlatform: 'product-hub',
|
|
77
|
+
sourceRepo: 'clickup-tasks-internal',
|
|
78
|
+
});
|
|
79
|
+
// A row with no public URL still gets its dropdown row (Ask needs only id + type).
|
|
80
|
+
expect(chip.items?.map(item => item.id)).toEqual(['a', 'b']);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('lets a producer set the chip-level link', () => {
|
|
84
|
+
const chip = buildGroupedSource({
|
|
85
|
+
index: 1,
|
|
86
|
+
sourceRepo: 'hubspot-tickets-self',
|
|
87
|
+
rows: [{ id: '1', documentType: 'hubspot_ticket_self', name: 'T', externalUrl: '/t/1' }],
|
|
88
|
+
externalUrl: '/my-tickets',
|
|
89
|
+
targetPlatform: 'openframe',
|
|
90
|
+
});
|
|
91
|
+
expect(chip.externalUrl).toBe('/my-tickets');
|
|
92
|
+
expect(chip.targetPlatform).toBe('openframe');
|
|
93
|
+
expect(recordCountLabel(1)).toBe('(1 record)');
|
|
94
|
+
expect(chip.name.endsWith('(1 record)')).toBe(true);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('groupSourcesByTable', () => {
|
|
99
|
+
it('collapses rows of one table into a single chip that keeps every citation number', () => {
|
|
100
|
+
const [group, ...rest] = groupSourcesByTable([task(1), task(2), task(4)]);
|
|
101
|
+
|
|
102
|
+
expect(rest).toEqual([]);
|
|
103
|
+
expect(group.name).toBe('ClickUp Tasks (3 records)');
|
|
104
|
+
expect(group.index).toBe(1);
|
|
105
|
+
expect(group.items?.map(item => item.index)).toEqual([1, 2, 4]);
|
|
106
|
+
expect(group.items?.[1]).toEqual({
|
|
107
|
+
index: 2,
|
|
108
|
+
id: '2',
|
|
109
|
+
documentType: 'internal_task',
|
|
110
|
+
name: 'clickup-tasks-internal 2',
|
|
111
|
+
externalUrl: '/clickup-tasks-internal?search=2',
|
|
112
|
+
targetPlatform: 'product-hub',
|
|
113
|
+
path: 'clickup-tasks-internal/2',
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('groups a lone record too, exactly as the hub web chat draws it', () => {
|
|
118
|
+
const [chip] = groupSourcesByTable([blog(1)]);
|
|
119
|
+
expect(chip.name).toBe('Blog Posts (1 record)');
|
|
120
|
+
expect(chip.items).toHaveLength(1);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('keeps one deterministic order when three tables interleave: each chip at its first row', () => {
|
|
124
|
+
const chips = groupSourcesByTable([task(1), blog(2), webinar(3), task(4), doc(5), blog(6), webinar(7), task(8)]);
|
|
125
|
+
|
|
126
|
+
expect(chips.map(chip => chip.sourceRepo)).toEqual([
|
|
127
|
+
'clickup-tasks-internal',
|
|
128
|
+
'blog-posts',
|
|
129
|
+
'webinars',
|
|
130
|
+
'openframe-docs',
|
|
131
|
+
]);
|
|
132
|
+
// Every row lands in exactly one chip, in the order it arrived.
|
|
133
|
+
expect(chips.map(chip => chip.items?.map(item => item.index) ?? [chip.index])).toEqual([
|
|
134
|
+
[1, 4, 8],
|
|
135
|
+
[2, 6],
|
|
136
|
+
[3, 7],
|
|
137
|
+
[5],
|
|
138
|
+
]);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('never groups doc-table rows: each document is its own chip', () => {
|
|
142
|
+
const docs = [doc(1), doc(2), doc(3)];
|
|
143
|
+
expect(groupSourcesByTable(docs)).toEqual(docs);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('passes a server-grouped chip through untouched', () => {
|
|
147
|
+
const serverGroup = buildGroupedSource({
|
|
148
|
+
index: 1,
|
|
149
|
+
sourceRepo: 'clickup-tasks-internal',
|
|
150
|
+
rows: [{ id: '9', documentType: 'internal_task', name: 'Task 9' }],
|
|
151
|
+
});
|
|
152
|
+
const [first] = groupSourcesByTable([serverGroup, doc(2)]);
|
|
153
|
+
expect(first).toBe(serverGroup);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('merges flat rows into a server-grouped chip of the same table: one chip, never two', () => {
|
|
157
|
+
const serverChip = buildGroupedSource({
|
|
158
|
+
index: 1,
|
|
159
|
+
sourceRepo: 'clickup-tasks-internal',
|
|
160
|
+
rows: [{ id: '9', documentType: 'internal_task', name: 'Task 9' }],
|
|
161
|
+
externalUrl: '/admin/tasks',
|
|
162
|
+
targetPlatform: 'product-hub',
|
|
163
|
+
});
|
|
164
|
+
// task(9) is the record already inside the chip; task(2) is new.
|
|
165
|
+
const chips = groupSourcesByTable([serverChip, blog(5), task(2), task(9)]);
|
|
166
|
+
|
|
167
|
+
expect(chips.map(chip => chip.sourceRepo)).toEqual(['clickup-tasks-internal', 'blog-posts']);
|
|
168
|
+
expect(chips[0].name).toBe('ClickUp Tasks (2 records)');
|
|
169
|
+
expect(chips[0].index).toBe(1);
|
|
170
|
+
expect(chips[0].externalUrl).toBe('/admin/tasks');
|
|
171
|
+
expect(chips[0].items?.map(item => item.id)).toEqual(['9', '2']);
|
|
172
|
+
// The server's row keeps the group's number; the flat row keeps its own.
|
|
173
|
+
expect(chips[0].items?.map(item => item.index)).toEqual([undefined, 2]);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('keeps a table in ONE chip when a row has no id: it joins as an Open-only row', () => {
|
|
177
|
+
const { id: _id, ...noId } = task(2);
|
|
178
|
+
const chips = groupSourcesByTable([task(1), noId, task(3)]);
|
|
179
|
+
|
|
180
|
+
expect(chips).toHaveLength(1);
|
|
181
|
+
expect(chips[0].name).toBe('ClickUp Tasks (3 records)');
|
|
182
|
+
expect(chips[0].items?.map(item => item.id)).toEqual(['1', '', '3']);
|
|
183
|
+
expect(chips[0].items?.[1].externalUrl).toBe('/clickup-tasks-internal?search=2');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('keeps a table in ONE chip when a row has no documentType: the table supplies the type', () => {
|
|
187
|
+
const typeless = { ...task(2), documentType: '' };
|
|
188
|
+
const chips = groupSourcesByTable([task(1), typeless]);
|
|
189
|
+
|
|
190
|
+
expect(chips).toHaveLength(1);
|
|
191
|
+
expect(chips[0].name).toBe('ClickUp Tasks (2 records)');
|
|
192
|
+
// The row gets its table's canonical type, so Ask still works on it.
|
|
193
|
+
expect(chips[0].items?.map(item => item.documentType)).toEqual(['internal_task', 'internal_task']);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('still treats a typeless row of a doc table as a whole document', () => {
|
|
197
|
+
const typelessDoc = { ...doc(1), documentType: '' };
|
|
198
|
+
expect(groupSourcesByTable([typelessDoc, doc(2)])).toEqual([typelessDoc, doc(2)]);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('leaves a row that names no table as its own chip', () => {
|
|
202
|
+
const { sourceRepo: _repo, ...noTable } = task(2);
|
|
203
|
+
expect(groupSourcesByTable([noTable])).toEqual([noTable]);
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
describe('splitCitedSources with grouping', () => {
|
|
208
|
+
it('groups the cited and the uncited rows of one table separately', () => {
|
|
209
|
+
const { cited, uncited } = splitCitedSources([task(1), task(2), task(3), task(4)], 'See [3] and [1].');
|
|
210
|
+
|
|
211
|
+
expect(cited).toHaveLength(1);
|
|
212
|
+
expect(cited[0].items?.map(item => item.index)).toEqual([3, 1]);
|
|
213
|
+
expect(uncited).toHaveLength(1);
|
|
214
|
+
expect(uncited[0].items?.map(item => item.index)).toEqual([2, 4]);
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
describe('grouping is per message', () => {
|
|
219
|
+
it('groups each answer from its own sources only: the same table in two answers is two chips', () => {
|
|
220
|
+
// The strip calls this once per message with THAT message's sources. There
|
|
221
|
+
// is no shared state to carry a table's rows from one answer into the next.
|
|
222
|
+
const first = splitCitedSources([task(1), task(2)], 'See [1] and [2].');
|
|
223
|
+
const second = splitCitedSources([task(1), blog(2)], 'See [1].');
|
|
224
|
+
|
|
225
|
+
expect(first.cited.map(chip => chip.name)).toEqual(['ClickUp Tasks (2 records)']);
|
|
226
|
+
expect(second.cited.map(chip => chip.name)).toEqual(['ClickUp Tasks (1 record)']);
|
|
227
|
+
expect(second.uncited.map(chip => chip.name)).toEqual(['Blog Posts (1 record)']);
|
|
228
|
+
// The inputs are never mutated, so a re-render regroups from the same flat list.
|
|
229
|
+
const flat = [task(1), task(2)];
|
|
230
|
+
groupSourcesByTable(flat);
|
|
231
|
+
expect(flat.every(source => source.items === undefined)).toBe(true);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
describe('formatCitationIndices', () => {
|
|
236
|
+
it('folds consecutive numbers into ranges', () => {
|
|
237
|
+
expect(formatCitationIndices([3, 1, 2, 7, 9, 10])).toBe('1-3, 7, 9-10');
|
|
238
|
+
expect(formatCitationIndices([5])).toBe('5');
|
|
239
|
+
});
|
|
240
|
+
});
|
package/src/utils/index.ts
CHANGED
|
@@ -196,6 +196,17 @@ export {
|
|
|
196
196
|
// instead of src/components/chat/utils/ so server-side hub callers like
|
|
197
197
|
// doc-chat-utils can use them without tripping the 'use client' boundary)
|
|
198
198
|
export { SOURCE_ICON_NAMES, getSourceIconName, SOURCE_LABELS_BY_TABLE, getSourceLabel } from './source-icons';
|
|
199
|
+
// Grouped source chips: the one rule + the one constructor, for the hub
|
|
200
|
+
// (server) and the chat strip (client) alike.
|
|
201
|
+
export {
|
|
202
|
+
DOC_TABLE_TYPES,
|
|
203
|
+
groupsByTable,
|
|
204
|
+
recordCountLabel,
|
|
205
|
+
buildGroupedSource,
|
|
206
|
+
groupSourcesByTable,
|
|
207
|
+
formatCitationIndices,
|
|
208
|
+
type GroupedSourceRow,
|
|
209
|
+
} from './source-grouping';
|
|
199
210
|
|
|
200
211
|
// Embed-surface auth — generic across chat AND ticket center (and any
|
|
201
212
|
// future embedded React component that needs to identify as the proxied
|