@lostgradient/cinder 0.15.0 → 0.16.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/CHANGELOG.md +6 -0
- package/README.md +3 -3
- package/components.json +2 -143
- package/dist/components/access-gate/index.js +379 -327
- package/dist/components/alert-dialog/index.js +170 -172
- package/dist/components/confirm-dialog/index.js +170 -172
- package/dist/components/drawer/index.js +11 -11
- package/dist/components/focus-trap/index.d.ts +1 -0
- package/dist/components/focus-trap/index.js +171 -1
- package/dist/components/icons/index.d.ts +80 -1
- package/dist/components/icons/index.js +1256 -0
- package/dist/components/markdown-editor/index.js +170 -170
- package/dist/components/modal/index.js +20 -20
- package/dist/components/review-editor/index.js +170 -187
- package/dist/components/sheet/index.js +11 -11
- package/dist/components/sidebar/index.js +37 -37
- package/dist/index.d.ts +0 -8
- package/dist/index.js +23202 -30173
- package/dist/server/components/access-gate/index.js +7 -10
- package/dist/server/components/alert-dialog/index.js +4 -4
- package/dist/server/components/approval-card/index.js +6 -6
- package/dist/server/components/autocomplete/index.js +4 -4
- package/dist/server/components/choice-grid/index.js +2 -2
- package/dist/server/components/color-field/index.js +2 -2
- package/dist/server/components/combobox/index.js +3 -3
- package/dist/server/components/command-item/index.js +3 -5
- package/dist/server/components/command-menu/index.js +3 -5
- package/dist/server/components/confirm-dialog/index.js +4 -4
- package/dist/server/components/context-menu/index.js +7 -7
- package/dist/server/components/data-table/index.js +3 -3
- package/dist/server/components/date-picker/index.js +4 -4
- package/dist/server/components/date-range-field/index.js +4 -4
- package/dist/server/components/diff-viewer/index.js +9 -11
- package/dist/server/components/drawer/index.js +4 -4
- package/dist/server/components/dropdown/index.js +7 -7
- package/dist/server/components/faceted-filter-bar/index.js +2 -2
- package/dist/server/components/focus-trap/index.js +7 -2
- package/dist/server/components/icons/index.js +156 -0
- package/dist/server/components/inline-loading/index.js +1 -1
- package/dist/server/components/json-schema-editor/index.js +11 -13
- package/dist/server/components/load-more/index.js +2 -3
- package/dist/server/components/markdown-editor/index.js +13 -12
- package/dist/server/components/menu-bar/index.js +4 -4
- package/dist/server/components/modal/index.js +4 -4
- package/dist/server/components/popover/index.js +3 -3
- package/dist/server/components/review-editor/index.js +169 -122
- package/dist/server/components/schedule-builder/index.js +5 -5
- package/dist/server/components/schema-form/index.js +1 -1
- package/dist/server/components/segment/index.js +3 -3
- package/dist/server/components/segmented-control/index.js +4 -4
- package/dist/server/components/selection-popover/index.js +3 -3
- package/dist/server/components/sheet/index.js +3 -3
- package/dist/server/components/sidebar/index.js +4 -4
- package/dist/server/components/table/index.js +3 -3
- package/dist/server/components/tag-input/index.js +2 -2
- package/dist/server/index.js +272 -316
- package/dist/server/{index.server-dwwqssey.js → index.server-0qh3v3nq.js} +1 -1
- package/dist/server/index.server-25wmev4e.js +2 -0
- package/dist/server/{index.server-zdm63dt8.js → index.server-2c56kqws.js} +107 -25
- package/dist/server/{index.server-y4n8vc08.js → index.server-2pc5cv6c.js} +1 -1
- package/dist/server/{index.server-1vsv7ngz.js → index.server-3g76h7z7.js} +12 -2
- package/dist/server/{index.server-xz99aed4.js → index.server-45n4s30n.js} +12 -12
- package/dist/server/{index.server-zzd5wpbw.js → index.server-4dfs3xwn.js} +1 -1
- package/dist/server/{index.server-vhyjjx9z.js → index.server-4jkqgp17.js} +7 -9
- package/dist/server/{index.server-bmxbsk4y.js → index.server-51sxnete.js} +18 -18
- package/dist/server/{index.server-1bwvsnjk.js → index.server-6rv1rfwq.js} +37 -14
- package/dist/server/{index.server-np3c7kx0.js → index.server-7798gc22.js} +1 -1
- package/dist/server/{index.server-2m1kenak.js → index.server-7kjw6qw5.js} +1 -1
- package/dist/server/{index.server-tfftb7hs.js → index.server-7zpzspk6.js} +1 -1
- package/dist/server/{index.server-7yvpb6z7.js → index.server-894t97kv.js} +4 -4
- package/dist/server/{index.server-47v2fhp4.js → index.server-8b35ekqg.js} +1 -1
- package/dist/server/{index.server-j5hn2qds.js → index.server-8nm871y8.js} +80 -30
- package/dist/server/{index.server-h0cvwvhy.js → index.server-9drzqktm.js} +1 -1
- package/dist/server/{index.server-x9s4m9eg.js → index.server-agsdwg53.js} +1 -1
- package/dist/server/{index.server-hpeavvnq.js → index.server-b4gp066a.js} +1 -1
- package/dist/server/{index.server-gkazv439.js → index.server-bf7d81b4.js} +7 -7
- package/dist/server/{index.server-krqvnt6p.js → index.server-d4ft97bx.js} +4 -2
- package/dist/server/{index.server-t1x9h8cb.js → index.server-dg19y3m7.js} +1 -1
- package/dist/server/{index.server-jt1twhgk.js → index.server-dq0k0qf6.js} +10 -10
- package/dist/server/{index.server-pxq277t5.js → index.server-frb9e55d.js} +1 -1
- package/dist/server/{index.server-9kz37z89.js → index.server-g3726bja.js} +1 -1
- package/dist/server/index.server-gyzmkrnz.js +2 -0
- package/dist/server/{index.server-mr68brd6.js → index.server-jgdtsvz2.js} +1 -1
- package/dist/server/{index.server-p56xxef1.js → index.server-m8ya4p7w.js} +1 -1
- package/dist/server/{index.server-1nq7z1qw.js → index.server-mda2y5g6.js} +1 -1
- package/dist/server/{index.server-jdcq5zza.js → index.server-mehav5vs.js} +7 -7
- package/dist/server/{index.server-e89qfamd.js → index.server-mknhgg07.js} +4 -4
- package/dist/server/{index.server-j570vb03.js → index.server-mvjzcna5.js} +1 -1
- package/dist/server/index.server-n4jxy52q.js +2 -0
- package/dist/server/{index.server-h89zk5ev.js → index.server-ne4gzxvz.js} +7 -7
- package/dist/server/{index.server-eftvmq3f.js → index.server-pfbzz3x7.js} +1 -1
- package/dist/server/{index.server-zrh23kty.js → index.server-pyjzfjfn.js} +1 -1
- package/dist/server/{index.server-rga8sc7j.js → index.server-q1d48s9t.js} +40 -36
- package/dist/server/{index.server-46cjwcqw.js → index.server-qv0kkre4.js} +5 -5
- package/dist/server/{index.server-yhzydqxe.js → index.server-r82zjq88.js} +5 -5
- package/dist/server/{index.server-9ykk1kbg.js → index.server-rbd5ys4z.js} +1 -1
- package/dist/server/{index.server-tcay903b.js → index.server-tnecnach.js} +4 -4
- package/dist/server/{index.server-9ra3xv88.js → index.server-x66zvjfc.js} +9 -9
- package/dist/server/{index.server-6sh11ap6.js → index.server-y4kfz0er.js} +1 -1
- package/dist/server/{index.server-n82rcv0m.js → index.server-z721a5gp.js} +4 -4
- package/dist/server/{index.server-mm1xa3kr.js → index.server-zdhv33ph.js} +51 -20
- package/dist/server/{index.server-t3hknp1c.js → index.server-zm04d9eq.js} +4 -4
- package/dist/server/{index.server-nx9c2ep1.js → index.server-zncgb7mw.js} +2 -2
- package/package.json +10 -130
- package/src/components/focus-trap/index.ts +1 -0
- package/src/components/icons/index.ts +82 -40
- package/src/index.ts +0 -34
- package/src/styles/components.css +0 -4
- package/dist/components/chat/adapter/chat-adapter.d.ts +0 -123
- package/dist/components/chat/adapter/index.d.ts +0 -8
- package/dist/components/chat/artifact/artifact-panel.svelte.d.ts +0 -15
- package/dist/components/chat/artifact/artifact-viewer.svelte.d.ts +0 -10
- package/dist/components/chat/artifact/chat-artifact-layout.svelte.d.ts +0 -23
- package/dist/components/chat/artifact/index.d.ts +0 -3
- package/dist/components/chat/builders.d.ts +0 -25
- package/dist/components/chat/chat.css +0 -16
- package/dist/components/chat/chat.css.d.ts +0 -1
- package/dist/components/chat/chat.schema.d.ts +0 -3
- package/dist/components/chat/chat.schema.js +0 -366
- package/dist/components/chat/chat.svelte.d.ts +0 -31
- package/dist/components/chat/chat.types.d.ts +0 -268
- package/dist/components/chat/chat.variables.d.ts +0 -2
- package/dist/components/chat/chat.variables.js +0 -61
- package/dist/components/chat/container/chat-events.d.ts +0 -22
- package/dist/components/chat/container/chat-history-trigger.svelte.d.ts +0 -15
- package/dist/components/chat/container/chat-jump-controls.svelte.d.ts +0 -24
- package/dist/components/chat/container/chat-participant-typing.svelte.d.ts +0 -31
- package/dist/components/chat/container/chat-search-bar.svelte.d.ts +0 -38
- package/dist/components/chat/container/chat-status-announcer.svelte.d.ts +0 -21
- package/dist/components/chat/container/chat.svelte.d.ts +0 -17
- package/dist/components/chat/container/index.d.ts +0 -12
- package/dist/components/chat/container/scroll-utilities.d.ts +0 -119
- package/dist/components/chat/container/use-chat-disclosure-state.svelte.d.ts +0 -58
- package/dist/components/chat/container/use-chat-keyboard-nav.svelte.d.ts +0 -57
- package/dist/components/chat/container/use-chat-message-groups.svelte.d.ts +0 -74
- package/dist/components/chat/container/use-chat-read-receipts.svelte.d.ts +0 -51
- package/dist/components/chat/container/use-chat-scroll-state.svelte.d.ts +0 -111
- package/dist/components/chat/container/use-chat-search.svelte.d.ts +0 -82
- package/dist/components/chat/container/use-chat-typing-indicator.svelte.d.ts +0 -76
- package/dist/components/chat/container/use-chat-unread-state.svelte.d.ts +0 -80
- package/dist/components/chat/container/use-chat-virtualizer.svelte.d.ts +0 -47
- package/dist/components/chat/conversation-model.d.ts +0 -16
- package/dist/components/chat/export/conversation-export-actions.svelte.d.ts +0 -17
- package/dist/components/chat/export/index.d.ts +0 -8
- package/dist/components/chat/index.d.ts +0 -25
- package/dist/components/chat/index.js +0 -11319
- package/dist/components/chat/input/attachment-kind.d.ts +0 -10
- package/dist/components/chat/input/chat-attachment-preview.svelte.d.ts +0 -8
- package/dist/components/chat/input/chat-attachment-serialization.d.ts +0 -9
- package/dist/components/chat/input/chat-attachment.d.ts +0 -11
- package/dist/components/chat/input/chat-input.svelte.d.ts +0 -79
- package/dist/components/chat/input/index.d.ts +0 -5
- package/dist/components/chat/message/chat-date-separator.svelte.d.ts +0 -12
- package/dist/components/chat/message/chat-message-parts-renderer.svelte.d.ts +0 -4
- package/dist/components/chat/message/chat-message-parts.d.ts +0 -96
- package/dist/components/chat/message/chat-message.svelte.d.ts +0 -91
- package/dist/components/chat/message/chat-read-receipt.svelte.d.ts +0 -27
- package/dist/components/chat/message/image-lightbox.svelte.d.ts +0 -17
- package/dist/components/chat/message/index.d.ts +0 -6
- package/dist/components/chat/message/markdown-preview.svelte.d.ts +0 -8
- package/dist/components/chat/message/message-attachments.svelte.d.ts +0 -17
- package/dist/components/chat/message/message-content.svelte.d.ts +0 -18
- package/dist/components/chat/message/parts/image-part.svelte.d.ts +0 -17
- package/dist/components/chat/message/parts/markdown-part.svelte.d.ts +0 -8
- package/dist/components/chat/message/parts/reasoning-part.svelte.d.ts +0 -12
- package/dist/components/chat/message/parts/step-part.svelte.d.ts +0 -8
- package/dist/components/chat/message/parts/suggestion-part.svelte.d.ts +0 -18
- package/dist/components/chat/message/parts/tool-approval-part.svelte.d.ts +0 -12
- package/dist/components/chat/message/parts/tool-call-part.svelte.d.ts +0 -12
- package/dist/components/chat/message/parts/tool-result-part.svelte.d.ts +0 -8
- package/dist/components/chat/message/tool-call-group.svelte.d.ts +0 -15
- package/dist/components/chat/message/tool-payload-code.svelte.d.ts +0 -9
- package/dist/components/chat/utilities/conversation.d.ts +0 -12
- package/dist/components/chat/utilities/index.d.ts +0 -9
- package/dist/components/chat/utilities/types.d.ts +0 -262
- package/dist/components/chat/utilities/utilities.d.ts +0 -140
- package/dist/components/chat-composer-popover/chat-composer-popover-filter.d.ts +0 -11
- package/dist/components/chat-composer-popover/chat-composer-popover.css +0 -7
- package/dist/components/chat-composer-popover/chat-composer-popover.css.d.ts +0 -1
- package/dist/components/chat-composer-popover/chat-composer-popover.schema.d.ts +0 -3
- package/dist/components/chat-composer-popover/chat-composer-popover.schema.js +0 -150
- package/dist/components/chat-composer-popover/chat-composer-popover.svelte.d.ts +0 -46
- package/dist/components/chat-composer-popover/chat-composer-popover.types.d.ts +0 -77
- package/dist/components/chat-composer-popover/chat-composer-popover.variables.d.ts +0 -2
- package/dist/components/chat-composer-popover/chat-composer-popover.variables.js +0 -61
- package/dist/components/chat-composer-popover/index.d.ts +0 -6
- package/dist/components/chat-composer-popover/index.js +0 -3285
- package/dist/components/chat-conversation-header/chat-conversation-header.css +0 -51
- package/dist/components/chat-conversation-header/chat-conversation-header.css.d.ts +0 -1
- package/dist/components/chat-conversation-header/chat-conversation-header.schema.d.ts +0 -3
- package/dist/components/chat-conversation-header/chat-conversation-header.schema.js +0 -94
- package/dist/components/chat-conversation-header/chat-conversation-header.svelte.d.ts +0 -19
- package/dist/components/chat-conversation-header/chat-conversation-header.types.d.ts +0 -18
- package/dist/components/chat-conversation-header/chat-conversation-header.variables.d.ts +0 -2
- package/dist/components/chat-conversation-header/chat-conversation-header.variables.js +0 -61
- package/dist/components/chat-conversation-header/index.d.ts +0 -5
- package/dist/components/chat-conversation-header/index.js +0 -4278
- package/dist/components/chat-conversation-list/chat-conversation-list.css +0 -127
- package/dist/components/chat-conversation-list/chat-conversation-list.css.d.ts +0 -1
- package/dist/components/chat-conversation-list/chat-conversation-list.schema.d.ts +0 -3
- package/dist/components/chat-conversation-list/chat-conversation-list.schema.js +0 -105
- package/dist/components/chat-conversation-list/chat-conversation-list.svelte.d.ts +0 -21
- package/dist/components/chat-conversation-list/chat-conversation-list.types.d.ts +0 -17
- package/dist/components/chat-conversation-list/chat-conversation-list.variables.d.ts +0 -2
- package/dist/components/chat-conversation-list/chat-conversation-list.variables.js +0 -61
- package/dist/components/chat-conversation-list/conversation-summary.d.ts +0 -30
- package/dist/components/chat-conversation-list/index.d.ts +0 -6
- package/dist/components/chat-conversation-list/index.js +0 -536
- package/dist/server/components/chat/index.js +0 -131
- package/dist/server/components/chat-composer-popover/index.js +0 -26
- package/dist/server/components/chat-conversation-header/index.js +0 -41
- package/dist/server/components/chat-conversation-list/index.js +0 -19
- package/dist/server/index.server-2bbwajb2.js +0 -54
- package/dist/server/index.server-2hqrv7ca.js +0 -9
- package/dist/server/index.server-67qgdypc.js +0 -9
- package/dist/server/index.server-6hnfzc7f.js +0 -263
- package/dist/server/index.server-8rmtb8vx.js +0 -175
- package/dist/server/index.server-a59y47rw.js +0 -59
- package/dist/server/index.server-bfkka7x4.js +0 -2
- package/dist/server/index.server-czf35aba.js +0 -4241
- package/dist/server/index.server-kb6w1a7c.js +0 -27
- package/dist/server/index.server-nphtb2ey.js +0 -76
- package/dist/server/index.server-qkfd0qa7.js +0 -2
- package/dist/server/index.server-rf67m8v5.js +0 -2
- package/dist/server/index.server-rqe5bqgm.js +0 -37
- package/dist/server/index.server-xtjjmsyq.js +0 -315
- package/dist/server/index.server-yq9evnp4.js +0 -38
- package/dist/server/index.server-z1qvwaem.js +0 -74
- package/dist/server/index.server-z7hxtqs1.js +0 -83
- package/src/components/chat/adapter/chat-adapter.ts +0 -132
- package/src/components/chat/adapter/index.ts +0 -15
- package/src/components/chat/artifact/artifact-panel.svelte +0 -112
- package/src/components/chat/artifact/artifact-viewer.svelte +0 -101
- package/src/components/chat/artifact/chat-artifact-layout.svelte +0 -56
- package/src/components/chat/artifact/index.ts +0 -3
- package/src/components/chat/builders.ts +0 -464
- package/src/components/chat/chat.css +0 -16
- package/src/components/chat/chat.examples.json +0 -67
- package/src/components/chat/chat.schema.json +0 -290
- package/src/components/chat/chat.schema.ts +0 -335
- package/src/components/chat/chat.svelte +0 -67
- package/src/components/chat/chat.types.ts +0 -284
- package/src/components/chat/chat.variables.json +0 -1
- package/src/components/chat/chat.variables.ts +0 -3
- package/src/components/chat/container/chat-events.ts +0 -26
- package/src/components/chat/container/chat-history-trigger.svelte +0 -95
- package/src/components/chat/container/chat-jump-controls.svelte +0 -191
- package/src/components/chat/container/chat-participant-typing.svelte +0 -128
- package/src/components/chat/container/chat-search-bar.svelte +0 -219
- package/src/components/chat/container/chat-status-announcer.svelte +0 -22
- package/src/components/chat/container/chat.svelte +0 -1879
- package/src/components/chat/container/index.ts +0 -64
- package/src/components/chat/container/scroll-utilities.ts +0 -204
- package/src/components/chat/container/use-chat-disclosure-state.svelte.ts +0 -62
- package/src/components/chat/container/use-chat-keyboard-nav.svelte.ts +0 -153
- package/src/components/chat/container/use-chat-message-groups.svelte.ts +0 -146
- package/src/components/chat/container/use-chat-read-receipts.svelte.ts +0 -62
- package/src/components/chat/container/use-chat-scroll-state.svelte.ts +0 -292
- package/src/components/chat/container/use-chat-search.svelte.ts +0 -116
- package/src/components/chat/container/use-chat-typing-indicator.svelte.ts +0 -153
- package/src/components/chat/container/use-chat-unread-state.svelte.ts +0 -170
- package/src/components/chat/container/use-chat-virtualizer.svelte.ts +0 -260
- package/src/components/chat/conversation-model.ts +0 -56
- package/src/components/chat/export/conversation-export-actions.svelte +0 -174
- package/src/components/chat/export/index.ts +0 -9
- package/src/components/chat/index.ts +0 -160
- package/src/components/chat/input/attachment-kind.ts +0 -28
- package/src/components/chat/input/chat-attachment-preview.svelte +0 -223
- package/src/components/chat/input/chat-attachment-serialization.ts +0 -63
- package/src/components/chat/input/chat-attachment.ts +0 -12
- package/src/components/chat/input/chat-input.svelte +0 -810
- package/src/components/chat/input/index.ts +0 -9
- package/src/components/chat/message/chat-date-separator.svelte +0 -87
- package/src/components/chat/message/chat-message-parts-renderer.svelte +0 -139
- package/src/components/chat/message/chat-message-parts.ts +0 -163
- package/src/components/chat/message/chat-message.svelte +0 -861
- package/src/components/chat/message/chat-read-receipt.svelte +0 -85
- package/src/components/chat/message/image-lightbox.svelte +0 -255
- package/src/components/chat/message/index.ts +0 -6
- package/src/components/chat/message/markdown-preview.svelte +0 -77
- package/src/components/chat/message/message-attachments.svelte +0 -178
- package/src/components/chat/message/message-content.svelte +0 -132
- package/src/components/chat/message/parts/image-part.svelte +0 -11
- package/src/components/chat/message/parts/markdown-part.svelte +0 -17
- package/src/components/chat/message/parts/reasoning-part.svelte +0 -274
- package/src/components/chat/message/parts/step-part.svelte +0 -127
- package/src/components/chat/message/parts/suggestion-part.svelte +0 -83
- package/src/components/chat/message/parts/tool-approval-part.svelte +0 -298
- package/src/components/chat/message/parts/tool-call-part.svelte +0 -19
- package/src/components/chat/message/parts/tool-result-part.svelte +0 -65
- package/src/components/chat/message/tool-call-group.svelte +0 -274
- package/src/components/chat/message/tool-payload-code.svelte +0 -35
- package/src/components/chat/utilities/conversation.ts +0 -44
- package/src/components/chat/utilities/index.ts +0 -33
- package/src/components/chat/utilities/types.ts +0 -288
- package/src/components/chat/utilities/utilities.ts +0 -507
- package/src/components/chat-composer-popover/chat-composer-popover-filter.ts +0 -68
- package/src/components/chat-composer-popover/chat-composer-popover.css +0 -7
- package/src/components/chat-composer-popover/chat-composer-popover.examples.json +0 -13
- package/src/components/chat-composer-popover/chat-composer-popover.schema.json +0 -90
- package/src/components/chat-composer-popover/chat-composer-popover.schema.ts +0 -95
- package/src/components/chat-composer-popover/chat-composer-popover.svelte +0 -234
- package/src/components/chat-composer-popover/chat-composer-popover.types.ts +0 -88
- package/src/components/chat-composer-popover/chat-composer-popover.variables.json +0 -1
- package/src/components/chat-composer-popover/chat-composer-popover.variables.ts +0 -3
- package/src/components/chat-composer-popover/index.ts +0 -19
- package/src/components/chat-conversation-header/chat-conversation-header.css +0 -51
- package/src/components/chat-conversation-header/chat-conversation-header.examples.json +0 -13
- package/src/components/chat-conversation-header/chat-conversation-header.schema.json +0 -34
- package/src/components/chat-conversation-header/chat-conversation-header.schema.ts +0 -38
- package/src/components/chat-conversation-header/chat-conversation-header.svelte +0 -49
- package/src/components/chat-conversation-header/chat-conversation-header.types.ts +0 -20
- package/src/components/chat-conversation-header/chat-conversation-header.variables.json +0 -1
- package/src/components/chat-conversation-header/chat-conversation-header.variables.ts +0 -3
- package/src/components/chat-conversation-header/index.ts +0 -9
- package/src/components/chat-conversation-list/chat-conversation-list.css +0 -127
- package/src/components/chat-conversation-list/chat-conversation-list.examples.json +0 -13
- package/src/components/chat-conversation-list/chat-conversation-list.schema.json +0 -45
- package/src/components/chat-conversation-list/chat-conversation-list.schema.ts +0 -52
- package/src/components/chat-conversation-list/chat-conversation-list.svelte +0 -75
- package/src/components/chat-conversation-list/chat-conversation-list.types.ts +0 -18
- package/src/components/chat-conversation-list/chat-conversation-list.variables.json +0 -1
- package/src/components/chat-conversation-list/chat-conversation-list.variables.ts +0 -3
- package/src/components/chat-conversation-list/conversation-summary.ts +0 -88
- package/src/components/chat-conversation-list/index.ts +0 -11
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
ChatScrollStateChangeEvent,
|
|
3
|
-
ChatStopGeneratingEvent,
|
|
4
|
-
ChatSubmitEvent,
|
|
5
|
-
ChatUnreadIndicatorChangeEvent,
|
|
6
|
-
} from './chat-events.ts';
|
|
7
|
-
export { default as Chat } from './chat.svelte';
|
|
8
|
-
|
|
9
|
-
// Scroll utilities
|
|
10
|
-
export {
|
|
11
|
-
DEFAULT_SCROLL_CONFIGURATION,
|
|
12
|
-
calculateScrollToBottom,
|
|
13
|
-
calculateUnreadCount,
|
|
14
|
-
extractTimestamp,
|
|
15
|
-
findUnreadBoundaryIndex,
|
|
16
|
-
formatUnreadCount,
|
|
17
|
-
isAtBottom,
|
|
18
|
-
isLargeCount,
|
|
19
|
-
shouldShowJumpToLatest,
|
|
20
|
-
} from './scroll-utilities';
|
|
21
|
-
export type { ScrollConfiguration, ScrollState } from './scroll-utilities';
|
|
22
|
-
|
|
23
|
-
// Runes helpers
|
|
24
|
-
export {
|
|
25
|
-
useChatScrollState,
|
|
26
|
-
type UseChatScrollStateOptions,
|
|
27
|
-
type UseChatScrollStateReturn,
|
|
28
|
-
} from './use-chat-scroll-state.svelte';
|
|
29
|
-
|
|
30
|
-
export {
|
|
31
|
-
useChatUnreadState,
|
|
32
|
-
type UseChatUnreadStateOptions,
|
|
33
|
-
type UseChatUnreadStateReturn,
|
|
34
|
-
} from './use-chat-unread-state.svelte';
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
useChatKeyboardNav,
|
|
38
|
-
type UseChatKeyboardNavOptions,
|
|
39
|
-
type UseChatKeyboardNavReturn,
|
|
40
|
-
} from './use-chat-keyboard-nav.svelte';
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
useChatMessageGroups,
|
|
44
|
-
type DateItem,
|
|
45
|
-
type MessageItem,
|
|
46
|
-
type MessageWithDateItem,
|
|
47
|
-
type ToolCallPair,
|
|
48
|
-
type UseChatMessageGroupsOptions,
|
|
49
|
-
type UseChatMessageGroupsReturn,
|
|
50
|
-
} from './use-chat-message-groups.svelte';
|
|
51
|
-
|
|
52
|
-
// Subcomponents
|
|
53
|
-
export { default as ChatJumpControls } from './chat-jump-controls.svelte';
|
|
54
|
-
|
|
55
|
-
export { default as ChatStatusAnnouncer } from './chat-status-announcer.svelte';
|
|
56
|
-
|
|
57
|
-
export { default as ChatSearchBar } from './chat-search-bar.svelte';
|
|
58
|
-
|
|
59
|
-
export {
|
|
60
|
-
useChatSearch,
|
|
61
|
-
type ChatSearchMatch,
|
|
62
|
-
type UseChatSearchOptions,
|
|
63
|
-
type UseChatSearchReturn,
|
|
64
|
-
} from './use-chat-search.svelte';
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure utility functions for scroll position calculations and unread tracking.
|
|
3
|
-
*
|
|
4
|
-
* These functions are intentionally pure (no DOM access) for testability.
|
|
5
|
-
* They accept scroll state as input and return computed values.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { Message } from '../conversation-model.ts';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Represents the scroll state of a container element.
|
|
12
|
-
* These values come from HTMLElement scroll properties.
|
|
13
|
-
*/
|
|
14
|
-
export type ScrollState = {
|
|
15
|
-
/** Current scroll position from top (scrollTop) */
|
|
16
|
-
scrollTop: number;
|
|
17
|
-
/** Total scrollable height (scrollHeight) */
|
|
18
|
-
scrollHeight: number;
|
|
19
|
-
/** Visible viewport height (clientHeight) */
|
|
20
|
-
clientHeight: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Configuration for scroll behavior thresholds.
|
|
25
|
-
*/
|
|
26
|
-
export type ScrollConfiguration = {
|
|
27
|
-
/**
|
|
28
|
-
* Pixels from bottom to consider "at bottom".
|
|
29
|
-
* A generous threshold handles:
|
|
30
|
-
* - Fractional pixel values on high-DPI displays
|
|
31
|
-
* - Imprecise touch scrolling
|
|
32
|
-
* - Small layout shifts from loading content
|
|
33
|
-
* @default 150
|
|
34
|
-
*/
|
|
35
|
-
bottomThreshold: number;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Pixels scrolled up before showing jump-to-latest button.
|
|
39
|
-
* Slightly larger than bottomThreshold to create hysteresis
|
|
40
|
-
* (prevents button flickering near the threshold).
|
|
41
|
-
* @default 200
|
|
42
|
-
*/
|
|
43
|
-
jumpThreshold: number;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Default scroll configuration values.
|
|
48
|
-
*
|
|
49
|
-
* The 150px bottom threshold accommodates 2-3 message previews,
|
|
50
|
-
* which matches user mental models of "being at the end".
|
|
51
|
-
*/
|
|
52
|
-
export const DEFAULT_SCROLL_CONFIGURATION: ScrollConfiguration = {
|
|
53
|
-
bottomThreshold: 150,
|
|
54
|
-
jumpThreshold: 200,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Determines if the scroll position is at or near the bottom.
|
|
59
|
-
*
|
|
60
|
-
* Used to decide whether to auto-scroll when new messages arrive.
|
|
61
|
-
* If true, new messages should trigger scroll-to-bottom.
|
|
62
|
-
* If false, the user is reading history and scroll should not change.
|
|
63
|
-
*
|
|
64
|
-
* @param state - Current scroll state from the container
|
|
65
|
-
* @param threshold - Pixels from bottom to consider "at bottom"
|
|
66
|
-
* @returns true if within threshold of the bottom
|
|
67
|
-
*/
|
|
68
|
-
export function isAtBottom(state: ScrollState, threshold: number): boolean {
|
|
69
|
-
const distanceFromBottom = state.scrollHeight - state.scrollTop - state.clientHeight;
|
|
70
|
-
// Handle edge case where content is shorter than viewport
|
|
71
|
-
// (scrollHeight <= clientHeight means user is always "at bottom")
|
|
72
|
-
return distanceFromBottom <= threshold || state.scrollHeight <= state.clientHeight;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Determines if the jump-to-latest button should be visible.
|
|
77
|
-
*
|
|
78
|
-
* Uses a separate (larger) threshold than isAtBottom to create hysteresis,
|
|
79
|
-
* preventing the button from flickering when scrolling near the threshold.
|
|
80
|
-
*
|
|
81
|
-
* @param state - Current scroll state from the container
|
|
82
|
-
* @param threshold - Pixels from bottom before showing button
|
|
83
|
-
* @returns true if scrolled far enough from bottom to show button
|
|
84
|
-
*/
|
|
85
|
-
export function shouldShowJumpToLatest(state: ScrollState, threshold: number): boolean {
|
|
86
|
-
const distanceFromBottom = state.scrollHeight - state.scrollTop - state.clientHeight;
|
|
87
|
-
// Don't show if content fits in viewport
|
|
88
|
-
if (state.scrollHeight <= state.clientHeight) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
return distanceFromBottom > threshold;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Extracts a comparable timestamp value from a message.
|
|
96
|
-
* Messages use ISO 8601 strings for createdAt (e.g., "2024-01-15T10:30:00.000Z").
|
|
97
|
-
*
|
|
98
|
-
* @param message - Message to extract timestamp from
|
|
99
|
-
* @returns Timestamp as milliseconds since epoch, or null if not available
|
|
100
|
-
*/
|
|
101
|
-
function getMessageTimestamp(message: Message): number | null {
|
|
102
|
-
// createdAt is an ISO 8601 string
|
|
103
|
-
if (message.createdAt) {
|
|
104
|
-
const parsed = Date.parse(message.createdAt);
|
|
105
|
-
if (!Number.isNaN(parsed)) {
|
|
106
|
-
return parsed;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
// Fallback to metadata.timestamp if present (may be number or string)
|
|
110
|
-
const metaTimestamp = message.metadata?.['timestamp'];
|
|
111
|
-
if (typeof metaTimestamp === 'number') {
|
|
112
|
-
return metaTimestamp;
|
|
113
|
-
}
|
|
114
|
-
if (typeof metaTimestamp === 'string') {
|
|
115
|
-
const parsed = Date.parse(metaTimestamp);
|
|
116
|
-
if (!Number.isNaN(parsed)) {
|
|
117
|
-
return parsed;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Calculates the number of unread messages based on timestamp.
|
|
125
|
-
*
|
|
126
|
-
* @param messages - Array of messages with timestamps
|
|
127
|
-
* @param lastReadTimestamp - Timestamp of the last read message in milliseconds (0 if none read)
|
|
128
|
-
* @returns Count of messages with timestamp > lastReadTimestamp
|
|
129
|
-
*/
|
|
130
|
-
export function calculateUnreadCount(messages: Message[], lastReadTimestamp: number): number {
|
|
131
|
-
if (lastReadTimestamp === 0) {
|
|
132
|
-
// If nothing has been read, all messages are "unread"
|
|
133
|
-
// But we typically don't count initial load as unread
|
|
134
|
-
return 0;
|
|
135
|
-
}
|
|
136
|
-
return messages.filter((message) => {
|
|
137
|
-
const timestamp = getMessageTimestamp(message);
|
|
138
|
-
return timestamp != null && timestamp > lastReadTimestamp;
|
|
139
|
-
}).length;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Finds the index where unread messages begin.
|
|
144
|
-
*
|
|
145
|
-
* This is used to insert the "unread divider" in the message list.
|
|
146
|
-
*
|
|
147
|
-
* @param messages - Array of messages with timestamps
|
|
148
|
-
* @param lastReadTimestamp - Timestamp of the last read message in milliseconds
|
|
149
|
-
* @returns Index of first unread message, or -1 if all messages are read
|
|
150
|
-
*/
|
|
151
|
-
export function findUnreadBoundaryIndex(messages: Message[], lastReadTimestamp: number): number {
|
|
152
|
-
if (lastReadTimestamp === 0) {
|
|
153
|
-
return -1; // No unread boundary for initial load
|
|
154
|
-
}
|
|
155
|
-
return messages.findIndex((message) => {
|
|
156
|
-
const timestamp = getMessageTimestamp(message);
|
|
157
|
-
return timestamp != null && timestamp > lastReadTimestamp;
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Calculates the scroll position needed to scroll to bottom.
|
|
163
|
-
*
|
|
164
|
-
* @param state - Current scroll state
|
|
165
|
-
* @returns The scrollTop value that would scroll to bottom
|
|
166
|
-
*/
|
|
167
|
-
export function calculateScrollToBottom(state: ScrollState): number {
|
|
168
|
-
return Math.max(0, state.scrollHeight - state.clientHeight);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Formats the unread count for display.
|
|
173
|
-
* Caps at 99+ to prevent badge overflow.
|
|
174
|
-
*
|
|
175
|
-
* @param count - Raw unread count
|
|
176
|
-
* @returns Formatted string for display ("1", "50", "99+")
|
|
177
|
-
*/
|
|
178
|
-
export function formatUnreadCount(count: number): string {
|
|
179
|
-
if (count <= 0) return '';
|
|
180
|
-
if (count > 99) return '99+';
|
|
181
|
-
return count.toString();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Determines if a count should be displayed with compact styling.
|
|
186
|
-
* Used to adjust badge styling for large numbers.
|
|
187
|
-
*
|
|
188
|
-
* @param count - Raw unread count
|
|
189
|
-
* @returns true if count exceeds 99
|
|
190
|
-
*/
|
|
191
|
-
export function isLargeCount(count: number): boolean {
|
|
192
|
-
return count > 99;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Extracts a numeric timestamp from a message for comparison.
|
|
197
|
-
* Exported for use in components that need to track last-read timestamps.
|
|
198
|
-
*
|
|
199
|
-
* @param message - Message to extract timestamp from
|
|
200
|
-
* @returns Timestamp as milliseconds since epoch, or current time if not available
|
|
201
|
-
*/
|
|
202
|
-
export function extractTimestamp(message: Message): number {
|
|
203
|
-
return getMessageTimestamp(message) ?? Date.now();
|
|
204
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runes helper for tracking which per-message disclosures are expanded.
|
|
3
|
-
*
|
|
4
|
-
* Owns a set of expanded message ids and provides a toggle function. Used for
|
|
5
|
-
* any collapsed-by-default disclosure that is keyed by message id and lives in
|
|
6
|
-
* a virtualized transcript — reasoning blocks and tool-call cards both use one
|
|
7
|
-
* instance each. When a virtualizer remeasure callback is registered
|
|
8
|
-
* (optional), toggling fires it so the virtualizer can remeasure the row after
|
|
9
|
-
* the disclosure opens/closes.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Creates reactive state for per-message disclosure expansion.
|
|
13
|
-
*
|
|
14
|
-
* The returned `isExpanded` and `toggle` are stable references — safe to pass
|
|
15
|
-
* as props without triggering extra re-renders.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```svelte
|
|
19
|
-
* <script lang="ts">
|
|
20
|
-
* import { useChatDisclosureState } from './use-chat-disclosure-state.svelte';
|
|
21
|
-
*
|
|
22
|
-
* const reasoningState = useChatDisclosureState({});
|
|
23
|
-
* </script>
|
|
24
|
-
*
|
|
25
|
-
* <!-- in template: -->
|
|
26
|
-
* <ReasoningPart
|
|
27
|
-
* {part}
|
|
28
|
-
* expanded={reasoningState.isExpanded(message.id)}
|
|
29
|
-
* ontoggle={() => reasoningState.toggle(message.id)}
|
|
30
|
-
* />
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export function useChatDisclosureState(options) {
|
|
34
|
-
const { onRemeasureRow } = options;
|
|
35
|
-
// Set of message ids whose disclosures are currently expanded.
|
|
36
|
-
// Collapsed by default (disclosures start closed).
|
|
37
|
-
let expandedIds = $state(new Set());
|
|
38
|
-
function isExpanded(messageId) {
|
|
39
|
-
return expandedIds.has(messageId);
|
|
40
|
-
}
|
|
41
|
-
function toggle(messageId) {
|
|
42
|
-
const next = new Set(expandedIds);
|
|
43
|
-
if (next.has(messageId)) {
|
|
44
|
-
next.delete(messageId);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
next.add(messageId);
|
|
48
|
-
}
|
|
49
|
-
expandedIds = next;
|
|
50
|
-
// Notify the virtualizer so it can remeasure the row after the DOM
|
|
51
|
-
// transitions to its new open/closed height. No-op when not wired.
|
|
52
|
-
onRemeasureRow?.(messageId);
|
|
53
|
-
}
|
|
54
|
-
function reset() {
|
|
55
|
-
expandedIds = new Set();
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
isExpanded,
|
|
59
|
-
toggle,
|
|
60
|
-
reset,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runes helper for chat keyboard navigation.
|
|
3
|
-
*
|
|
4
|
-
* Extracts keyboard event handling for:
|
|
5
|
-
* - Home/End to jump to first/last message
|
|
6
|
-
* - PageUp/PageDown for viewport scrolling
|
|
7
|
-
* - Arrow keys for message-to-message navigation
|
|
8
|
-
*/
|
|
9
|
-
import { tick } from 'svelte';
|
|
10
|
-
// ==========================================================================
|
|
11
|
-
// Helper
|
|
12
|
-
// ==========================================================================
|
|
13
|
-
/**
|
|
14
|
-
* Creates keyboard navigation handlers for the chat container.
|
|
15
|
-
*
|
|
16
|
-
* Supports:
|
|
17
|
-
* - `End`: Jump to latest message
|
|
18
|
-
* - `Home`: Scroll to top and focus first message
|
|
19
|
-
* - `PageDown`/`PageUp`: Scroll by 90% of viewport
|
|
20
|
-
* - `ArrowDown`/`ArrowUp`: Navigate between messages when focused on a message
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```svelte
|
|
24
|
-
* <script lang="ts">
|
|
25
|
-
* import { useChatKeyboardNav } from './use-chat-keyboard-nav.svelte';
|
|
26
|
-
*
|
|
27
|
-
* const keyboardNav = useChatKeyboardNav({
|
|
28
|
-
* onJumpToLatest: handleJumpToLatest,
|
|
29
|
-
* getScrollBehavior: () => prefersReducedMotion() ? 'auto' : 'smooth',
|
|
30
|
-
* });
|
|
31
|
-
* </script>
|
|
32
|
-
*
|
|
33
|
-
* <div onkeydown={(e) => keyboardNav.handleKeyDown(e, viewport)}>
|
|
34
|
-
* <!-- chat content -->
|
|
35
|
-
* </div>
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export function useChatKeyboardNav(options) {
|
|
39
|
-
const { onJumpToLatest, onJumpToStart, getScrollBehavior, getHistoryTrigger, onVirtualMessageNavigation, } = options;
|
|
40
|
-
/**
|
|
41
|
-
* Navigate to next or previous message.
|
|
42
|
-
* Scrolls the focused message into view.
|
|
43
|
-
*/
|
|
44
|
-
function navigateMessages(viewport, direction) {
|
|
45
|
-
const allMessages = viewport.querySelectorAll('.chat-message');
|
|
46
|
-
if (allMessages.length === 0)
|
|
47
|
-
return;
|
|
48
|
-
const currentIndex = Array.from(allMessages).findIndex((msg) => msg === document.activeElement);
|
|
49
|
-
let targetIndex;
|
|
50
|
-
if (currentIndex === -1) {
|
|
51
|
-
// No message currently focused: default to first/last message based on direction
|
|
52
|
-
targetIndex = direction === 'next' ? 0 : allMessages.length - 1;
|
|
53
|
-
}
|
|
54
|
-
else if (direction === 'next') {
|
|
55
|
-
targetIndex = currentIndex < allMessages.length - 1 ? currentIndex + 1 : currentIndex;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
targetIndex = currentIndex > 0 ? currentIndex - 1 : currentIndex;
|
|
59
|
-
}
|
|
60
|
-
const targetMessage = allMessages[targetIndex];
|
|
61
|
-
if (targetMessage && targetMessage !== document.activeElement) {
|
|
62
|
-
targetMessage.focus();
|
|
63
|
-
targetMessage.scrollIntoView({ behavior: getScrollBehavior(), block: 'nearest' });
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Text-editing element selectors where Home/End/PageUp/PageDown are used for
|
|
68
|
-
* cursor/scroll movement within the element itself.
|
|
69
|
-
*
|
|
70
|
-
* We intentionally exclude `button` and `a` because those elements do not
|
|
71
|
-
* consume these keys, and blocking viewport navigation when a message action
|
|
72
|
-
* button is focused would silently break PageUp/PageDown for keyboard users.
|
|
73
|
-
*/
|
|
74
|
-
const TEXT_EDITING_SELECTOR = 'input, textarea, select, [contenteditable]';
|
|
75
|
-
/**
|
|
76
|
-
* Handle keydown events for keyboard navigation.
|
|
77
|
-
*/
|
|
78
|
-
function handleKeyDown(event, viewport) {
|
|
79
|
-
if (!viewport)
|
|
80
|
-
return;
|
|
81
|
-
// Don't intercept if focus is inside a text-editing element that uses
|
|
82
|
-
// these keys for cursor movement (input, textarea, contenteditable, etc.).
|
|
83
|
-
// Buttons and links do not consume Home/End/PageUp/PageDown, so they are
|
|
84
|
-
// excluded from the guard to preserve viewport navigation for those cases.
|
|
85
|
-
if (document.activeElement?.closest('.chat-input') ||
|
|
86
|
-
document.activeElement?.matches(TEXT_EDITING_SELECTOR))
|
|
87
|
-
return;
|
|
88
|
-
const behavior = getScrollBehavior();
|
|
89
|
-
switch (event.key) {
|
|
90
|
-
case 'End':
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
onJumpToLatest();
|
|
93
|
-
break;
|
|
94
|
-
case 'Home':
|
|
95
|
-
event.preventDefault();
|
|
96
|
-
if (onJumpToStart) {
|
|
97
|
-
onJumpToStart();
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
viewport.scrollTo({ top: 0, behavior });
|
|
101
|
-
}
|
|
102
|
-
// Focus the explicit history trigger first when present; otherwise focus
|
|
103
|
-
// the first rendered message.
|
|
104
|
-
void tick().then(() => {
|
|
105
|
-
const historyTrigger = getHistoryTrigger?.();
|
|
106
|
-
if (historyTrigger) {
|
|
107
|
-
historyTrigger.focus();
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
const firstMessage = viewport.querySelector('.chat-message');
|
|
111
|
-
firstMessage?.focus();
|
|
112
|
-
}
|
|
113
|
-
return undefined;
|
|
114
|
-
}, () => undefined);
|
|
115
|
-
break;
|
|
116
|
-
case 'PageDown':
|
|
117
|
-
event.preventDefault();
|
|
118
|
-
viewport.scrollBy({ top: viewport.clientHeight * 0.9, behavior });
|
|
119
|
-
break;
|
|
120
|
-
case 'PageUp':
|
|
121
|
-
event.preventDefault();
|
|
122
|
-
viewport.scrollBy({ top: -viewport.clientHeight * 0.9, behavior });
|
|
123
|
-
break;
|
|
124
|
-
// Arrow key navigation between messages. Suppressed whenever the focused
|
|
125
|
-
// element is NOT the `.chat-message` article itself (tabindex=-1). This
|
|
126
|
-
// means focus inside any child interactive element (tool-approval buttons,
|
|
127
|
-
// suggestion chips, etc.) is already excluded because those elements do
|
|
128
|
-
// not have the `chat-message` class. The previous `.closest()` guards
|
|
129
|
-
// were dead code: `closest()` traverses upward to ancestors, but
|
|
130
|
-
// `[data-cinder-tool-approval]` and `[data-cinder-suggested-replies]` are
|
|
131
|
-
// descendants — so they always returned null, making `!null` always true.
|
|
132
|
-
case 'ArrowDown':
|
|
133
|
-
if (document.activeElement?.classList.contains('chat-message')) {
|
|
134
|
-
event.preventDefault();
|
|
135
|
-
if (!onVirtualMessageNavigation?.('next')) {
|
|
136
|
-
navigateMessages(viewport, 'next');
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
break;
|
|
140
|
-
case 'ArrowUp':
|
|
141
|
-
if (document.activeElement?.classList.contains('chat-message')) {
|
|
142
|
-
event.preventDefault();
|
|
143
|
-
if (!onVirtualMessageNavigation?.('previous')) {
|
|
144
|
-
navigateMessages(viewport, 'previous');
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return {
|
|
151
|
-
handleKeyDown,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runes helper for chat message grouping and tool call pairing.
|
|
3
|
-
*
|
|
4
|
-
* Extracts derived values for:
|
|
5
|
-
* - Messages grouped with date separators
|
|
6
|
-
* - Tool call pairs indexed by call ID for O(1) lookup
|
|
7
|
-
*/
|
|
8
|
-
import { pairToolCallsWithResults } from '../utilities';
|
|
9
|
-
// ==========================================================================
|
|
10
|
-
// Helper
|
|
11
|
-
// ==========================================================================
|
|
12
|
-
/** Find result message IDs that are already represented by paired tool-call messages. */
|
|
13
|
-
export function findPairedToolResultIds(messages) {
|
|
14
|
-
const visibleToolCallIds = new Set();
|
|
15
|
-
const pairedResultIds = new Set();
|
|
16
|
-
for (const message of messages) {
|
|
17
|
-
if (message.role === 'tool-call' && message.toolCall) {
|
|
18
|
-
visibleToolCallIds.add(message.toolCall.id);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
for (const message of messages) {
|
|
22
|
-
if (message.role === 'tool-result' &&
|
|
23
|
-
message.toolResult &&
|
|
24
|
-
visibleToolCallIds.has(message.toolResult.callId)) {
|
|
25
|
-
pairedResultIds.add(message.id);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return pairedResultIds;
|
|
29
|
-
}
|
|
30
|
-
/** Build visible messages with date separators, skipping paired tool-result messages. */
|
|
31
|
-
export function buildMessagesWithDateSeparators(messages, pairedToolResultIds) {
|
|
32
|
-
const result = [];
|
|
33
|
-
let lastDate = null;
|
|
34
|
-
for (const message of messages) {
|
|
35
|
-
if (message.role === 'tool-result' && pairedToolResultIds.has(message.id)) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
const timestamp = message.createdAt ?? message.metadata?.['timestamp'];
|
|
39
|
-
if (timestamp != null) {
|
|
40
|
-
const messageDate = new Date(timestamp);
|
|
41
|
-
const isValidDate = !isNaN(messageDate.getTime());
|
|
42
|
-
if (isValidDate) {
|
|
43
|
-
const dateKey = messageDate.toDateString();
|
|
44
|
-
if (dateKey !== lastDate) {
|
|
45
|
-
result.push({ type: 'date', date: messageDate });
|
|
46
|
-
lastDate = dateKey;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
result.push({ type: 'message', message });
|
|
51
|
-
}
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
54
|
-
export function buildChatRenderRows(items, options) {
|
|
55
|
-
const rows = [];
|
|
56
|
-
const firstUnreadId = options?.firstUnreadId ?? null;
|
|
57
|
-
let previousMessageId = null;
|
|
58
|
-
for (const item of items) {
|
|
59
|
-
if (item.type === 'message') {
|
|
60
|
-
if (item.message.id === firstUnreadId) {
|
|
61
|
-
rows.push({ type: 'unread-divider', afterMessageId: previousMessageId });
|
|
62
|
-
}
|
|
63
|
-
previousMessageId = item.message.id;
|
|
64
|
-
}
|
|
65
|
-
rows.push(item);
|
|
66
|
-
}
|
|
67
|
-
if (options?.showTypingIndicator) {
|
|
68
|
-
rows.push({ type: 'typing' });
|
|
69
|
-
}
|
|
70
|
-
return rows;
|
|
71
|
-
}
|
|
72
|
-
export function chatRenderRowKey(row) {
|
|
73
|
-
switch (row.type) {
|
|
74
|
-
case 'date':
|
|
75
|
-
return `date-${row.date.toISOString()}`;
|
|
76
|
-
case 'message':
|
|
77
|
-
return `msg-${row.message.id}`;
|
|
78
|
-
case 'unread-divider':
|
|
79
|
-
return `unread-${row.afterMessageId ?? 'start'}`;
|
|
80
|
-
case 'typing':
|
|
81
|
-
return 'typing';
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
export function findRenderRowIndexByMessageId(rows, messageId) {
|
|
85
|
-
return rows.findIndex((row) => row.type === 'message' && row.message.id === messageId);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Creates reactive derived values for message grouping and tool call pairing.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```svelte
|
|
92
|
-
* <script lang="ts">
|
|
93
|
-
* import { useChatMessageGroups } from './use-chat-message-groups.svelte';
|
|
94
|
-
*
|
|
95
|
-
* const messageGroups = useChatMessageGroups({
|
|
96
|
-
* getMessages: () => messages,
|
|
97
|
-
* });
|
|
98
|
-
*
|
|
99
|
-
* // Access derived values
|
|
100
|
-
* const items = messageGroups.messagesWithDates;
|
|
101
|
-
* const pairs = messageGroups.toolCallPairsByCallId.get(callId);
|
|
102
|
-
* </script>
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
export function useChatMessageGroups(options) {
|
|
106
|
-
const { getMessages } = options;
|
|
107
|
-
// Derive tool call pairs from messages
|
|
108
|
-
const toolCallPairs = $derived(pairToolCallsWithResults(getMessages()));
|
|
109
|
-
// Build a Map for O(1) lookup of tool call pairs by call ID
|
|
110
|
-
// Note: Using plain Map instead of SvelteMap since the map is recreated
|
|
111
|
-
// on each derivation (not mutated), so reactive wrapper is unnecessary
|
|
112
|
-
const toolCallPairsByCallId = $derived.by(() => {
|
|
113
|
-
// eslint-disable-next-line svelte/prefer-svelte-reactivity -- Map is recreated on each derivation, not mutated
|
|
114
|
-
const map = new Map();
|
|
115
|
-
for (const pair of toolCallPairs) {
|
|
116
|
-
const existing = map.get(pair.call.id);
|
|
117
|
-
if (existing) {
|
|
118
|
-
existing.push(pair);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
map.set(pair.call.id, [pair]);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return map;
|
|
125
|
-
});
|
|
126
|
-
const pairedToolResultIds = $derived.by(() => findPairedToolResultIds(getMessages()));
|
|
127
|
-
// Group messages by date for date separators
|
|
128
|
-
const messagesWithDates = $derived.by(() => {
|
|
129
|
-
return buildMessagesWithDateSeparators(getMessages(), pairedToolResultIds);
|
|
130
|
-
});
|
|
131
|
-
const renderRows = $derived.by(() => buildChatRenderRows(messagesWithDates));
|
|
132
|
-
return {
|
|
133
|
-
get messagesWithDates() {
|
|
134
|
-
return messagesWithDates;
|
|
135
|
-
},
|
|
136
|
-
get renderRows() {
|
|
137
|
-
return renderRows;
|
|
138
|
-
},
|
|
139
|
-
get toolCallPairsByCallId() {
|
|
140
|
-
return toolCallPairsByCallId;
|
|
141
|
-
},
|
|
142
|
-
get pairedToolResultIds() {
|
|
143
|
-
return pairedToolResultIds;
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-message read receipt state for the Chat component.
|
|
3
|
-
*
|
|
4
|
-
* Merges two sources of receipt state:
|
|
5
|
-
* 1. The `readReceipts` prop — a `Map<messageId, ReadReceipt>` passed directly
|
|
6
|
-
* by the consumer (no adapter required).
|
|
7
|
-
* 2. The adapter's `onReadReceipt` push handler, forwarded by the container
|
|
8
|
-
* via the `handleAdapterReadReceipt` callback below.
|
|
9
|
-
*
|
|
10
|
-
* The adapter path accumulates receipts incrementally: each incoming event inserts
|
|
11
|
-
* a fresh `'read'` receipt for a new message id, or accumulates (deduplicated)
|
|
12
|
-
* `readBy` names on a repeat push for an already-recorded message. Adapter events
|
|
13
|
-
* always imply `'read'` status, so there is no status ordering or downgrade.
|
|
14
|
-
*
|
|
15
|
-
* Render rules (enforced in the component, not here):
|
|
16
|
-
* - Only shown on `user`-role messages (gated by the caller).
|
|
17
|
-
* - Icon + accessible text always present — color alone never conveys state.
|
|
18
|
-
* - data-cinder-receipt-status=sent|delivered|read on the wrapper element.
|
|
19
|
-
*
|
|
20
|
-
* @module
|
|
21
|
-
*/
|
|
22
|
-
export function useChatReadReceipts(options) {
|
|
23
|
-
// Receipts accumulated from the adapter's onReadReceipt push events.
|
|
24
|
-
// Keyed by message id. Stored as a plain reactive object (record) rather than a
|
|
25
|
-
// Map so property assignments trigger Svelte 5's fine-grained reactivity.
|
|
26
|
-
let adapterReceipts = $state({});
|
|
27
|
-
function getReceipt(messageId) {
|
|
28
|
-
// A defined prop map is authoritative — return exactly its value (or
|
|
29
|
-
// undefined) so a consumer's empty/partial Map can suppress adapter state.
|
|
30
|
-
const propReceipts = options.getReadReceipts();
|
|
31
|
-
if (propReceipts !== undefined)
|
|
32
|
-
return propReceipts.get(messageId);
|
|
33
|
-
return adapterReceipts[messageId];
|
|
34
|
-
}
|
|
35
|
-
function handleAdapterReadReceipt(event) {
|
|
36
|
-
const existing = adapterReceipts[event.messageId];
|
|
37
|
-
// Adapter read-receipt events imply "read" status (the event type carries no
|
|
38
|
-
// lower-rank status). A new message gets a fresh "read" receipt; a repeat push
|
|
39
|
-
// for an already-read message accumulates the `readBy` names (deduplicated).
|
|
40
|
-
if (existing === undefined) {
|
|
41
|
-
// Conditional spread: under exactOptionalPropertyTypes, omit `readBy`
|
|
42
|
-
// entirely when the event carries none (don't set it to `undefined`).
|
|
43
|
-
adapterReceipts[event.messageId] = {
|
|
44
|
-
status: 'read',
|
|
45
|
-
...(event.readBy !== undefined ? { readBy: event.readBy } : {}),
|
|
46
|
-
};
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (event.readBy !== undefined && event.readBy.length > 0) {
|
|
50
|
-
const merged = Array.from(new Set([...(existing.readBy ?? []), ...event.readBy]));
|
|
51
|
-
adapterReceipts[event.messageId] = { ...existing, readBy: merged };
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function reset() {
|
|
55
|
-
adapterReceipts = {};
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
getReceipt,
|
|
59
|
-
handleAdapterReadReceipt,
|
|
60
|
-
reset,
|
|
61
|
-
};
|
|
62
|
-
}
|