@xpert-ai/chatkit-ui 0.1.2 → 0.2.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/dist/app/assets/{_baseUniq-Cjg58ynO.js → _baseUniq-U3ZlyosM.js} +1 -1
- package/dist/app/assets/{abap-CaHNU3KZ.js → abap-8X6m4nc9.js} +1 -1
- package/dist/app/assets/{abnf-D-YMXYdM.js → abnf-B9FqRK4Q.js} +1 -1
- package/dist/app/assets/{actionscript-CrHB5nA4.js → actionscript-BRiggmYG.js} +1 -1
- package/dist/app/assets/{ada-Dv2nikaa.js → ada-FFsIKz3W.js} +1 -1
- package/dist/app/assets/{agda-DFaAW7Yp.js → agda-CSry7vG2.js} +1 -1
- package/dist/app/assets/{al-CgiCJJan.js → al-B86I55sd.js} +1 -1
- package/dist/app/assets/{antlr4-BtYcfzHN.js → antlr4-DLdIrmfn.js} +1 -1
- package/dist/app/assets/{apacheconf-CQ7_TaHr.js → apacheconf-CyFZwC58.js} +1 -1
- package/dist/app/assets/{apex-B4zhZGbX.js → apex-DMVXQx7B.js} +1 -1
- package/dist/app/assets/{apl-CYl9UMD4.js → apl-CvxzOn3f.js} +1 -1
- package/dist/app/assets/{applescript-CqOg5uaM.js → applescript-D9BsJ4nv.js} +1 -1
- package/dist/app/assets/{aql-g4FQmCtN.js → aql-Du46VsVP.js} +1 -1
- package/dist/app/assets/{arc-Dg9GdpOd.js → arc-Cgg2Li2V.js} +1 -1
- package/dist/app/assets/{architectureDiagram-Q4EWVU46-D_Hf6A9k.js → architectureDiagram-Q4EWVU46-3DQlJdjW.js} +1 -1
- package/dist/app/assets/{arduino-CLAoEDGh.js → arduino-Bsv1YPmE.js} +1 -1
- package/dist/app/assets/{arff-CkPQOMpJ.js → arff-CJK1I_i3.js} +1 -1
- package/dist/app/assets/{asciidoc-D6FBYhU4.js → asciidoc-DxmnfpMK.js} +1 -1
- package/dist/app/assets/{asm6502-BNREQutf.js → asm6502-B-ig6A0r.js} +1 -1
- package/dist/app/assets/{asmatmel-AsGe04C5.js → asmatmel-DlH3PvMo.js} +1 -1
- package/dist/app/assets/{aspnet-BowT6uwS.js → aspnet-D8iv0Uvb.js} +1 -1
- package/dist/app/assets/{autohotkey-CYQjpY2v.js → autohotkey-B0J5KM1J.js} +1 -1
- package/dist/app/assets/{autoit-DZuwPYYs.js → autoit-DjZ-C8Ct.js} +1 -1
- package/dist/app/assets/{avisynth-BApmLDkf.js → avisynth-DBwstp_C.js} +1 -1
- package/dist/app/assets/{avro-idl-DTdqv6Sr.js → avro-idl-D2NmTxDF.js} +1 -1
- package/dist/app/assets/{bash-COtf9s5e.js → bash-CaYF0XP6.js} +1 -1
- package/dist/app/assets/{basic-0Wk0Z9hh.js → basic-CmOS0BPn.js} +1 -1
- package/dist/app/assets/{batch-yLGV74r2.js → batch-0uLA_1q6.js} +1 -1
- package/dist/app/assets/{bbcode-gj0k8ZdD.js → bbcode-DofDtehq.js} +1 -1
- package/dist/app/assets/{bicep-BsCXg-ZU.js → bicep-Csi6HiBf.js} +1 -1
- package/dist/app/assets/{birb-CrVXepVH.js → birb-wpSYHdbW.js} +1 -1
- package/dist/app/assets/{bison-CEkN9m61.js → bison-B_ycJmsC.js} +1 -1
- package/dist/app/assets/{blockDiagram-DXYQGD6D-Cxg7TJzM.js → blockDiagram-DXYQGD6D-C5FR_JeB.js} +1 -1
- package/dist/app/assets/{bnf-BNo5FkNz.js → bnf-BFkvwiYp.js} +1 -1
- package/dist/app/assets/{brainfuck-Be3VzThb.js → brainfuck-CKXec9xF.js} +1 -1
- package/dist/app/assets/{brightscript-DvlnFSog.js → brightscript-da2DAp0M.js} +1 -1
- package/dist/app/assets/{bro-v-4Gv7xz.js → bro-CMEOqxCO.js} +1 -1
- package/dist/app/assets/{bsl-Ckf08F6h.js → bsl-CcPijGZ5.js} +1 -1
- package/dist/app/assets/{c-DzIU03a7.js → c-ypihM29I.js} +1 -1
- package/dist/app/assets/{c4Diagram-AHTNJAMY-ClK737fG.js → c4Diagram-AHTNJAMY-CVQ-YBVO.js} +1 -1
- package/dist/app/assets/{cfscript-BjMiAM6E.js → cfscript-57UtmCol.js} +1 -1
- package/dist/app/assets/{chaiscript-B43Wj-Sh.js → chaiscript-Bzv7uMwl.js} +1 -1
- package/dist/app/assets/channel-QFEl2WH8.js +1 -0
- package/dist/app/assets/{chunk-4BX2VUAB-CLpouVUP.js → chunk-4BX2VUAB-Dxfd4JRQ.js} +1 -1
- package/dist/app/assets/{chunk-4TB4RGXK-Bx935_8R.js → chunk-4TB4RGXK-0tBP8iWY.js} +1 -1
- package/dist/app/assets/{chunk-55IACEB6-BBvPym8v.js → chunk-55IACEB6-C6Of3RNV.js} +1 -1
- package/dist/app/assets/{chunk-EDXVE4YY-DjPOkQ8M.js → chunk-EDXVE4YY-D9VnbCF6.js} +1 -1
- package/dist/app/assets/{chunk-FMBD7UC4-DYYB_Z9z.js → chunk-FMBD7UC4-C-jb70xY.js} +1 -1
- package/dist/app/assets/{chunk-OYMX7WX6-D6RNfja3.js → chunk-OYMX7WX6-DHv4g2zF.js} +1 -1
- package/dist/app/assets/{chunk-QZHKN3VN-C8ZgdC9O.js → chunk-QZHKN3VN-BVJ1du8l.js} +1 -1
- package/dist/app/assets/{chunk-YZCP3GAM-BBgDUOse.js → chunk-YZCP3GAM-C9v1WHTx.js} +1 -1
- package/dist/app/assets/{cil-B9ihzdF2.js → cil-D9cVdpCd.js} +1 -1
- package/dist/app/assets/classDiagram-6PBFFD2Q-CUn8MbgR.js +1 -0
- package/dist/app/assets/classDiagram-v2-HSJHXN6E-CUn8MbgR.js +1 -0
- package/dist/app/assets/{clike-CJh4oCgy.js → clike-M17MKmCg.js} +1 -1
- package/dist/app/assets/{clojure-TlSbaE4l.js → clojure-BP9wyv_O.js} +1 -1
- package/dist/app/assets/clone-BMPaQ6PL.js +1 -0
- package/dist/app/assets/{cmake-BSn84SxA.js → cmake-Co2PqOJx.js} +1 -1
- package/dist/app/assets/{cobol-CJ6-cTtI.js → cobol-CNBeDco-.js} +1 -1
- package/dist/app/assets/{coffeescript-stKJEoMv.js → coffeescript-DdmDPbXl.js} +1 -1
- package/dist/app/assets/{concurnas-1ifwVnR3.js → concurnas-C9VRiWa-.js} +1 -1
- package/dist/app/assets/{coq-DVFU6UV7.js → coq-CYE7tqZa.js} +1 -1
- package/dist/app/assets/{core-Yh44uZBs.js → core-D4MD7_kt.js} +1 -1
- package/dist/app/assets/{cose-bilkent-S5V4N54A-Dx7-_QHb.js → cose-bilkent-S5V4N54A-Dxea2bnQ.js} +1 -1
- package/dist/app/assets/{cpp-Zzzi5FD8.js → cpp-DWaMOtiP.js} +1 -1
- package/dist/app/assets/{crystal-DDbZAA_E.js → crystal-BtBXd6Fx.js} +1 -1
- package/dist/app/assets/{csharp-BZcvKq6n.js → csharp-CrOHktb0.js} +1 -1
- package/dist/app/assets/{cshtml-9x1DpGIK.js → cshtml-CzjshIvK.js} +1 -1
- package/dist/app/assets/{csp-D1hHVDgG.js → csp-DnNBeWw0.js} +1 -1
- package/dist/app/assets/{css-extras-COx1Ei_l.js → css-extras-BDArRWv3.js} +1 -1
- package/dist/app/assets/{css-BFu7Iqqk.js → css-pohe_YML.js} +1 -1
- package/dist/app/assets/{csv-D0CxHXjS.js → csv-BOXRdr2m.js} +1 -1
- package/dist/app/assets/{cypher-BsuAyRBu.js → cypher-IsM8Hmhu.js} +1 -1
- package/dist/app/assets/{d-CtjOdpDZ.js → d-BUE4Srvp.js} +1 -1
- package/dist/app/assets/{dagre-KV5264BT-DjhJCF-B.js → dagre-KV5264BT-D9I1gn5M.js} +1 -1
- package/dist/app/assets/{dart-BN9c8RLX.js → dart-DKXx5vmY.js} +1 -1
- package/dist/app/assets/{dataweave-DzlUCFjQ.js → dataweave-CZ-IeeGN.js} +1 -1
- package/dist/app/assets/{dax-D0KU-54t.js → dax-Cyyg-Qre.js} +1 -1
- package/dist/app/assets/{dhall-BZJS2G5U.js → dhall-CI9o_hcQ.js} +1 -1
- package/dist/app/assets/{diagram-5BDNPKRD-DSws8TSr.js → diagram-5BDNPKRD-Da8AhEfW.js} +1 -1
- package/dist/app/assets/{diagram-G4DWMVQ6-Cx7BBH89.js → diagram-G4DWMVQ6-u5xAUOB1.js} +1 -1
- package/dist/app/assets/{diagram-MMDJMWI5-D9n-fpq5.js → diagram-MMDJMWI5-CRedReUg.js} +1 -1
- package/dist/app/assets/{diagram-TYMM5635-A2Du0da2.js → diagram-TYMM5635-Btelw9Gj.js} +1 -1
- package/dist/app/assets/{diff-2klWb1Uo.js → diff-BaJjRLPC.js} +1 -1
- package/dist/app/assets/{django-B2AbqJYz.js → django-DKz8sLSB.js} +1 -1
- package/dist/app/assets/{dns-zone-file-CvZSGx-4.js → dns-zone-file-DB4bzm0m.js} +1 -1
- package/dist/app/assets/{docker-Cn7U_QhX.js → docker-f9TV7yVV.js} +1 -1
- package/dist/app/assets/{dot-B8xtegaK.js → dot-CItfl0YH.js} +1 -1
- package/dist/app/assets/{ebnf-oe3GchaY.js → ebnf-4UWkoMwW.js} +1 -1
- package/dist/app/assets/{editorconfig-BcXP_CBv.js → editorconfig-DsQRKuSQ.js} +1 -1
- package/dist/app/assets/{eiffel-2H-hw0_M.js → eiffel-BKzL5tZy.js} +1 -1
- package/dist/app/assets/{ejs-Ba0Dl3hs.js → ejs-FawjQT4F.js} +1 -1
- package/dist/app/assets/{elixir-Zqex1hfd.js → elixir-CYrsCeua.js} +1 -1
- package/dist/app/assets/{elm-BaLOxH54.js → elm-BQbPKl6Y.js} +1 -1
- package/dist/app/assets/{erDiagram-SMLLAGMA-lphP26u7.js → erDiagram-SMLLAGMA-nIXCbdu9.js} +1 -1
- package/dist/app/assets/{erb-D4zKB7vm.js → erb-D8td-3qG.js} +1 -1
- package/dist/app/assets/{erlang-hK3qlNLz.js → erlang-CVcUIOcL.js} +1 -1
- package/dist/app/assets/{etlua-DmORWQ6o.js → etlua-Sp57LMlp.js} +1 -1
- package/dist/app/assets/{excel-formula-Dyve7tHx.js → excel-formula-C2xW1VqS.js} +1 -1
- package/dist/app/assets/{factor-aKN6m8fH.js → factor-B39cYmXr.js} +1 -1
- package/dist/app/assets/{false-CIRDgfm3.js → false-BXc89S7-.js} +1 -1
- package/dist/app/assets/{firestore-security-rules-D8Ht8z5e.js → firestore-security-rules-D5XHnYii.js} +1 -1
- package/dist/app/assets/{flow-CoMa0rFO.js → flow-DvgodFNT.js} +1 -1
- package/dist/app/assets/{flowDiagram-DWJPFMVM-BLg6doOr.js → flowDiagram-DWJPFMVM-BRxtHyqr.js} +1 -1
- package/dist/app/assets/{fortran-CN_uZJ_i.js → fortran-C2uXAnB9.js} +1 -1
- package/dist/app/assets/{fsharp-C9nE9g7s.js → fsharp-D4MeNJsV.js} +1 -1
- package/dist/app/assets/{ftl-DvqhmJFJ.js → ftl-FdK7rzYa.js} +1 -1
- package/dist/app/assets/{ganttDiagram-T4ZO3ILL-20MMEZeq.js → ganttDiagram-T4ZO3ILL-CxQPl5RJ.js} +1 -1
- package/dist/app/assets/{gap-ChJ4bKbS.js → gap-CqoRmA2e.js} +1 -1
- package/dist/app/assets/{gcode-D6-Q_Sls.js → gcode-Cbf6Hq0S.js} +1 -1
- package/dist/app/assets/{gdscript-uy9Z57J0.js → gdscript-vUATu21P.js} +1 -1
- package/dist/app/assets/{gedcom-DKejVBFQ.js → gedcom-Dq_MXb_u.js} +1 -1
- package/dist/app/assets/{gherkin-D309wbrl.js → gherkin-TnW-3H17.js} +1 -1
- package/dist/app/assets/{git-CXyU-4Kx.js → git-ChiXZZK3.js} +1 -1
- package/dist/app/assets/{gitGraphDiagram-UUTBAWPF-CdbhEKk_.js → gitGraphDiagram-UUTBAWPF-Bcj29y1k.js} +1 -1
- package/dist/app/assets/{glsl-CUHcECEi.js → glsl-D73MB7QA.js} +1 -1
- package/dist/app/assets/{gml-BYJwp8Mq.js → gml-DKKhoV5Q.js} +1 -1
- package/dist/app/assets/{gn-C5jDEgl-.js → gn-xteKZDbd.js} +1 -1
- package/dist/app/assets/{go-4DBR4Ukq.js → go-gderB942.js} +1 -1
- package/dist/app/assets/{go-module-BDCY5HMb.js → go-module-Cxdn5g6K.js} +1 -1
- package/dist/app/assets/{graph-CasqcucB.js → graph-Dr0CyUTm.js} +1 -1
- package/dist/app/assets/{graphql-CUOhePaJ.js → graphql-B9ESkh7V.js} +1 -1
- package/dist/app/assets/{groovy-C6NRtaMF.js → groovy-D46SaIaB.js} +1 -1
- package/dist/app/assets/{haml-CeFDFdq_.js → haml-C-gOKeM2.js} +1 -1
- package/dist/app/assets/{handlebars-Diav69MK.js → handlebars-WQgCAz-C.js} +1 -1
- package/dist/app/assets/{haskell-BRtS7ZYk.js → haskell-DZKWHhbK.js} +1 -1
- package/dist/app/assets/{haxe-okolorzn.js → haxe-Do6EdaWm.js} +1 -1
- package/dist/app/assets/{hcl-DUovHBmz.js → hcl-CW6MZD7W.js} +1 -1
- package/dist/app/assets/{hlsl-Est_RcA2.js → hlsl-BYgUfMru.js} +1 -1
- package/dist/app/assets/{hoon-BiOVdLrI.js → hoon-IqFoeyLn.js} +1 -1
- package/dist/app/assets/{hpkp-Bm0WuAFk.js → hpkp-BuV8JDpY.js} +1 -1
- package/dist/app/assets/{hsts-CbOaMMM4.js → hsts-DAvq0I49.js} +1 -1
- package/dist/app/assets/{http-D0tGKTH_.js → http-CCayShZc.js} +1 -1
- package/dist/app/assets/{ichigojam-WTyjHjN0.js → ichigojam-IQlKAhBR.js} +1 -1
- package/dist/app/assets/{icon-Bcw6nO7C.js → icon-C1YOMBEH.js} +1 -1
- package/dist/app/assets/{icu-message-format-1IVITSOw.js → icu-message-format-CbkLI-kP.js} +1 -1
- package/dist/app/assets/{idris-DGiKWxqv.js → idris-Db0sol3G.js} +1 -1
- package/dist/app/assets/{iecst-_G6fk-6o.js → iecst-Rp9pN_Ps.js} +1 -1
- package/dist/app/assets/{ignore-CGGRjy1I.js → ignore-DSijMN4b.js} +1 -1
- package/dist/app/assets/index-EzE2l0pf.css +1 -0
- package/dist/app/assets/{index-BnLZxiSt.js → index-izi7yD-m.js} +176 -176
- package/dist/app/assets/{infoDiagram-42DDH7IO-DNXFcEYI.js → infoDiagram-42DDH7IO-DP_5_HCg.js} +1 -1
- package/dist/app/assets/{inform7-DJNO-7Vs.js → inform7-BdTrQNcW.js} +1 -1
- package/dist/app/assets/{ini-BXxeA4dZ.js → ini-BL1YqQPe.js} +1 -1
- package/dist/app/assets/{io-CZYqA1fa.js → io-ju4qnY4R.js} +1 -1
- package/dist/app/assets/{ishikawaDiagram-UXIWVN3A-1FFzVMOS.js → ishikawaDiagram-UXIWVN3A-c-5weLZu.js} +1 -1
- package/dist/app/assets/{j-CLXGTuej.js → j-BNgG1B_8.js} +1 -1
- package/dist/app/assets/{java-DgCJQY9_.js → java-BBM8kPUi.js} +1 -1
- package/dist/app/assets/{javadoc-rf7ABQVy.js → javadoc-DzqYwIEC.js} +1 -1
- package/dist/app/assets/{javadoclike-BhPYSoi1.js → javadoclike-CXHyoMho.js} +1 -1
- package/dist/app/assets/{javascript-DOESY9kn.js → javascript-DyOtAE59.js} +1 -1
- package/dist/app/assets/{javastacktrace-B40tpYFc.js → javastacktrace-CfTMUgb0.js} +1 -1
- package/dist/app/assets/{jexl-CVSwBfWj.js → jexl-BmCWVTv_.js} +1 -1
- package/dist/app/assets/{jolie-CuMdzw00.js → jolie-C3BdHGrF.js} +1 -1
- package/dist/app/assets/{journeyDiagram-VCZTEJTY-DCh9QB_1.js → journeyDiagram-VCZTEJTY-DAKBW1_0.js} +1 -1
- package/dist/app/assets/{jq-rSPG4wjz.js → jq-B4eKQbVT.js} +1 -1
- package/dist/app/assets/{js-extras-DtC7d85t.js → js-extras-B9Um65g1.js} +1 -1
- package/dist/app/assets/{js-templates-BkzRtF3M.js → js-templates-B8LIGz8d.js} +1 -1
- package/dist/app/assets/{jsdoc-CdEDtKIx.js → jsdoc-X69feyNn.js} +1 -1
- package/dist/app/assets/{json-DFUISOXb.js → json-Ds9Y6npk.js} +1 -1
- package/dist/app/assets/{json5-DDXB8kVt.js → json5-BEpvRyGQ.js} +1 -1
- package/dist/app/assets/{jsonp-B6KceYOu.js → jsonp-CI2Vwglg.js} +1 -1
- package/dist/app/assets/{jsstacktrace-BmLmkRns.js → jsstacktrace-B_qFrkK8.js} +1 -1
- package/dist/app/assets/{jsx-tZerg2PH.js → jsx-C_Wki7pg.js} +1 -1
- package/dist/app/assets/{julia-Bc1WscpO.js → julia-CGmxtkB0.js} +1 -1
- package/dist/app/assets/{kanban-definition-6JOO6SKY-BG2AO71l.js → kanban-definition-6JOO6SKY-Bj8uidJb.js} +1 -1
- package/dist/app/assets/{keepalived-C-VxfNGq.js → keepalived-C8Mk-Wqp.js} +1 -1
- package/dist/app/assets/{keyman-EjQIu4mX.js → keyman-CMifeZZV.js} +1 -1
- package/dist/app/assets/{kotlin-CQALgAA5.js → kotlin-ogZAOqoN.js} +1 -1
- package/dist/app/assets/{kumir-7Nk84McD.js → kumir-BrGxaUVr.js} +1 -1
- package/dist/app/assets/{kusto-DaP91ut7.js → kusto-DeyIYXML.js} +1 -1
- package/dist/app/assets/{latex-DjQNRo9H.js → latex-DwJWQSKl.js} +1 -1
- package/dist/app/assets/{latte-5JEuNRoR.js → latte-DiAT5mgQ.js} +1 -1
- package/dist/app/assets/{layout-FVsf45l9.js → layout-Ci0rB0BF.js} +1 -1
- package/dist/app/assets/{less-8yUOsL09.js → less-DAct2ixG.js} +1 -1
- package/dist/app/assets/{lilypond-COsmQkBk.js → lilypond-CznC99Kp.js} +1 -1
- package/dist/app/assets/{linear-C_63YKi4.js → linear-Db4iWNSq.js} +1 -1
- package/dist/app/assets/{liquid--Ji9gJSD.js → liquid-BxjgrxHp.js} +1 -1
- package/dist/app/assets/{lisp-DuUkFEfd.js → lisp-C4lgit6G.js} +1 -1
- package/dist/app/assets/{livescript-Cs6PchSa.js → livescript-BEQgCon6.js} +1 -1
- package/dist/app/assets/{llvm-COqWFLYS.js → llvm-Xf0jCPO4.js} +1 -1
- package/dist/app/assets/{log-C8QHMZzv.js → log-BiVfEwum.js} +1 -1
- package/dist/app/assets/{lolcode-BIsqHJ6H.js → lolcode-BSO8DuGE.js} +1 -1
- package/dist/app/assets/{lua-Ds7uGUxB.js → lua-DGW916x5.js} +1 -1
- package/dist/app/assets/{magma-DLHoFFMW.js → magma-OhptpZ13.js} +1 -1
- package/dist/app/assets/{makefile-CW_5azpn.js → makefile-DBnxpcUU.js} +1 -1
- package/dist/app/assets/{markdown-wU5DnlD5.js → markdown-BznySwma.js} +1 -1
- package/dist/app/assets/{markup-BjK1nSyh.js → markup-DqRz3LJm.js} +1 -1
- package/dist/app/assets/{markup-templating-CfGV0lcD.js → markup-templating-BKB_GGuz.js} +1 -1
- package/dist/app/assets/{matlab-Bs2eP0LD.js → matlab-3N0TcL6N.js} +1 -1
- package/dist/app/assets/{maxscript-D8jwXiPi.js → maxscript-BZvlaoGH.js} +1 -1
- package/dist/app/assets/{mel-Cmbsj11e.js → mel-BSmK0T7H.js} +1 -1
- package/dist/app/assets/{mermaid-C-cxdm_P.js → mermaid-Duc2qb5F.js} +1 -1
- package/dist/app/assets/{min-BctQ8xDj.js → min-BKNYKdIk.js} +1 -1
- package/dist/app/assets/{mindmap-definition-QFDTVHPH-DHcgEjW6.js → mindmap-definition-QFDTVHPH-CnWL0xVD.js} +1 -1
- package/dist/app/assets/{mizar-Ca1dbNOh.js → mizar-BI02SHrx.js} +1 -1
- package/dist/app/assets/{mongodb-BocaDOlW.js → mongodb-CRQm09Xn.js} +1 -1
- package/dist/app/assets/{monkey-BLhpedmj.js → monkey-Dv34nuh4.js} +1 -1
- package/dist/app/assets/{moonscript-CElpz-Ug.js → moonscript-50xJ2oId.js} +1 -1
- package/dist/app/assets/{n1ql-CwNqjlWA.js → n1ql-Cm4qd43r.js} +1 -1
- package/dist/app/assets/{n4js-B1i6cZX9.js → n4js-LXxDuAtT.js} +1 -1
- package/dist/app/assets/{nand2tetris-hdl-DO01eHXa.js → nand2tetris-hdl-CkSPhEoK.js} +1 -1
- package/dist/app/assets/{naniscript-C86I87cR.js → naniscript-CopSq9dX.js} +1 -1
- package/dist/app/assets/{nasm-X9SuO04-.js → nasm-D7A7rGAF.js} +1 -1
- package/dist/app/assets/{neon-Cb3VrB_2.js → neon-BAKsC02_.js} +1 -1
- package/dist/app/assets/{nevod-BiEf92s6.js → nevod-C-euYOSr.js} +1 -1
- package/dist/app/assets/{nginx-CUAldmyK.js → nginx-B9jALad5.js} +1 -1
- package/dist/app/assets/{nim-CicsGaXu.js → nim-BBHZHQ5E.js} +1 -1
- package/dist/app/assets/{nix-CqX4i_yR.js → nix-DmfkvvNO.js} +1 -1
- package/dist/app/assets/{nsis-TyCoq1Up.js → nsis-CiSC6aDO.js} +1 -1
- package/dist/app/assets/{objectivec-COzECw8M.js → objectivec-CZ2ovZFJ.js} +1 -1
- package/dist/app/assets/{ocaml-CouJ1SZ_.js → ocaml-CyX9uBPK.js} +1 -1
- package/dist/app/assets/{opencl-BNCeQsDQ.js → opencl-BSrZYM8c.js} +1 -1
- package/dist/app/assets/{openqasm-DX-rtDDv.js → openqasm-DOuul9tf.js} +1 -1
- package/dist/app/assets/{oz-CAFaEfY9.js → oz-rsJy_2_r.js} +1 -1
- package/dist/app/assets/{parigp-DTj7bCjF.js → parigp-DMZs3sMP.js} +1 -1
- package/dist/app/assets/{parser-Dw8xYjDE.js → parser-CLeK_wYt.js} +1 -1
- package/dist/app/assets/{pascal-rnwnKrYC.js → pascal-DZ4qTuqN.js} +1 -1
- package/dist/app/assets/{pascaligo-x1XdfDyr.js → pascaligo-D6ziPQJn.js} +1 -1
- package/dist/app/assets/{pcaxis-2ZAgxxTO.js → pcaxis-Bsa4kJ1N.js} +1 -1
- package/dist/app/assets/{peoplecode-pTltM-sq.js → peoplecode-BtULIv-H.js} +1 -1
- package/dist/app/assets/{perl-CdAlw2Ho.js → perl-CswAAlfX.js} +1 -1
- package/dist/app/assets/{php-C2mFD2oC.js → php-Bv-ALqgC.js} +1 -1
- package/dist/app/assets/{php-extras-D7Zt-ImZ.js → php-extras-CGQHigyg.js} +1 -1
- package/dist/app/assets/{phpdoc-C1kmfh9i.js → phpdoc-CbRxSWh6.js} +1 -1
- package/dist/app/assets/{pieDiagram-DEJITSTG-B_eQU9Uk.js → pieDiagram-DEJITSTG-VWWiVQxO.js} +1 -1
- package/dist/app/assets/{plsql-Im5gOG9c.js → plsql-DQRexRDV.js} +1 -1
- package/dist/app/assets/{powerquery-poq2eyPm.js → powerquery-B84pC27o.js} +1 -1
- package/dist/app/assets/{powershell-DJ56nmEi.js → powershell-CYB8PDOS.js} +1 -1
- package/dist/app/assets/{processing-Bn-H7mMf.js → processing-IV7AOKMt.js} +1 -1
- package/dist/app/assets/{prolog-BCb-6dWU.js → prolog-C5Umzi6Y.js} +1 -1
- package/dist/app/assets/{promql-CtbjoMKF.js → promql-DnQb00nJ.js} +1 -1
- package/dist/app/assets/{properties-CU4TDD4l.js → properties-JtX62kym.js} +1 -1
- package/dist/app/assets/{protobuf-_Q2Yj86k.js → protobuf-D0u54vfT.js} +1 -1
- package/dist/app/assets/{psl-DqN21NC_.js → psl-D2wfxc3N.js} +1 -1
- package/dist/app/assets/{pug-DAgKMecD.js → pug-Cfscfbjt.js} +1 -1
- package/dist/app/assets/{puppet-Cc2ljXH1.js → puppet-DTE3iXOW.js} +1 -1
- package/dist/app/assets/{pure-B0x_E1bn.js → pure-YKO-tWRN.js} +1 -1
- package/dist/app/assets/{purebasic-DcsxzNqC.js → purebasic-BjxfhqXa.js} +1 -1
- package/dist/app/assets/{purescript-Cc11iskN.js → purescript-BYtsXeuA.js} +1 -1
- package/dist/app/assets/{q-SRKQXeFP.js → q-BGBZJwiX.js} +1 -1
- package/dist/app/assets/{qml-COWYdH0A.js → qml-DTmpu0_b.js} +1 -1
- package/dist/app/assets/{qore-AdoWA6sw.js → qore-DV3zUzln.js} +1 -1
- package/dist/app/assets/{qsharp-k5lgGfSV.js → qsharp-BB4ZU4l7.js} +1 -1
- package/dist/app/assets/{quadrantDiagram-34T5L4WZ-U_BUH870.js → quadrantDiagram-34T5L4WZ-DZe4FQWm.js} +1 -1
- package/dist/app/assets/{r-Bmcjr3EC.js → r-BuRdYuOg.js} +1 -1
- package/dist/app/assets/{racket-506ZDFuM.js → racket-BdOLCXmL.js} +1 -1
- package/dist/app/assets/{reason-BngsaqkW.js → reason-BCIhgqTr.js} +1 -1
- package/dist/app/assets/{regex-BC6jlFZr.js → regex-CeDcXiBn.js} +1 -1
- package/dist/app/assets/{rego-BYCQ91X3.js → rego-Bug6Gtky.js} +1 -1
- package/dist/app/assets/{renpy-D95h89N9.js → renpy-C1LtsjtW.js} +1 -1
- package/dist/app/assets/{requirementDiagram-MS252O5E-CWAV9Lki.js → requirementDiagram-MS252O5E-BYaMMinK.js} +1 -1
- package/dist/app/assets/{rest-DiYuUdld.js → rest-Fa9SyY67.js} +1 -1
- package/dist/app/assets/{rip-B1Ip8kd2.js → rip-SetkIYoC.js} +1 -1
- package/dist/app/assets/{roboconf-DHaw-Q3G.js → roboconf-CRy7RXFK.js} +1 -1
- package/dist/app/assets/{robotframework-HN9oBCJd.js → robotframework-DHo4R8pp.js} +1 -1
- package/dist/app/assets/{ruby-C42HzAMc.js → ruby-DM2JwZlW.js} +1 -1
- package/dist/app/assets/{rust-DJdUDgl0.js → rust-_NNFafik.js} +1 -1
- package/dist/app/assets/{sankeyDiagram-XADWPNL6-DzoDqMzU.js → sankeyDiagram-XADWPNL6-DAunyA-1.js} +1 -1
- package/dist/app/assets/{sas-EmHkISJg.js → sas-CAllZx8n.js} +1 -1
- package/dist/app/assets/{sass-BEWMjvc2.js → sass-Hf4UBtzK.js} +1 -1
- package/dist/app/assets/{scala-Y9l-QmB_.js → scala-DkNiERTA.js} +1 -1
- package/dist/app/assets/{scheme-oQH0YeM4.js → scheme-cRBlcCac.js} +1 -1
- package/dist/app/assets/{scss-DDqkkzfA.js → scss-D8mZ_Za-.js} +1 -1
- package/dist/app/assets/{sequenceDiagram-FGHM5R23-BRWyyuf5.js → sequenceDiagram-FGHM5R23-sNXmL4Cw.js} +1 -1
- package/dist/app/assets/{shell-session-DUtkYnuZ.js → shell-session-DeKXiekb.js} +1 -1
- package/dist/app/assets/{smali-CQN_R6JD.js → smali-DBMpR0WA.js} +1 -1
- package/dist/app/assets/{smalltalk-C5vveBjr.js → smalltalk-BPhQ9s3z.js} +1 -1
- package/dist/app/assets/{smarty-BF9avlDB.js → smarty-BMg06VgP.js} +1 -1
- package/dist/app/assets/{sml-C_smEF_i.js → sml-DLGSWP51.js} +1 -1
- package/dist/app/assets/{solidity-CsmKUFUp.js → solidity-DeQT3dsc.js} +1 -1
- package/dist/app/assets/{solution-file-5OHlEmXf.js → solution-file-rfNIkT7V.js} +1 -1
- package/dist/app/assets/{soy-DHS0rtw_.js → soy-zYtC6_ht.js} +1 -1
- package/dist/app/assets/{sparql-BxBq3H35.js → sparql-CGa1CKp5.js} +1 -1
- package/dist/app/assets/{splunk-spl-C8VgtuYE.js → splunk-spl-C8v7uxfM.js} +1 -1
- package/dist/app/assets/{sqf-hSDek24H.js → sqf-DPaz1Lai.js} +1 -1
- package/dist/app/assets/{sql-DYgxUZFA.js → sql-CRZBr2wA.js} +1 -1
- package/dist/app/assets/{squirrel-C7uGEJgW.js → squirrel-CrbdCeO4.js} +1 -1
- package/dist/app/assets/{stan-CGYqPG3F.js → stan-BKYvxpSb.js} +1 -1
- package/dist/app/assets/{stateDiagram-FHFEXIEX-Dj_QL8hp.js → stateDiagram-FHFEXIEX-D36OCRvJ.js} +1 -1
- package/dist/app/assets/stateDiagram-v2-QKLJ7IA2-DmqGcWux.js +1 -0
- package/dist/app/assets/{stylus-BCrv-hm1.js → stylus-Ci4_F8nK.js} +1 -1
- package/dist/app/assets/{swift-3XnbN5uB.js → swift-mmkHLTYT.js} +1 -1
- package/dist/app/assets/{systemd-DzUq_PeH.js → systemd-DAUIxyR2.js} +1 -1
- package/dist/app/assets/{t4-cs-DaXmHhdA.js → t4-cs-BED2tz-u.js} +1 -1
- package/dist/app/assets/{t4-templating-C1pqdj2v.js → t4-templating--ieaosVt.js} +1 -1
- package/dist/app/assets/{t4-vb-4wqP1_sy.js → t4-vb-Dq0Puemw.js} +1 -1
- package/dist/app/assets/{tap-FHe0A6pH.js → tap-C_XPd1SR.js} +1 -1
- package/dist/app/assets/{tcl-DlumdfOH.js → tcl-DJZd1oZX.js} +1 -1
- package/dist/app/assets/{textile-BmxrCmib.js → textile-wcSaXbdv.js} +1 -1
- package/dist/app/assets/{timeline-definition-GMOUNBTQ-BcI-XOle.js → timeline-definition-GMOUNBTQ-BewoZYzR.js} +1 -1
- package/dist/app/assets/{toml-BngAbTT7.js → toml-CKDZZOrE.js} +1 -1
- package/dist/app/assets/{tremor-BoVxotcN.js → tremor-B1-Zw3yS.js} +1 -1
- package/dist/app/assets/{tt2-BoBfCiJa.js → tt2-BHFaXCZF.js} +1 -1
- package/dist/app/assets/{turtle-CJfK17BD.js → turtle-KSw4upem.js} +1 -1
- package/dist/app/assets/{twig-BoM58FfM.js → twig-BRBoP8KB.js} +1 -1
- package/dist/app/assets/{typescript-BU7mQ9Me.js → typescript-bns4dUtY.js} +1 -1
- package/dist/app/assets/{typoscript-BQMBCyle.js → typoscript-BVmk6GiM.js} +1 -1
- package/dist/app/assets/{unrealscript-Bly1rszO.js → unrealscript-hTYhevmS.js} +1 -1
- package/dist/app/assets/{uorazor-AR6v804j.js → uorazor-BY_i1glx.js} +1 -1
- package/dist/app/assets/{uri-DQN5AlR9.js → uri-Cshg9KEA.js} +1 -1
- package/dist/app/assets/{v-CzlNjPFF.js → v-2HZBfvBQ.js} +1 -1
- package/dist/app/assets/{vala-D4j-TYUj.js → vala-DpwXQy33.js} +1 -1
- package/dist/app/assets/{vbnet-BO_zrLTA.js → vbnet-CzcanlBM.js} +1 -1
- package/dist/app/assets/{velocity-D14EQjuJ.js → velocity-CV3Erd1R.js} +1 -1
- package/dist/app/assets/{vennDiagram-DHZGUBPP-Ct-BJj4e.js → vennDiagram-DHZGUBPP-CYp9O0hw.js} +1 -1
- package/dist/app/assets/{verilog-8HBCyzJW.js → verilog-DUFfdhmC.js} +1 -1
- package/dist/app/assets/{vhdl-CABoGFHh.js → vhdl-Ehst2swj.js} +1 -1
- package/dist/app/assets/{vim-BqejDUiH.js → vim-ChBxD9-s.js} +1 -1
- package/dist/app/assets/{visual-basic-BBFqe9IH.js → visual-basic-DhxNPprf.js} +1 -1
- package/dist/app/assets/{wardley-RL74JXVD-DF76BHVV.js → wardley-RL74JXVD-ChpRMv2u.js} +1 -1
- package/dist/app/assets/{wardleyDiagram-NUSXRM2D-tb9-DpEL.js → wardleyDiagram-NUSXRM2D-CFpThRE-.js} +1 -1
- package/dist/app/assets/{warpscript-D8JsH2aH.js → warpscript-Dx1Itmpb.js} +1 -1
- package/dist/app/assets/{wasm-usuPS3UI.js → wasm-BvTc7Cyo.js} +1 -1
- package/dist/app/assets/{web-idl-CtjhIrn5.js → web-idl-B43dy8xT.js} +1 -1
- package/dist/app/assets/{wiki-nE7oYJAm.js → wiki-C0vje4IO.js} +1 -1
- package/dist/app/assets/{wolfram-BpCCg-Fp.js → wolfram-B1twTrAy.js} +1 -1
- package/dist/app/assets/{wren-Dtkpodh6.js → wren-CpwJ20dT.js} +1 -1
- package/dist/app/assets/{xeora-BpTlDPdY.js → xeora-Q9elMskQ.js} +1 -1
- package/dist/app/assets/{xml-doc-CcDifcyn.js → xml-doc-eO6FH-U3.js} +1 -1
- package/dist/app/assets/{xojo-O-0SvFwZ.js → xojo-1Fr7QqPR.js} +1 -1
- package/dist/app/assets/{xquery-UAB2jKQB.js → xquery-BMmMoA1b.js} +1 -1
- package/dist/app/assets/{xychartDiagram-5P7HB3ND-d6FXhzUl.js → xychartDiagram-5P7HB3ND-De8Xu1fj.js} +1 -1
- package/dist/app/assets/{yaml-eCAjf2lJ.js → yaml-34lcFD2P.js} +1 -1
- package/dist/app/assets/{yang-BkCZ0omw.js → yang-DervT_oZ.js} +1 -1
- package/dist/app/assets/{zig-DEIPVEHz.js → zig-Cipb22UI.js} +1 -1
- package/dist/app/index.html +2 -2
- package/dist/index.cjs +2298 -648
- package/dist/index.js +2319 -650
- package/package.json +4 -4
- package/dist/app/assets/channel-SVZNtrjN.js +0 -1
- package/dist/app/assets/classDiagram-6PBFFD2Q-BiMmE_Ro.js +0 -1
- package/dist/app/assets/classDiagram-v2-HSJHXN6E-BiMmE_Ro.js +0 -1
- package/dist/app/assets/clone-E2Stvins.js +0 -1
- package/dist/app/assets/index-D58ynlvg.css +0 -1
- package/dist/app/assets/stateDiagram-v2-QKLJ7IA2-BJgU_5Se.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/components/chat.tsx
|
|
2
|
-
import * as
|
|
2
|
+
import * as React26 from "react";
|
|
3
3
|
import {
|
|
4
|
-
ArrowDown,
|
|
4
|
+
ArrowDown as ArrowDown2,
|
|
5
5
|
FileText as FileText2,
|
|
6
6
|
ImageIcon,
|
|
7
|
-
Loader2 as
|
|
7
|
+
Loader2 as Loader24,
|
|
8
8
|
Pencil as Pencil3,
|
|
9
9
|
Quote,
|
|
10
10
|
RefreshCw as RefreshCw2,
|
|
@@ -114,7 +114,10 @@ import {
|
|
|
114
114
|
import "@langchain/core/messages/tool";
|
|
115
115
|
import {
|
|
116
116
|
ChatMessageEventTypeEnum,
|
|
117
|
-
ChatMessageTypeEnum
|
|
117
|
+
ChatMessageTypeEnum,
|
|
118
|
+
REQUEST_USER_INPUT_TOOL_NAME,
|
|
119
|
+
isLangGraphInterruptPayload,
|
|
120
|
+
isClientToolRequest
|
|
118
121
|
} from "@xpert-ai/chatkit-types";
|
|
119
122
|
|
|
120
123
|
// src/lib/api-config.ts
|
|
@@ -646,6 +649,10 @@ function ParentMessengerProvider({
|
|
|
646
649
|
}
|
|
647
650
|
return;
|
|
648
651
|
}
|
|
652
|
+
const requestHumanInput = params.planMode === true || params.state?.[STATE_VARIABLE_HUMAN2]?.planMode === true ? {
|
|
653
|
+
...humanInput,
|
|
654
|
+
planMode: true
|
|
655
|
+
} : humanInput;
|
|
649
656
|
const newMessage = {
|
|
650
657
|
id: createMessageId(),
|
|
651
658
|
type: "human",
|
|
@@ -659,11 +666,11 @@ function ParentMessengerProvider({
|
|
|
659
666
|
const requestOptions = buildInjectedRequestOptions({
|
|
660
667
|
defaults: latestOptionsRef.current?.request,
|
|
661
668
|
state: params.state,
|
|
662
|
-
humanInput
|
|
669
|
+
humanInput: requestHumanInput
|
|
663
670
|
});
|
|
664
671
|
stream?.submit(
|
|
665
672
|
{
|
|
666
|
-
input:
|
|
673
|
+
input: requestHumanInput,
|
|
667
674
|
...requestOptions.state ? { state: requestOptions.state } : {}
|
|
668
675
|
},
|
|
669
676
|
{
|
|
@@ -950,6 +957,7 @@ import {
|
|
|
950
957
|
Globe,
|
|
951
958
|
Images,
|
|
952
959
|
Lightbulb,
|
|
960
|
+
ListChecks,
|
|
953
961
|
Paperclip,
|
|
954
962
|
Pencil,
|
|
955
963
|
Plus,
|
|
@@ -1129,8 +1137,22 @@ var en_US_default = {
|
|
|
1129
1137
|
composer: {
|
|
1130
1138
|
openMenu: "Open menu",
|
|
1131
1139
|
addAttachment: "Add attachment",
|
|
1140
|
+
planMode: "Plan mode",
|
|
1132
1141
|
removeReference: "Remove reference",
|
|
1133
|
-
quoteSelection: "Quote selection"
|
|
1142
|
+
quoteSelection: "Quote selection",
|
|
1143
|
+
requestUserInput: {
|
|
1144
|
+
title: "Input requested",
|
|
1145
|
+
recommended: "Recommended",
|
|
1146
|
+
other: "Other",
|
|
1147
|
+
otherPlaceholder: "Type a custom answer",
|
|
1148
|
+
continue: "Continue",
|
|
1149
|
+
dismiss: "Dismiss",
|
|
1150
|
+
previousQuestion: "Previous question",
|
|
1151
|
+
nextQuestion: "Next question",
|
|
1152
|
+
questionProgress: "{{current}} of {{total}}",
|
|
1153
|
+
optionInfo: "Details for {{label}}",
|
|
1154
|
+
submit: "Continue"
|
|
1155
|
+
}
|
|
1134
1156
|
},
|
|
1135
1157
|
sheet: {
|
|
1136
1158
|
close: "Close"
|
|
@@ -1157,7 +1179,58 @@ var en_US_default = {
|
|
|
1157
1179
|
reasoning: "Reasoning",
|
|
1158
1180
|
loading: "Loading",
|
|
1159
1181
|
thinking: "Thinking",
|
|
1160
|
-
answering: "Answering"
|
|
1182
|
+
answering: "Answering",
|
|
1183
|
+
requestUserInputResult: {
|
|
1184
|
+
title: "Selections confirmed",
|
|
1185
|
+
option: "Option",
|
|
1186
|
+
other: "Other"
|
|
1187
|
+
},
|
|
1188
|
+
toolGroup: {
|
|
1189
|
+
status: {
|
|
1190
|
+
running: "Processing",
|
|
1191
|
+
success: "Processed",
|
|
1192
|
+
fail: "Processing failed"
|
|
1193
|
+
},
|
|
1194
|
+
inputTitle: "Input",
|
|
1195
|
+
outputTitle: "Output",
|
|
1196
|
+
errorTitle: "Error",
|
|
1197
|
+
jsonTitle: "JSON",
|
|
1198
|
+
jsonTree: "Tree",
|
|
1199
|
+
jsonRaw: "Raw",
|
|
1200
|
+
copy: "Copy",
|
|
1201
|
+
copied: "Copied",
|
|
1202
|
+
separator: ", ",
|
|
1203
|
+
categories: {
|
|
1204
|
+
files: {
|
|
1205
|
+
one: "{{count}} file",
|
|
1206
|
+
other: "{{count}} files"
|
|
1207
|
+
},
|
|
1208
|
+
searches: {
|
|
1209
|
+
one: "{{count}} search",
|
|
1210
|
+
other: "{{count}} searches"
|
|
1211
|
+
},
|
|
1212
|
+
commands: {
|
|
1213
|
+
one: "{{count}} command",
|
|
1214
|
+
other: "{{count}} commands"
|
|
1215
|
+
},
|
|
1216
|
+
lists: {
|
|
1217
|
+
one: "{{count}} list",
|
|
1218
|
+
other: "{{count}} lists"
|
|
1219
|
+
},
|
|
1220
|
+
tasks: {
|
|
1221
|
+
one: "{{count}} task",
|
|
1222
|
+
other: "{{count}} tasks"
|
|
1223
|
+
},
|
|
1224
|
+
knowledges: {
|
|
1225
|
+
one: "{{count}} knowledge result",
|
|
1226
|
+
other: "{{count}} knowledge results"
|
|
1227
|
+
},
|
|
1228
|
+
tools: {
|
|
1229
|
+
one: "{{count}} tool",
|
|
1230
|
+
other: "{{count}} tools"
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1161
1234
|
}
|
|
1162
1235
|
};
|
|
1163
1236
|
|
|
@@ -1236,8 +1309,22 @@ var zh_CN_default = {
|
|
|
1236
1309
|
composer: {
|
|
1237
1310
|
openMenu: "\u6253\u5F00\u83DC\u5355",
|
|
1238
1311
|
addAttachment: "\u6DFB\u52A0\u9644\u4EF6",
|
|
1312
|
+
planMode: "\u8BA1\u5212\u6A21\u5F0F",
|
|
1239
1313
|
removeReference: "\u79FB\u9664\u5F15\u7528",
|
|
1240
|
-
quoteSelection: "\u5F15\u7528\u9009\u4E2D\u5185\u5BB9"
|
|
1314
|
+
quoteSelection: "\u5F15\u7528\u9009\u4E2D\u5185\u5BB9",
|
|
1315
|
+
requestUserInput: {
|
|
1316
|
+
title: "\u9700\u8981\u4F60\u7684\u8F93\u5165",
|
|
1317
|
+
recommended: "\u63A8\u8350",
|
|
1318
|
+
other: "\u5176\u4ED6",
|
|
1319
|
+
otherPlaceholder: "\u8F93\u5165\u81EA\u5B9A\u4E49\u56DE\u7B54",
|
|
1320
|
+
continue: "\u7EE7\u7EED",
|
|
1321
|
+
dismiss: "\u5173\u95ED",
|
|
1322
|
+
previousQuestion: "\u4E0A\u4E00\u4E2A\u95EE\u9898",
|
|
1323
|
+
nextQuestion: "\u4E0B\u4E00\u4E2A\u95EE\u9898",
|
|
1324
|
+
questionProgress: "{{current}} / {{total}}",
|
|
1325
|
+
optionInfo: "{{label}} \u7684\u8BF4\u660E",
|
|
1326
|
+
submit: "\u7EE7\u7EED"
|
|
1327
|
+
}
|
|
1241
1328
|
},
|
|
1242
1329
|
sheet: {
|
|
1243
1330
|
close: "\u5173\u95ED"
|
|
@@ -1264,7 +1351,58 @@ var zh_CN_default = {
|
|
|
1264
1351
|
reasoning: "\u63A8\u7406",
|
|
1265
1352
|
loading: "\u6B63\u5728\u52A0\u8F7D",
|
|
1266
1353
|
thinking: "\u6B63\u5728\u601D\u8003",
|
|
1267
|
-
answering: "\u6B63\u5728\u751F\u6210"
|
|
1354
|
+
answering: "\u6B63\u5728\u751F\u6210",
|
|
1355
|
+
requestUserInputResult: {
|
|
1356
|
+
title: "\u5DF2\u786E\u8BA4\u9009\u62E9",
|
|
1357
|
+
option: "\u9009\u9879",
|
|
1358
|
+
other: "\u5176\u4ED6"
|
|
1359
|
+
},
|
|
1360
|
+
toolGroup: {
|
|
1361
|
+
status: {
|
|
1362
|
+
running: "\u6B63\u5728\u5904\u7406",
|
|
1363
|
+
success: "\u5DF2\u5904\u7406",
|
|
1364
|
+
fail: "\u5904\u7406\u5931\u8D25"
|
|
1365
|
+
},
|
|
1366
|
+
inputTitle: "\u8F93\u5165",
|
|
1367
|
+
outputTitle: "\u8F93\u51FA",
|
|
1368
|
+
errorTitle: "\u9519\u8BEF",
|
|
1369
|
+
jsonTitle: "JSON",
|
|
1370
|
+
jsonTree: "\u6811\u5F62",
|
|
1371
|
+
jsonRaw: "\u539F\u59CB",
|
|
1372
|
+
copy: "\u590D\u5236",
|
|
1373
|
+
copied: "\u5DF2\u590D\u5236",
|
|
1374
|
+
separator: "\uFF0C",
|
|
1375
|
+
categories: {
|
|
1376
|
+
files: {
|
|
1377
|
+
one: "{{count}} \u4E2A\u6587\u4EF6",
|
|
1378
|
+
other: "{{count}} \u4E2A\u6587\u4EF6"
|
|
1379
|
+
},
|
|
1380
|
+
searches: {
|
|
1381
|
+
one: "{{count}} \u4E2A\u641C\u7D22",
|
|
1382
|
+
other: "{{count}} \u4E2A\u641C\u7D22"
|
|
1383
|
+
},
|
|
1384
|
+
commands: {
|
|
1385
|
+
one: "{{count}} \u4E2A\u547D\u4EE4",
|
|
1386
|
+
other: "{{count}} \u4E2A\u547D\u4EE4"
|
|
1387
|
+
},
|
|
1388
|
+
lists: {
|
|
1389
|
+
one: "{{count}} \u4E2A\u5217\u8868",
|
|
1390
|
+
other: "{{count}} \u4E2A\u5217\u8868"
|
|
1391
|
+
},
|
|
1392
|
+
tasks: {
|
|
1393
|
+
one: "{{count}} \u4E2A\u4EFB\u52A1",
|
|
1394
|
+
other: "{{count}} \u4E2A\u4EFB\u52A1"
|
|
1395
|
+
},
|
|
1396
|
+
knowledges: {
|
|
1397
|
+
one: "{{count}} \u4E2A\u77E5\u8BC6\u7ED3\u679C",
|
|
1398
|
+
other: "{{count}} \u4E2A\u77E5\u8BC6\u7ED3\u679C"
|
|
1399
|
+
},
|
|
1400
|
+
tools: {
|
|
1401
|
+
one: "{{count}} \u4E2A\u5DE5\u5177\u8C03\u7528",
|
|
1402
|
+
other: "{{count}} \u4E2A\u5DE5\u5177\u8C03\u7528"
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1268
1406
|
}
|
|
1269
1407
|
};
|
|
1270
1408
|
|
|
@@ -1700,6 +1838,8 @@ function ComposerMenu({
|
|
|
1700
1838
|
onAttachmentClick,
|
|
1701
1839
|
onToolSelect,
|
|
1702
1840
|
selectedTool,
|
|
1841
|
+
planModeEnabled = false,
|
|
1842
|
+
onPlanModeChange,
|
|
1703
1843
|
disabled = false
|
|
1704
1844
|
}) {
|
|
1705
1845
|
const { t } = useChatkitTranslation();
|
|
@@ -1708,9 +1848,6 @@ function ComposerMenu({
|
|
|
1708
1848
|
const roundedClass = getRoundedClass(theme.radius);
|
|
1709
1849
|
const attachmentsEnabled = composer?.attachments?.enabled ?? false;
|
|
1710
1850
|
const tools = composer?.tools ?? [];
|
|
1711
|
-
if (!attachmentsEnabled && tools.length === 0) {
|
|
1712
|
-
return null;
|
|
1713
|
-
}
|
|
1714
1851
|
const handleAttachmentClick = () => {
|
|
1715
1852
|
onAttachmentClick?.();
|
|
1716
1853
|
setOpen(false);
|
|
@@ -1719,6 +1856,9 @@ function ComposerMenu({
|
|
|
1719
1856
|
onToolSelect?.(tool);
|
|
1720
1857
|
setOpen(false);
|
|
1721
1858
|
};
|
|
1859
|
+
const handlePlanModeToggle = () => {
|
|
1860
|
+
onPlanModeChange?.(!planModeEnabled);
|
|
1861
|
+
};
|
|
1722
1862
|
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
1723
1863
|
/* @__PURE__ */ jsx6(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
1724
1864
|
Button,
|
|
@@ -1758,8 +1898,46 @@ function ComposerMenu({
|
|
|
1758
1898
|
]
|
|
1759
1899
|
}
|
|
1760
1900
|
),
|
|
1761
|
-
|
|
1901
|
+
/* @__PURE__ */ jsx6("div", { className: "my-1 h-px bg-border" })
|
|
1762
1902
|
] }),
|
|
1903
|
+
/* @__PURE__ */ jsxs(
|
|
1904
|
+
"button",
|
|
1905
|
+
{
|
|
1906
|
+
type: "button",
|
|
1907
|
+
role: "switch",
|
|
1908
|
+
"aria-checked": planModeEnabled,
|
|
1909
|
+
onClick: handlePlanModeToggle,
|
|
1910
|
+
className: cn(
|
|
1911
|
+
"flex items-center gap-3 px-3 py-2 text-sm hover:bg-muted transition-colors",
|
|
1912
|
+
roundedClass,
|
|
1913
|
+
planModeEnabled && "bg-muted"
|
|
1914
|
+
),
|
|
1915
|
+
children: [
|
|
1916
|
+
/* @__PURE__ */ jsx6("span", { className: "flex h-6 w-6 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsx6(ListChecks, { size: 16 }) }),
|
|
1917
|
+
/* @__PURE__ */ jsx6("span", { className: "min-w-0 flex-1 text-left", children: t("composer.planMode") }),
|
|
1918
|
+
/* @__PURE__ */ jsx6(
|
|
1919
|
+
"span",
|
|
1920
|
+
{
|
|
1921
|
+
className: cn(
|
|
1922
|
+
"relative inline-flex h-6 w-10 shrink-0 items-center rounded-full transition-colors",
|
|
1923
|
+
planModeEnabled ? "bg-primary" : "bg-muted-foreground/20"
|
|
1924
|
+
),
|
|
1925
|
+
"aria-hidden": "true",
|
|
1926
|
+
children: /* @__PURE__ */ jsx6(
|
|
1927
|
+
"span",
|
|
1928
|
+
{
|
|
1929
|
+
className: cn(
|
|
1930
|
+
"inline-block h-5 w-5 rounded-full bg-background shadow-sm transition-transform",
|
|
1931
|
+
planModeEnabled ? "translate-x-[18px]" : "translate-x-0.5"
|
|
1932
|
+
)
|
|
1933
|
+
}
|
|
1934
|
+
)
|
|
1935
|
+
}
|
|
1936
|
+
)
|
|
1937
|
+
]
|
|
1938
|
+
}
|
|
1939
|
+
),
|
|
1940
|
+
tools.length > 0 && /* @__PURE__ */ jsx6("div", { className: "my-1 h-px bg-border" }),
|
|
1763
1941
|
tools.map((tool) => /* @__PURE__ */ jsxs(
|
|
1764
1942
|
"button",
|
|
1765
1943
|
{
|
|
@@ -2082,19 +2260,23 @@ function HistorySidebar({
|
|
|
2082
2260
|
setOpen(false);
|
|
2083
2261
|
};
|
|
2084
2262
|
return /* @__PURE__ */ jsxs6(Sheet, { open, onOpenChange: setOpen, children: [
|
|
2085
|
-
/* @__PURE__ */
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2263
|
+
/* @__PURE__ */ jsxs6(Tooltip, { children: [
|
|
2264
|
+
/* @__PURE__ */ jsx11(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx11("span", { className: "inline-flex h-8 w-8", children: /* @__PURE__ */ jsx11(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsxs6(
|
|
2265
|
+
Button,
|
|
2266
|
+
{
|
|
2267
|
+
variant: "ghost",
|
|
2268
|
+
size: "icon",
|
|
2269
|
+
disabled,
|
|
2270
|
+
className: "h-8 w-8 cursor-pointer",
|
|
2271
|
+
"aria-label": t("history.threadHistory"),
|
|
2272
|
+
children: [
|
|
2273
|
+
/* @__PURE__ */ jsx11(History, { size: 16 }),
|
|
2274
|
+
/* @__PURE__ */ jsx11("span", { className: "sr-only", children: t("history.threadHistory") })
|
|
2275
|
+
]
|
|
2276
|
+
}
|
|
2277
|
+
) }) }) }),
|
|
2278
|
+
/* @__PURE__ */ jsx11(TooltipContent, { side: "bottom", children: t("history.threadHistory") })
|
|
2279
|
+
] }),
|
|
2098
2280
|
/* @__PURE__ */ jsxs6(SheetContent, { side: "right", className: "w-80 p-0", children: [
|
|
2099
2281
|
/* @__PURE__ */ jsx11(SheetHeader, { className: "border-b p-4", children: /* @__PURE__ */ jsx11(SheetTitle, { children: t("history.title") }) }),
|
|
2100
2282
|
/* @__PURE__ */ jsx11("div", { className: "p-4", children: /* @__PURE__ */ jsxs6(
|
|
@@ -2571,173 +2753,797 @@ function PendingTodos({
|
|
|
2571
2753
|
);
|
|
2572
2754
|
}
|
|
2573
2755
|
|
|
2574
|
-
// src/components/
|
|
2575
|
-
import * as
|
|
2756
|
+
// src/components/composer/request-user-input-panel.tsx
|
|
2757
|
+
import * as React12 from "react";
|
|
2576
2758
|
import {
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2759
|
+
ArrowDown,
|
|
2760
|
+
ArrowUp as ArrowUp2,
|
|
2761
|
+
Check,
|
|
2762
|
+
ChevronLeft,
|
|
2763
|
+
ChevronRight,
|
|
2764
|
+
CornerDownLeft as CornerDownLeft2,
|
|
2765
|
+
Info as Info2
|
|
2582
2766
|
} from "lucide-react";
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
)
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2767
|
+
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2768
|
+
function useRoundedClasses3() {
|
|
2769
|
+
const { theme } = useTheme();
|
|
2770
|
+
const density = theme.density ?? "normal";
|
|
2771
|
+
const densityClasses = {
|
|
2772
|
+
compact: {
|
|
2773
|
+
section: "px-3.5 py-2",
|
|
2774
|
+
eyebrow: "mb-0 text-[11px]",
|
|
2775
|
+
title: "text-[15px] leading-5",
|
|
2776
|
+
pager: "gap-1.5 text-xs",
|
|
2777
|
+
pagerButton: "h-6 w-6",
|
|
2778
|
+
pagerIcon: "h-3.5 w-3.5",
|
|
2779
|
+
choices: "mt-2.5 space-y-0.5",
|
|
2780
|
+
row: "min-h-8 grid-cols-[28px_minmax(0,1fr)_auto] gap-2 px-2.5 py-1",
|
|
2781
|
+
otherRow: "min-h-8 grid-cols-[28px_minmax(0,1fr)] gap-2 px-2.5 py-1",
|
|
2782
|
+
input: "h-6",
|
|
2783
|
+
footer: "mt-2.5 gap-2",
|
|
2784
|
+
dismissButton: "h-7",
|
|
2785
|
+
continueButton: "h-8 px-3.5",
|
|
2786
|
+
continueIcon: "h-5 min-w-5"
|
|
2787
|
+
},
|
|
2788
|
+
normal: {
|
|
2789
|
+
section: "px-4 py-2.5",
|
|
2790
|
+
eyebrow: "mb-0.5 text-xs",
|
|
2791
|
+
title: "text-base leading-5",
|
|
2792
|
+
pager: "gap-2 text-sm",
|
|
2793
|
+
pagerButton: "h-7 w-7",
|
|
2794
|
+
pagerIcon: "h-4 w-4",
|
|
2795
|
+
choices: "mt-3 space-y-0.5",
|
|
2796
|
+
row: "min-h-9 grid-cols-[30px_minmax(0,1fr)_auto] gap-2.5 px-2.5 py-1.5",
|
|
2797
|
+
otherRow: "min-h-9 grid-cols-[30px_minmax(0,1fr)] gap-2.5 px-2.5 py-1.5",
|
|
2798
|
+
input: "h-6",
|
|
2799
|
+
footer: "mt-3 gap-3",
|
|
2800
|
+
dismissButton: "h-7",
|
|
2801
|
+
continueButton: "h-8 px-4",
|
|
2802
|
+
continueIcon: "h-5 min-w-5"
|
|
2803
|
+
},
|
|
2804
|
+
spacious: {
|
|
2805
|
+
section: "px-5 py-3",
|
|
2806
|
+
eyebrow: "mb-0.5 text-xs",
|
|
2807
|
+
title: "text-base leading-5",
|
|
2808
|
+
pager: "gap-2 text-sm",
|
|
2809
|
+
pagerButton: "h-7 w-7",
|
|
2810
|
+
pagerIcon: "h-4 w-4",
|
|
2811
|
+
choices: "mt-4 space-y-1",
|
|
2812
|
+
row: "min-h-10 grid-cols-[32px_minmax(0,1fr)_auto] gap-3 px-3 py-2",
|
|
2813
|
+
otherRow: "min-h-10 grid-cols-[32px_minmax(0,1fr)] gap-3 px-3 py-2",
|
|
2814
|
+
input: "h-7",
|
|
2815
|
+
footer: "mt-4 gap-3",
|
|
2816
|
+
dismissButton: "h-8",
|
|
2817
|
+
continueButton: "h-9 px-4",
|
|
2818
|
+
continueIcon: "h-5 min-w-5"
|
|
2613
2819
|
}
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
function
|
|
2643
|
-
const
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
(
|
|
2647
|
-
|
|
2648
|
-
|
|
2820
|
+
}[density] ?? {
|
|
2821
|
+
section: "px-4 py-2.5",
|
|
2822
|
+
eyebrow: "mb-0.5 text-xs",
|
|
2823
|
+
title: "text-base leading-5",
|
|
2824
|
+
pager: "gap-2 text-sm",
|
|
2825
|
+
pagerButton: "h-7 w-7",
|
|
2826
|
+
pagerIcon: "h-4 w-4",
|
|
2827
|
+
choices: "mt-3 space-y-0.5",
|
|
2828
|
+
row: "min-h-9 grid-cols-[30px_minmax(0,1fr)_auto] gap-2.5 px-2.5 py-1.5",
|
|
2829
|
+
otherRow: "min-h-9 grid-cols-[30px_minmax(0,1fr)] gap-2.5 px-2.5 py-1.5",
|
|
2830
|
+
input: "h-6",
|
|
2831
|
+
footer: "mt-3 gap-3",
|
|
2832
|
+
dismissButton: "h-7",
|
|
2833
|
+
continueButton: "h-8 px-4",
|
|
2834
|
+
continueIcon: "h-5 min-w-5"
|
|
2835
|
+
};
|
|
2836
|
+
return {
|
|
2837
|
+
top: theme.radius ? {
|
|
2838
|
+
pill: "rounded-t-3xl",
|
|
2839
|
+
round: "rounded-t-xl",
|
|
2840
|
+
soft: "rounded-t-lg",
|
|
2841
|
+
sharp: "rounded-t-none"
|
|
2842
|
+
}[theme.radius] : "rounded-t-lg",
|
|
2843
|
+
panel: getRoundedClass(theme.radius, "rounded-lg"),
|
|
2844
|
+
control: getRoundedClass(theme.radius, "rounded-md"),
|
|
2845
|
+
density: densityClasses
|
|
2846
|
+
};
|
|
2847
|
+
}
|
|
2848
|
+
function parseRecommendedLabel(label) {
|
|
2849
|
+
const recommendedPattern = /\s*(?:\((?:recommended)\)|(推荐))\s*$/i;
|
|
2850
|
+
return {
|
|
2851
|
+
label: label.replace(recommendedPattern, "").trim() || label,
|
|
2852
|
+
recommended: recommendedPattern.test(label)
|
|
2853
|
+
};
|
|
2854
|
+
}
|
|
2855
|
+
function getAnswerForQuestion(question, draft) {
|
|
2856
|
+
if (!draft) return null;
|
|
2857
|
+
if (draft.type === "other") {
|
|
2858
|
+
const value = draft.otherText.trim();
|
|
2859
|
+
if (!value) return null;
|
|
2860
|
+
return {
|
|
2861
|
+
id: question.id,
|
|
2862
|
+
question: question.question,
|
|
2863
|
+
type: "other",
|
|
2864
|
+
value
|
|
2865
|
+
};
|
|
2866
|
+
}
|
|
2867
|
+
const option = question.options[draft.optionIndex];
|
|
2868
|
+
if (!option) return null;
|
|
2869
|
+
return {
|
|
2870
|
+
id: question.id,
|
|
2871
|
+
question: question.question,
|
|
2872
|
+
type: "option",
|
|
2873
|
+
value: option.label,
|
|
2874
|
+
label: option.label,
|
|
2875
|
+
description: option.description
|
|
2876
|
+
};
|
|
2877
|
+
}
|
|
2878
|
+
function getSelectedChoiceIndex(question, draft) {
|
|
2879
|
+
if (!draft) return -1;
|
|
2880
|
+
if (draft.type === "other") return question.options.length;
|
|
2881
|
+
return draft.optionIndex;
|
|
2882
|
+
}
|
|
2883
|
+
function RequestUserInputPanel({
|
|
2884
|
+
request,
|
|
2885
|
+
onSubmit,
|
|
2886
|
+
onDismiss,
|
|
2887
|
+
attachToComposer = true,
|
|
2888
|
+
className
|
|
2889
|
+
}) {
|
|
2890
|
+
const { t } = useChatkitTranslation();
|
|
2891
|
+
const rounded = useRoundedClasses3();
|
|
2892
|
+
const [drafts, setDrafts] = React12.useState({});
|
|
2893
|
+
const [currentQuestionIndex, setCurrentQuestionIndex] = React12.useState(0);
|
|
2894
|
+
const otherInputRef = React12.useRef(null);
|
|
2895
|
+
const questions = request?.params.questions ?? [];
|
|
2896
|
+
React12.useEffect(() => {
|
|
2897
|
+
setDrafts({});
|
|
2898
|
+
setCurrentQuestionIndex(0);
|
|
2899
|
+
}, [request?.id]);
|
|
2900
|
+
React12.useEffect(() => {
|
|
2901
|
+
if (questions.length === 0) return;
|
|
2902
|
+
setCurrentQuestionIndex(
|
|
2903
|
+
(index) => Math.min(Math.max(index, 0), questions.length - 1)
|
|
2904
|
+
);
|
|
2905
|
+
}, [questions.length]);
|
|
2906
|
+
const setQuestionDraft = React12.useCallback(
|
|
2907
|
+
(questionId, draft) => {
|
|
2908
|
+
setDrafts((previous) => ({
|
|
2909
|
+
...previous,
|
|
2910
|
+
[questionId]: draft
|
|
2911
|
+
}));
|
|
2649
2912
|
},
|
|
2650
|
-
[
|
|
2913
|
+
[]
|
|
2651
2914
|
);
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
)
|
|
2663
|
-
|
|
2664
|
-
|
|
2915
|
+
const focusOtherInput = React12.useCallback(() => {
|
|
2916
|
+
window.setTimeout(() => otherInputRef.current?.focus(), 0);
|
|
2917
|
+
}, []);
|
|
2918
|
+
const selectOption = React12.useCallback(
|
|
2919
|
+
(question, optionIndex) => {
|
|
2920
|
+
const previousDraft = drafts[question.id];
|
|
2921
|
+
setQuestionDraft(question.id, {
|
|
2922
|
+
type: "option",
|
|
2923
|
+
optionIndex,
|
|
2924
|
+
otherText: previousDraft?.otherText ?? ""
|
|
2925
|
+
});
|
|
2926
|
+
},
|
|
2927
|
+
[drafts, setQuestionDraft]
|
|
2928
|
+
);
|
|
2929
|
+
const selectOther = React12.useCallback(
|
|
2930
|
+
(question, otherText2) => {
|
|
2931
|
+
const previousDraft = drafts[question.id];
|
|
2932
|
+
setQuestionDraft(question.id, {
|
|
2933
|
+
type: "other",
|
|
2934
|
+
otherText: otherText2 ?? (previousDraft?.type === "other" ? previousDraft.otherText : previousDraft?.otherText) ?? ""
|
|
2935
|
+
});
|
|
2936
|
+
focusOtherInput();
|
|
2937
|
+
},
|
|
2938
|
+
[drafts, focusOtherInput, setQuestionDraft]
|
|
2939
|
+
);
|
|
2940
|
+
const goToQuestion = React12.useCallback(
|
|
2941
|
+
(index) => {
|
|
2942
|
+
if (questions.length === 0) return;
|
|
2943
|
+
setCurrentQuestionIndex(
|
|
2944
|
+
Math.min(Math.max(index, 0), questions.length - 1)
|
|
2945
|
+
);
|
|
2946
|
+
},
|
|
2947
|
+
[questions.length]
|
|
2948
|
+
);
|
|
2949
|
+
const answers = React12.useMemo(
|
|
2950
|
+
() => questions.map((question) => getAnswerForQuestion(question, drafts[question.id])).filter((answer) => Boolean(answer)),
|
|
2951
|
+
[drafts, questions]
|
|
2952
|
+
);
|
|
2953
|
+
const canSubmit = answers.length === questions.length;
|
|
2954
|
+
const currentQuestion = questions[currentQuestionIndex] ?? null;
|
|
2955
|
+
const currentDraft = currentQuestion ? drafts[currentQuestion.id] : void 0;
|
|
2956
|
+
const currentAnswer = currentQuestion ? getAnswerForQuestion(currentQuestion, currentDraft) : null;
|
|
2957
|
+
const isLastQuestion = currentQuestionIndex === questions.length - 1;
|
|
2958
|
+
const buildAnswersFromDrafts = React12.useCallback(
|
|
2959
|
+
(nextDrafts) => questions.map((question) => getAnswerForQuestion(question, nextDrafts[question.id])).filter((answer) => Boolean(answer)),
|
|
2960
|
+
[questions]
|
|
2961
|
+
);
|
|
2962
|
+
const submitOrFocusFirstMissing = React12.useCallback(
|
|
2963
|
+
(nextDrafts) => {
|
|
2964
|
+
const nextAnswers = buildAnswersFromDrafts(nextDrafts);
|
|
2965
|
+
if (nextAnswers.length === questions.length) {
|
|
2966
|
+
onSubmit(nextAnswers);
|
|
2967
|
+
return;
|
|
2968
|
+
}
|
|
2969
|
+
const firstMissingIndex = questions.findIndex(
|
|
2970
|
+
(question) => !getAnswerForQuestion(question, nextDrafts[question.id])
|
|
2971
|
+
);
|
|
2972
|
+
if (firstMissingIndex >= 0) {
|
|
2973
|
+
goToQuestion(firstMissingIndex);
|
|
2974
|
+
}
|
|
2975
|
+
},
|
|
2976
|
+
[buildAnswersFromDrafts, goToQuestion, onSubmit, questions]
|
|
2977
|
+
);
|
|
2978
|
+
const activateOption = React12.useCallback(
|
|
2979
|
+
(question, optionIndex) => {
|
|
2980
|
+
const previousDraft = drafts[question.id];
|
|
2981
|
+
const nextDrafts = {
|
|
2982
|
+
...drafts,
|
|
2983
|
+
[question.id]: {
|
|
2984
|
+
type: "option",
|
|
2985
|
+
optionIndex,
|
|
2986
|
+
otherText: previousDraft?.otherText ?? ""
|
|
2987
|
+
}
|
|
2988
|
+
};
|
|
2989
|
+
setDrafts(nextDrafts);
|
|
2990
|
+
if (isLastQuestion) {
|
|
2991
|
+
submitOrFocusFirstMissing(nextDrafts);
|
|
2992
|
+
return;
|
|
2993
|
+
}
|
|
2994
|
+
goToQuestion(currentQuestionIndex + 1);
|
|
2995
|
+
},
|
|
2996
|
+
[
|
|
2997
|
+
currentQuestionIndex,
|
|
2998
|
+
drafts,
|
|
2999
|
+
goToQuestion,
|
|
3000
|
+
isLastQuestion,
|
|
3001
|
+
submitOrFocusFirstMissing
|
|
3002
|
+
]
|
|
3003
|
+
);
|
|
3004
|
+
const chooseChoiceByIndex = React12.useCallback(
|
|
3005
|
+
(choiceIndex) => {
|
|
3006
|
+
if (!currentQuestion) return;
|
|
3007
|
+
if (choiceIndex < 0) return;
|
|
3008
|
+
if (choiceIndex < currentQuestion.options.length) {
|
|
3009
|
+
selectOption(currentQuestion, choiceIndex);
|
|
3010
|
+
return;
|
|
3011
|
+
}
|
|
3012
|
+
if (choiceIndex === currentQuestion.options.length) {
|
|
3013
|
+
selectOther(currentQuestion);
|
|
3014
|
+
}
|
|
3015
|
+
},
|
|
3016
|
+
[currentQuestion, selectOption, selectOther]
|
|
3017
|
+
);
|
|
3018
|
+
const moveCurrentChoice = React12.useCallback(
|
|
3019
|
+
(direction) => {
|
|
3020
|
+
if (!currentQuestion) return;
|
|
3021
|
+
const choiceCount = currentQuestion.options.length + 1;
|
|
3022
|
+
const currentIndex = getSelectedChoiceIndex(currentQuestion, currentDraft);
|
|
3023
|
+
const nextIndex = currentIndex === -1 ? direction === 1 ? 0 : choiceCount - 1 : (currentIndex + direction + choiceCount) % choiceCount;
|
|
3024
|
+
chooseChoiceByIndex(nextIndex);
|
|
3025
|
+
},
|
|
3026
|
+
[chooseChoiceByIndex, currentDraft, currentQuestion]
|
|
3027
|
+
);
|
|
3028
|
+
const handleContinue = React12.useCallback(() => {
|
|
3029
|
+
if (!currentAnswer) return;
|
|
3030
|
+
if (!isLastQuestion) {
|
|
3031
|
+
goToQuestion(currentQuestionIndex + 1);
|
|
3032
|
+
return;
|
|
2665
3033
|
}
|
|
2666
|
-
|
|
2667
|
-
);
|
|
2668
|
-
|
|
2669
|
-
var TabsTrigger = React14.forwardRef(
|
|
2670
|
-
({ className, value, onClick, ...props }, ref) => {
|
|
2671
|
-
const context = React14.useContext(TabsContext);
|
|
2672
|
-
if (!context) {
|
|
2673
|
-
throw new Error("TabsTrigger must be used within Tabs");
|
|
3034
|
+
if (canSubmit) {
|
|
3035
|
+
onSubmit(answers);
|
|
3036
|
+
return;
|
|
2674
3037
|
}
|
|
2675
|
-
const
|
|
2676
|
-
|
|
2677
|
-
"button",
|
|
2678
|
-
{
|
|
2679
|
-
ref,
|
|
2680
|
-
type: "button",
|
|
2681
|
-
role: "tab",
|
|
2682
|
-
"aria-selected": isActive,
|
|
2683
|
-
"data-state": isActive ? "active" : "inactive",
|
|
2684
|
-
className: cn(
|
|
2685
|
-
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
|
|
2686
|
-
className
|
|
2687
|
-
),
|
|
2688
|
-
onClick: (event) => {
|
|
2689
|
-
context.setValue(value);
|
|
2690
|
-
onClick?.(event);
|
|
2691
|
-
},
|
|
2692
|
-
...props
|
|
2693
|
-
}
|
|
3038
|
+
const firstMissingIndex = questions.findIndex(
|
|
3039
|
+
(question) => !getAnswerForQuestion(question, drafts[question.id])
|
|
2694
3040
|
);
|
|
2695
|
-
|
|
2696
|
-
);
|
|
2697
|
-
TabsTrigger.displayName = "TabsTrigger";
|
|
2698
|
-
var TabsContent = React14.forwardRef(
|
|
2699
|
-
({ className, value, ...props }, ref) => {
|
|
2700
|
-
const context = React14.useContext(TabsContext);
|
|
2701
|
-
if (!context) {
|
|
2702
|
-
throw new Error("TabsContent must be used within Tabs");
|
|
3041
|
+
if (firstMissingIndex >= 0) {
|
|
3042
|
+
goToQuestion(firstMissingIndex);
|
|
2703
3043
|
}
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
3044
|
+
}, [
|
|
3045
|
+
answers,
|
|
3046
|
+
canSubmit,
|
|
3047
|
+
currentAnswer,
|
|
3048
|
+
currentQuestionIndex,
|
|
3049
|
+
drafts,
|
|
3050
|
+
goToQuestion,
|
|
3051
|
+
isLastQuestion,
|
|
3052
|
+
onSubmit,
|
|
3053
|
+
questions
|
|
3054
|
+
]);
|
|
3055
|
+
React12.useEffect(() => {
|
|
3056
|
+
if (!request) return;
|
|
3057
|
+
const handleKeyDown = (event) => {
|
|
3058
|
+
if (event.isComposing) return;
|
|
3059
|
+
const target = event.target;
|
|
3060
|
+
const targetTag = target?.tagName;
|
|
3061
|
+
const isTypingTarget = target?.isContentEditable || targetTag === "INPUT" || targetTag === "TEXTAREA" || targetTag === "SELECT";
|
|
3062
|
+
if (event.key === "Escape" || event.key === "Esc") {
|
|
3063
|
+
if (onDismiss) {
|
|
3064
|
+
event.preventDefault();
|
|
3065
|
+
onDismiss();
|
|
3066
|
+
}
|
|
3067
|
+
return;
|
|
2715
3068
|
}
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
3069
|
+
if (isTypingTarget && event.key !== "Enter") {
|
|
3070
|
+
return;
|
|
3071
|
+
}
|
|
3072
|
+
if (event.key === "Enter") {
|
|
3073
|
+
event.preventDefault();
|
|
3074
|
+
handleContinue();
|
|
3075
|
+
return;
|
|
3076
|
+
}
|
|
3077
|
+
if (event.key === "ArrowLeft") {
|
|
3078
|
+
event.preventDefault();
|
|
3079
|
+
goToQuestion(currentQuestionIndex - 1);
|
|
3080
|
+
return;
|
|
3081
|
+
}
|
|
3082
|
+
if (event.key === "ArrowRight") {
|
|
3083
|
+
event.preventDefault();
|
|
3084
|
+
goToQuestion(currentQuestionIndex + 1);
|
|
3085
|
+
return;
|
|
3086
|
+
}
|
|
3087
|
+
if (event.key === "ArrowUp") {
|
|
3088
|
+
event.preventDefault();
|
|
3089
|
+
moveCurrentChoice(-1);
|
|
3090
|
+
return;
|
|
3091
|
+
}
|
|
3092
|
+
if (event.key === "ArrowDown") {
|
|
3093
|
+
event.preventDefault();
|
|
3094
|
+
moveCurrentChoice(1);
|
|
3095
|
+
return;
|
|
3096
|
+
}
|
|
3097
|
+
if (/^[1-9]$/.test(event.key)) {
|
|
3098
|
+
const choiceIndex = Number(event.key) - 1;
|
|
3099
|
+
if (currentQuestion && choiceIndex < currentQuestion.options.length + 1) {
|
|
3100
|
+
event.preventDefault();
|
|
3101
|
+
chooseChoiceByIndex(choiceIndex);
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
};
|
|
3105
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
3106
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
3107
|
+
}, [
|
|
3108
|
+
chooseChoiceByIndex,
|
|
3109
|
+
currentQuestion,
|
|
3110
|
+
currentQuestionIndex,
|
|
3111
|
+
goToQuestion,
|
|
3112
|
+
handleContinue,
|
|
3113
|
+
moveCurrentChoice,
|
|
3114
|
+
onDismiss,
|
|
3115
|
+
request
|
|
3116
|
+
]);
|
|
3117
|
+
if (!request || !currentQuestion) {
|
|
3118
|
+
return null;
|
|
3119
|
+
}
|
|
3120
|
+
const handleOtherTextChange = (value) => {
|
|
3121
|
+
setDrafts((previous) => ({
|
|
3122
|
+
...previous,
|
|
3123
|
+
[currentQuestion.id]: {
|
|
3124
|
+
type: "other",
|
|
3125
|
+
otherText: value
|
|
3126
|
+
}
|
|
3127
|
+
}));
|
|
3128
|
+
};
|
|
3129
|
+
const otherText = currentDraft?.otherText ?? "";
|
|
3130
|
+
return /* @__PURE__ */ jsxs9(
|
|
3131
|
+
"section",
|
|
3132
|
+
{
|
|
3133
|
+
"aria-label": t("composer.requestUserInput.title"),
|
|
3134
|
+
"aria-live": "polite",
|
|
3135
|
+
className: cn(
|
|
3136
|
+
"mx-2 border border-border bg-background/95 shadow-sm",
|
|
3137
|
+
rounded.density.section,
|
|
3138
|
+
attachToComposer ? "border-b-0" : null,
|
|
3139
|
+
attachToComposer ? rounded.top : rounded.panel,
|
|
3140
|
+
className
|
|
3141
|
+
),
|
|
3142
|
+
children: [
|
|
3143
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-start justify-between gap-3", children: [
|
|
3144
|
+
/* @__PURE__ */ jsxs9("div", { className: "min-w-0", children: [
|
|
3145
|
+
/* @__PURE__ */ jsx14(
|
|
3146
|
+
"div",
|
|
3147
|
+
{
|
|
3148
|
+
className: cn(
|
|
3149
|
+
"font-medium text-muted-foreground",
|
|
3150
|
+
rounded.density.eyebrow
|
|
3151
|
+
),
|
|
3152
|
+
children: currentQuestion.header
|
|
3153
|
+
}
|
|
3154
|
+
),
|
|
3155
|
+
/* @__PURE__ */ jsx14(
|
|
3156
|
+
"h3",
|
|
3157
|
+
{
|
|
3158
|
+
className: cn(
|
|
3159
|
+
"font-semibold text-foreground",
|
|
3160
|
+
rounded.density.title
|
|
3161
|
+
),
|
|
3162
|
+
children: currentQuestion.question
|
|
3163
|
+
}
|
|
3164
|
+
)
|
|
3165
|
+
] }),
|
|
3166
|
+
questions.length > 1 ? /* @__PURE__ */ jsxs9(
|
|
3167
|
+
"div",
|
|
3168
|
+
{
|
|
3169
|
+
className: cn(
|
|
3170
|
+
"flex shrink-0 items-center font-medium text-muted-foreground",
|
|
3171
|
+
rounded.density.pager
|
|
3172
|
+
),
|
|
3173
|
+
children: [
|
|
3174
|
+
/* @__PURE__ */ jsx14(
|
|
3175
|
+
"button",
|
|
3176
|
+
{
|
|
3177
|
+
type: "button",
|
|
3178
|
+
onClick: () => goToQuestion(currentQuestionIndex - 1),
|
|
3179
|
+
disabled: currentQuestionIndex === 0,
|
|
3180
|
+
className: cn(
|
|
3181
|
+
"inline-flex items-center justify-center rounded-full hover:bg-muted disabled:pointer-events-none disabled:opacity-35",
|
|
3182
|
+
rounded.density.pagerButton
|
|
3183
|
+
),
|
|
3184
|
+
"aria-label": t("composer.requestUserInput.previousQuestion"),
|
|
3185
|
+
children: /* @__PURE__ */ jsx14(ChevronLeft, { className: rounded.density.pagerIcon })
|
|
3186
|
+
}
|
|
3187
|
+
),
|
|
3188
|
+
/* @__PURE__ */ jsx14("span", { className: "min-w-12 text-center", children: t("composer.requestUserInput.questionProgress", {
|
|
3189
|
+
current: currentQuestionIndex + 1,
|
|
3190
|
+
total: questions.length
|
|
3191
|
+
}) }),
|
|
3192
|
+
/* @__PURE__ */ jsx14(
|
|
3193
|
+
"button",
|
|
3194
|
+
{
|
|
3195
|
+
type: "button",
|
|
3196
|
+
onClick: () => goToQuestion(currentQuestionIndex + 1),
|
|
3197
|
+
disabled: currentQuestionIndex === questions.length - 1,
|
|
3198
|
+
className: cn(
|
|
3199
|
+
"inline-flex items-center justify-center rounded-full hover:bg-muted disabled:pointer-events-none disabled:opacity-35",
|
|
3200
|
+
rounded.density.pagerButton
|
|
3201
|
+
),
|
|
3202
|
+
"aria-label": t("composer.requestUserInput.nextQuestion"),
|
|
3203
|
+
children: /* @__PURE__ */ jsx14(ChevronRight, { className: rounded.density.pagerIcon })
|
|
3204
|
+
}
|
|
3205
|
+
)
|
|
3206
|
+
]
|
|
3207
|
+
}
|
|
3208
|
+
) : null
|
|
3209
|
+
] }),
|
|
3210
|
+
/* @__PURE__ */ jsxs9("div", { className: rounded.density.choices, children: [
|
|
3211
|
+
currentQuestion.options.map((option, optionIndex) => {
|
|
3212
|
+
const selected = currentDraft?.type === "option" && currentDraft.optionIndex === optionIndex;
|
|
3213
|
+
const parsedLabel = parseRecommendedLabel(option.label);
|
|
3214
|
+
return /* @__PURE__ */ jsxs9(
|
|
3215
|
+
"div",
|
|
3216
|
+
{
|
|
3217
|
+
role: "button",
|
|
3218
|
+
tabIndex: 0,
|
|
3219
|
+
onClick: () => activateOption(currentQuestion, optionIndex),
|
|
3220
|
+
onKeyDown: (event) => {
|
|
3221
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
3222
|
+
event.preventDefault();
|
|
3223
|
+
event.stopPropagation();
|
|
3224
|
+
activateOption(currentQuestion, optionIndex);
|
|
3225
|
+
}
|
|
3226
|
+
},
|
|
3227
|
+
"aria-pressed": selected,
|
|
3228
|
+
"aria-label": `${optionIndex + 1}. ${option.label}`,
|
|
3229
|
+
className: cn(
|
|
3230
|
+
"grid cursor-pointer items-center text-left transition-colors",
|
|
3231
|
+
rounded.density.row,
|
|
3232
|
+
rounded.panel,
|
|
3233
|
+
selected ? "bg-muted text-foreground" : "text-foreground/90 hover:bg-muted/55"
|
|
3234
|
+
),
|
|
3235
|
+
children: [
|
|
3236
|
+
/* @__PURE__ */ jsxs9("span", { className: "text-sm font-semibold text-muted-foreground", children: [
|
|
3237
|
+
optionIndex + 1,
|
|
3238
|
+
"."
|
|
3239
|
+
] }),
|
|
3240
|
+
/* @__PURE__ */ jsxs9("span", { className: "min-w-0", children: [
|
|
3241
|
+
/* @__PURE__ */ jsx14("span", { className: "inline min-w-0 text-sm font-semibold leading-5", children: parsedLabel.label }),
|
|
3242
|
+
parsedLabel.recommended ? /* @__PURE__ */ jsxs9("span", { className: "ml-1.5 inline-flex items-center gap-1 text-sm font-semibold text-primary", children: [
|
|
3243
|
+
/* @__PURE__ */ jsx14(Check, { className: "h-3.5 w-3.5" }),
|
|
3244
|
+
"(",
|
|
3245
|
+
t("composer.requestUserInput.recommended"),
|
|
3246
|
+
")"
|
|
3247
|
+
] }) : null
|
|
3248
|
+
] }),
|
|
3249
|
+
/* @__PURE__ */ jsxs9("span", { className: "flex items-center gap-2 text-muted-foreground", children: [
|
|
3250
|
+
option.description ? /* @__PURE__ */ jsxs9(Tooltip, { children: [
|
|
3251
|
+
/* @__PURE__ */ jsx14(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx14(
|
|
3252
|
+
"button",
|
|
3253
|
+
{
|
|
3254
|
+
type: "button",
|
|
3255
|
+
onClick: (event) => event.stopPropagation(),
|
|
3256
|
+
onKeyDown: (event) => event.stopPropagation(),
|
|
3257
|
+
title: option.description,
|
|
3258
|
+
className: "inline-flex h-7 w-7 items-center justify-center rounded-full hover:bg-background/80 hover:text-foreground",
|
|
3259
|
+
"aria-label": t("composer.requestUserInput.optionInfo", {
|
|
3260
|
+
label: parsedLabel.label
|
|
3261
|
+
}),
|
|
3262
|
+
children: /* @__PURE__ */ jsx14(Info2, { className: "h-4 w-4" })
|
|
3263
|
+
}
|
|
3264
|
+
) }),
|
|
3265
|
+
/* @__PURE__ */ jsx14(
|
|
3266
|
+
TooltipContent,
|
|
3267
|
+
{
|
|
3268
|
+
side: "top",
|
|
3269
|
+
sideOffset: 6,
|
|
3270
|
+
className: "max-w-72 text-left leading-5",
|
|
3271
|
+
children: option.description
|
|
3272
|
+
}
|
|
3273
|
+
)
|
|
3274
|
+
] }) : null,
|
|
3275
|
+
selected ? /* @__PURE__ */ jsxs9(
|
|
3276
|
+
"span",
|
|
3277
|
+
{
|
|
3278
|
+
"aria-hidden": "true",
|
|
3279
|
+
className: "hidden items-center gap-0.5 sm:flex",
|
|
3280
|
+
children: [
|
|
3281
|
+
/* @__PURE__ */ jsx14(ArrowUp2, { className: "h-4 w-4 opacity-45" }),
|
|
3282
|
+
/* @__PURE__ */ jsx14(ArrowDown, { className: "h-4 w-4 opacity-45" })
|
|
3283
|
+
]
|
|
3284
|
+
}
|
|
3285
|
+
) : null
|
|
3286
|
+
] })
|
|
3287
|
+
]
|
|
3288
|
+
},
|
|
3289
|
+
`${currentQuestion.id}-${optionIndex}`
|
|
3290
|
+
);
|
|
3291
|
+
}),
|
|
3292
|
+
/* @__PURE__ */ jsxs9(
|
|
3293
|
+
"label",
|
|
3294
|
+
{
|
|
3295
|
+
className: cn(
|
|
3296
|
+
"grid items-center transition-colors",
|
|
3297
|
+
rounded.density.otherRow,
|
|
3298
|
+
rounded.panel,
|
|
3299
|
+
currentDraft?.type === "other" ? "bg-muted text-foreground" : "hover:bg-muted/55"
|
|
3300
|
+
),
|
|
3301
|
+
children: [
|
|
3302
|
+
/* @__PURE__ */ jsxs9("span", { className: "text-sm font-semibold text-muted-foreground", children: [
|
|
3303
|
+
currentQuestion.options.length + 1,
|
|
3304
|
+
"."
|
|
3305
|
+
] }),
|
|
3306
|
+
/* @__PURE__ */ jsx14("span", { className: "grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-3", children: /* @__PURE__ */ jsx14(
|
|
3307
|
+
"input",
|
|
3308
|
+
{
|
|
3309
|
+
ref: otherInputRef,
|
|
3310
|
+
value: otherText,
|
|
3311
|
+
onChange: (event) => handleOtherTextChange(event.target.value),
|
|
3312
|
+
onFocus: () => selectOther(currentQuestion, otherText),
|
|
3313
|
+
placeholder: t("composer.requestUserInput.otherPlaceholder"),
|
|
3314
|
+
className: cn(
|
|
3315
|
+
"min-w-0 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",
|
|
3316
|
+
rounded.density.input
|
|
3317
|
+
)
|
|
3318
|
+
}
|
|
3319
|
+
) })
|
|
3320
|
+
]
|
|
3321
|
+
}
|
|
3322
|
+
)
|
|
3323
|
+
] }),
|
|
3324
|
+
/* @__PURE__ */ jsxs9(
|
|
3325
|
+
"div",
|
|
3326
|
+
{
|
|
3327
|
+
className: cn(
|
|
3328
|
+
"flex items-center justify-end",
|
|
3329
|
+
rounded.density.footer
|
|
3330
|
+
),
|
|
3331
|
+
children: [
|
|
3332
|
+
onDismiss ? /* @__PURE__ */ jsxs9(
|
|
3333
|
+
"button",
|
|
3334
|
+
{
|
|
3335
|
+
type: "button",
|
|
3336
|
+
onClick: onDismiss,
|
|
3337
|
+
className: cn(
|
|
3338
|
+
"inline-flex items-center gap-2 text-sm font-semibold text-muted-foreground transition-colors hover:text-foreground",
|
|
3339
|
+
rounded.density.dismissButton
|
|
3340
|
+
),
|
|
3341
|
+
children: [
|
|
3342
|
+
t("composer.requestUserInput.dismiss"),
|
|
3343
|
+
/* @__PURE__ */ jsx14("kbd", { className: "rounded-full bg-muted px-2 py-1 text-xs font-semibold text-muted-foreground", children: "ESC" })
|
|
3344
|
+
]
|
|
3345
|
+
}
|
|
3346
|
+
) : null,
|
|
3347
|
+
/* @__PURE__ */ jsxs9(
|
|
3348
|
+
"button",
|
|
3349
|
+
{
|
|
3350
|
+
type: "button",
|
|
3351
|
+
disabled: !currentAnswer,
|
|
3352
|
+
onClick: handleContinue,
|
|
3353
|
+
className: cn(
|
|
3354
|
+
"inline-flex items-center gap-2 bg-primary text-sm font-semibold text-background transition-all",
|
|
3355
|
+
rounded.density.continueButton,
|
|
3356
|
+
"hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-40",
|
|
3357
|
+
rounded.panel
|
|
3358
|
+
),
|
|
3359
|
+
children: [
|
|
3360
|
+
t("composer.requestUserInput.continue"),
|
|
3361
|
+
/* @__PURE__ */ jsx14(
|
|
3362
|
+
"span",
|
|
3363
|
+
{
|
|
3364
|
+
className: cn(
|
|
3365
|
+
"inline-flex items-center justify-center rounded-full bg-background/20",
|
|
3366
|
+
rounded.density.continueIcon
|
|
3367
|
+
),
|
|
3368
|
+
children: /* @__PURE__ */ jsx14(CornerDownLeft2, { className: "h-3.5 w-3.5" })
|
|
3369
|
+
}
|
|
3370
|
+
)
|
|
3371
|
+
]
|
|
3372
|
+
}
|
|
3373
|
+
)
|
|
3374
|
+
]
|
|
3375
|
+
}
|
|
3376
|
+
)
|
|
3377
|
+
]
|
|
3378
|
+
}
|
|
3379
|
+
);
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3382
|
+
// src/components/thread/messages/ai.tsx
|
|
3383
|
+
import * as React19 from "react";
|
|
3384
|
+
import {
|
|
3385
|
+
ChevronDown as ChevronDown2,
|
|
3386
|
+
Clock3,
|
|
3387
|
+
Loader2 as Loader23
|
|
3388
|
+
} from "lucide-react";
|
|
3389
|
+
|
|
3390
|
+
// src/components/ui/badge.tsx
|
|
3391
|
+
import * as React13 from "react";
|
|
3392
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
3393
|
+
var base = "inline-flex items-center rounded-full border border-transparent px-2.5 py-0.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background";
|
|
3394
|
+
var variants = {
|
|
3395
|
+
default: "bg-primary text-primary-foreground",
|
|
3396
|
+
secondary: "bg-secondary text-secondary-foreground",
|
|
3397
|
+
outline: "border-input text-foreground"
|
|
3398
|
+
};
|
|
3399
|
+
var Badge = React13.forwardRef(
|
|
3400
|
+
({ className, variant = "default", ...props }, ref) => {
|
|
3401
|
+
return /* @__PURE__ */ jsx15("span", { ref, className: cn(base, variants[variant], className), ...props });
|
|
3402
|
+
}
|
|
3403
|
+
);
|
|
3404
|
+
Badge.displayName = "Badge";
|
|
3405
|
+
|
|
3406
|
+
// src/components/ui/card.tsx
|
|
3407
|
+
import * as React14 from "react";
|
|
3408
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
3409
|
+
var Card = React14.forwardRef(
|
|
3410
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx16(
|
|
3411
|
+
"div",
|
|
3412
|
+
{
|
|
3413
|
+
ref,
|
|
3414
|
+
className: cn(
|
|
3415
|
+
"rounded-xl border bg-background/80 text-foreground shadow-[0_14px_40px_-30px_rgba(15,23,42,0.5)] backdrop-blur",
|
|
3416
|
+
className
|
|
3417
|
+
),
|
|
3418
|
+
...props
|
|
3419
|
+
}
|
|
3420
|
+
)
|
|
3421
|
+
);
|
|
3422
|
+
Card.displayName = "Card";
|
|
3423
|
+
var CardHeader = React14.forwardRef(
|
|
3424
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx16("div", { ref, className: cn("flex flex-col gap-1.5 px-6 pt-6", className), ...props })
|
|
3425
|
+
);
|
|
3426
|
+
CardHeader.displayName = "CardHeader";
|
|
3427
|
+
var CardTitle = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx16("h3", { ref, className: cn("text-lg font-semibold leading-tight", className), ...props }));
|
|
3428
|
+
CardTitle.displayName = "CardTitle";
|
|
3429
|
+
var CardDescription = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx16("p", { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
3430
|
+
CardDescription.displayName = "CardDescription";
|
|
3431
|
+
var CardContent = React14.forwardRef(
|
|
3432
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx16("div", { ref, className: cn("px-6 pb-6", className), ...props })
|
|
3433
|
+
);
|
|
3434
|
+
CardContent.displayName = "CardContent";
|
|
3435
|
+
var CardFooter = React14.forwardRef(
|
|
3436
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx16("div", { ref, className: cn("flex items-center px-6 pb-6", className), ...props })
|
|
3437
|
+
);
|
|
3438
|
+
CardFooter.displayName = "CardFooter";
|
|
3439
|
+
var CardAction = React14.forwardRef(
|
|
3440
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx16("div", { ref, className: cn("ml-auto flex items-center", className), ...props })
|
|
3441
|
+
);
|
|
3442
|
+
CardAction.displayName = "CardAction";
|
|
3443
|
+
|
|
3444
|
+
// src/components/ui/tabs.tsx
|
|
3445
|
+
import * as React15 from "react";
|
|
3446
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
3447
|
+
var TabsContext = React15.createContext(null);
|
|
3448
|
+
function Tabs({ className, defaultValue, value, onValueChange, ...props }) {
|
|
3449
|
+
const [internalValue, setInternalValue] = React15.useState(defaultValue ?? "");
|
|
3450
|
+
const activeValue = value ?? internalValue;
|
|
3451
|
+
const setValue = React15.useCallback(
|
|
3452
|
+
(nextValue) => {
|
|
3453
|
+
if (value === void 0) setInternalValue(nextValue);
|
|
3454
|
+
onValueChange?.(nextValue);
|
|
3455
|
+
},
|
|
3456
|
+
[onValueChange, value]
|
|
3457
|
+
);
|
|
3458
|
+
return /* @__PURE__ */ jsx17(TabsContext.Provider, { value: { value: activeValue, setValue }, children: /* @__PURE__ */ jsx17("div", { className: cn("w-full", className), ...props }) });
|
|
3459
|
+
}
|
|
3460
|
+
var TabsList = React15.forwardRef(
|
|
3461
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx17(
|
|
3462
|
+
"div",
|
|
3463
|
+
{
|
|
3464
|
+
ref,
|
|
3465
|
+
className: cn(
|
|
3466
|
+
"inline-flex items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
3467
|
+
className
|
|
3468
|
+
),
|
|
3469
|
+
role: "tablist",
|
|
3470
|
+
...props
|
|
3471
|
+
}
|
|
3472
|
+
)
|
|
3473
|
+
);
|
|
3474
|
+
TabsList.displayName = "TabsList";
|
|
3475
|
+
var TabsTrigger = React15.forwardRef(
|
|
3476
|
+
({ className, value, onClick, ...props }, ref) => {
|
|
3477
|
+
const context = React15.useContext(TabsContext);
|
|
3478
|
+
if (!context) {
|
|
3479
|
+
throw new Error("TabsTrigger must be used within Tabs");
|
|
3480
|
+
}
|
|
3481
|
+
const isActive = context.value === value;
|
|
3482
|
+
return /* @__PURE__ */ jsx17(
|
|
3483
|
+
"button",
|
|
3484
|
+
{
|
|
3485
|
+
ref,
|
|
3486
|
+
type: "button",
|
|
3487
|
+
role: "tab",
|
|
3488
|
+
"aria-selected": isActive,
|
|
3489
|
+
"data-state": isActive ? "active" : "inactive",
|
|
3490
|
+
className: cn(
|
|
3491
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
|
|
3492
|
+
className
|
|
3493
|
+
),
|
|
3494
|
+
onClick: (event) => {
|
|
3495
|
+
context.setValue(value);
|
|
3496
|
+
onClick?.(event);
|
|
3497
|
+
},
|
|
3498
|
+
...props
|
|
3499
|
+
}
|
|
3500
|
+
);
|
|
3501
|
+
}
|
|
3502
|
+
);
|
|
3503
|
+
TabsTrigger.displayName = "TabsTrigger";
|
|
3504
|
+
var TabsContent = React15.forwardRef(
|
|
3505
|
+
({ className, value, ...props }, ref) => {
|
|
3506
|
+
const context = React15.useContext(TabsContext);
|
|
3507
|
+
if (!context) {
|
|
3508
|
+
throw new Error("TabsContent must be used within Tabs");
|
|
3509
|
+
}
|
|
3510
|
+
if (context.value !== value) return null;
|
|
3511
|
+
return /* @__PURE__ */ jsx17(
|
|
3512
|
+
"div",
|
|
3513
|
+
{
|
|
3514
|
+
ref,
|
|
3515
|
+
role: "tabpanel",
|
|
3516
|
+
className: cn(
|
|
3517
|
+
"mt-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background",
|
|
3518
|
+
className
|
|
3519
|
+
),
|
|
3520
|
+
...props
|
|
3521
|
+
}
|
|
3522
|
+
);
|
|
3523
|
+
}
|
|
3524
|
+
);
|
|
3525
|
+
TabsContent.displayName = "TabsContent";
|
|
3526
|
+
|
|
3527
|
+
// src/components/thread/markdown-text.tsx
|
|
3528
|
+
import ReactMarkdown from "react-markdown";
|
|
3529
|
+
import remarkGfm from "remark-gfm";
|
|
3530
|
+
import rehypeKatex from "rehype-katex";
|
|
3531
|
+
import remarkMath from "remark-math";
|
|
3532
|
+
import {
|
|
3533
|
+
Children,
|
|
3534
|
+
isValidElement,
|
|
3535
|
+
memo,
|
|
3536
|
+
useState as useState9
|
|
3537
|
+
} from "react";
|
|
3538
|
+
import { CheckIcon as CheckIcon2, CopyIcon as CopyIcon2 } from "lucide-react";
|
|
3539
|
+
|
|
2734
3540
|
// src/components/thread/syntax-highlighter.tsx
|
|
2735
3541
|
import { PrismAsyncLight as SyntaxHighlighterPrism } from "react-syntax-highlighter";
|
|
2736
3542
|
import tsx from "react-syntax-highlighter/dist/esm/languages/prism/tsx";
|
|
2737
3543
|
import python from "react-syntax-highlighter/dist/esm/languages/prism/python";
|
|
2738
3544
|
import { coldarkDark } from "react-syntax-highlighter/dist/cjs/styles/prism";
|
|
2739
3545
|
import "react";
|
|
2740
|
-
import { jsx as
|
|
3546
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
2741
3547
|
SyntaxHighlighterPrism.registerLanguage("js", tsx);
|
|
2742
3548
|
SyntaxHighlighterPrism.registerLanguage("jsx", tsx);
|
|
2743
3549
|
SyntaxHighlighterPrism.registerLanguage("ts", tsx);
|
|
@@ -2748,7 +3554,7 @@ var SyntaxHighlighter = ({
|
|
|
2748
3554
|
language,
|
|
2749
3555
|
className
|
|
2750
3556
|
}) => {
|
|
2751
|
-
return /* @__PURE__ */
|
|
3557
|
+
return /* @__PURE__ */ jsx18(
|
|
2752
3558
|
SyntaxHighlighterPrism,
|
|
2753
3559
|
{
|
|
2754
3560
|
language,
|
|
@@ -2778,14 +3584,14 @@ import {
|
|
|
2778
3584
|
TriangleAlert,
|
|
2779
3585
|
X as X2
|
|
2780
3586
|
} from "lucide-react";
|
|
2781
|
-
import * as
|
|
3587
|
+
import * as React16 from "react";
|
|
2782
3588
|
|
|
2783
3589
|
// src/components/thread/tooltip-icon-button.tsx
|
|
2784
3590
|
import { forwardRef as forwardRef5 } from "react";
|
|
2785
|
-
import { jsx as
|
|
3591
|
+
import { jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2786
3592
|
var TooltipIconButton = forwardRef5(({ children, tooltip, side = "bottom", className, ...rest }, ref) => {
|
|
2787
|
-
return /* @__PURE__ */
|
|
2788
|
-
/* @__PURE__ */
|
|
3593
|
+
return /* @__PURE__ */ jsx19(TooltipProvider, { children: /* @__PURE__ */ jsxs10(Tooltip, { children: [
|
|
3594
|
+
/* @__PURE__ */ jsx19(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs10(
|
|
2789
3595
|
Button,
|
|
2790
3596
|
{
|
|
2791
3597
|
variant: "ghost",
|
|
@@ -2795,17 +3601,17 @@ var TooltipIconButton = forwardRef5(({ children, tooltip, side = "bottom", class
|
|
|
2795
3601
|
ref,
|
|
2796
3602
|
children: [
|
|
2797
3603
|
children,
|
|
2798
|
-
/* @__PURE__ */
|
|
3604
|
+
/* @__PURE__ */ jsx19("span", { className: "sr-only", children: tooltip })
|
|
2799
3605
|
]
|
|
2800
3606
|
}
|
|
2801
3607
|
) }),
|
|
2802
|
-
/* @__PURE__ */
|
|
3608
|
+
/* @__PURE__ */ jsx19(TooltipContent, { side, children: tooltip })
|
|
2803
3609
|
] }) });
|
|
2804
3610
|
});
|
|
2805
3611
|
TooltipIconButton.displayName = "TooltipIconButton";
|
|
2806
3612
|
|
|
2807
3613
|
// src/components/thread/mermaid-block.tsx
|
|
2808
|
-
import { Fragment as Fragment2, jsx as
|
|
3614
|
+
import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2809
3615
|
var HEX_COLOR_PATTERN = /^#([\da-f]{3,8})$/i;
|
|
2810
3616
|
var MERMAID_DIRECTIVE_PATTERN = /%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi;
|
|
2811
3617
|
var MERMAID_FRONTMATTER_PATTERN = /^-{3}\s*[\n\r](.*?)[\n\r]-{3}\s*[\n\r]+/s;
|
|
@@ -3053,24 +3859,24 @@ function MermaidPreviewDialog({
|
|
|
3053
3859
|
svgMarkup,
|
|
3054
3860
|
title
|
|
3055
3861
|
}) {
|
|
3056
|
-
return /* @__PURE__ */
|
|
3057
|
-
/* @__PURE__ */
|
|
3058
|
-
/* @__PURE__ */
|
|
3059
|
-
/* @__PURE__ */
|
|
3060
|
-
/* @__PURE__ */
|
|
3061
|
-
/* @__PURE__ */
|
|
3862
|
+
return /* @__PURE__ */ jsx20(Dialog.Root, { open, onOpenChange, children: /* @__PURE__ */ jsxs11(Dialog.Portal, { children: [
|
|
3863
|
+
/* @__PURE__ */ jsx20(Dialog.Overlay, { className: "fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=closed]:animate-out data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" }),
|
|
3864
|
+
/* @__PURE__ */ jsxs11(Dialog.Content, { className: "fixed inset-[5vh] z-50 flex flex-col overflow-hidden rounded-3xl border border-border bg-background shadow-2xl outline-none data-[state=closed]:animate-out data-[state=open]:animate-in data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", children: [
|
|
3865
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between gap-4 border-b border-border px-5 py-4", children: [
|
|
3866
|
+
/* @__PURE__ */ jsx20(Dialog.Title, { className: "text-base font-semibold text-foreground", children: title }),
|
|
3867
|
+
/* @__PURE__ */ jsx20(Dialog.Close, { asChild: true, children: /* @__PURE__ */ jsxs11(
|
|
3062
3868
|
"button",
|
|
3063
3869
|
{
|
|
3064
3870
|
type: "button",
|
|
3065
3871
|
className: "inline-flex size-10 items-center justify-center rounded-full border border-border bg-card text-muted-foreground transition-colors hover:text-foreground",
|
|
3066
3872
|
children: [
|
|
3067
|
-
/* @__PURE__ */
|
|
3068
|
-
/* @__PURE__ */
|
|
3873
|
+
/* @__PURE__ */ jsx20(X2, { className: "size-4" }),
|
|
3874
|
+
/* @__PURE__ */ jsx20("span", { className: "sr-only", children: closeLabel })
|
|
3069
3875
|
]
|
|
3070
3876
|
}
|
|
3071
3877
|
) })
|
|
3072
3878
|
] }),
|
|
3073
|
-
/* @__PURE__ */
|
|
3879
|
+
/* @__PURE__ */ jsx20("div", { className: "flex-1 overflow-auto bg-card p-6", children: /* @__PURE__ */ jsx20(
|
|
3074
3880
|
"div",
|
|
3075
3881
|
{
|
|
3076
3882
|
"data-slot": "mermaid-preview",
|
|
@@ -3084,24 +3890,24 @@ function MermaidPreviewDialog({
|
|
|
3084
3890
|
function MermaidBlock({ code }) {
|
|
3085
3891
|
const { t } = useChatkitTranslation();
|
|
3086
3892
|
const { theme, isDarkMode } = useTheme();
|
|
3087
|
-
const containerRef =
|
|
3088
|
-
const renderHostRef =
|
|
3089
|
-
const renderSequenceRef =
|
|
3090
|
-
const copyResetTimeoutRef =
|
|
3091
|
-
const diagramId =
|
|
3092
|
-
const [activeTab, setActiveTab] =
|
|
3093
|
-
const [isCopied, setIsCopied] =
|
|
3094
|
-
const [isPreviewOpen, setIsPreviewOpen] =
|
|
3095
|
-
const [isRendering, setIsRendering] =
|
|
3096
|
-
const [renderError, setRenderError] =
|
|
3097
|
-
const [svgMarkup, setSvgMarkup] =
|
|
3098
|
-
const normalizedCode =
|
|
3099
|
-
const clearCopyResetTimeout =
|
|
3893
|
+
const containerRef = React16.useRef(null);
|
|
3894
|
+
const renderHostRef = React16.useRef(null);
|
|
3895
|
+
const renderSequenceRef = React16.useRef(0);
|
|
3896
|
+
const copyResetTimeoutRef = React16.useRef(null);
|
|
3897
|
+
const diagramId = React16.useId().replace(/:/g, "");
|
|
3898
|
+
const [activeTab, setActiveTab] = React16.useState("diagram");
|
|
3899
|
+
const [isCopied, setIsCopied] = React16.useState(false);
|
|
3900
|
+
const [isPreviewOpen, setIsPreviewOpen] = React16.useState(false);
|
|
3901
|
+
const [isRendering, setIsRendering] = React16.useState(true);
|
|
3902
|
+
const [renderError, setRenderError] = React16.useState(null);
|
|
3903
|
+
const [svgMarkup, setSvgMarkup] = React16.useState(null);
|
|
3904
|
+
const normalizedCode = React16.useMemo(() => normalizeMermaidCode(code), [code]);
|
|
3905
|
+
const clearCopyResetTimeout = React16.useCallback(() => {
|
|
3100
3906
|
if (copyResetTimeoutRef.current === null) return;
|
|
3101
3907
|
window.clearTimeout(copyResetTimeoutRef.current);
|
|
3102
3908
|
copyResetTimeoutRef.current = null;
|
|
3103
3909
|
}, []);
|
|
3104
|
-
|
|
3910
|
+
React16.useEffect(() => {
|
|
3105
3911
|
let isActive = true;
|
|
3106
3912
|
async function runRender() {
|
|
3107
3913
|
const container = containerRef.current;
|
|
@@ -3139,17 +3945,17 @@ function MermaidBlock({ code }) {
|
|
|
3139
3945
|
}
|
|
3140
3946
|
};
|
|
3141
3947
|
}, [diagramId, isDarkMode, normalizedCode, theme]);
|
|
3142
|
-
|
|
3948
|
+
React16.useEffect(() => {
|
|
3143
3949
|
clearCopyResetTimeout();
|
|
3144
3950
|
setIsCopied(false);
|
|
3145
3951
|
}, [activeTab, clearCopyResetTimeout, code]);
|
|
3146
|
-
|
|
3952
|
+
React16.useEffect(
|
|
3147
3953
|
() => () => {
|
|
3148
3954
|
clearCopyResetTimeout();
|
|
3149
3955
|
},
|
|
3150
3956
|
[clearCopyResetTimeout]
|
|
3151
3957
|
);
|
|
3152
|
-
const handleDownload =
|
|
3958
|
+
const handleDownload = React16.useCallback(() => {
|
|
3153
3959
|
if (!svgMarkup) return;
|
|
3154
3960
|
const blob = new Blob([svgMarkup], {
|
|
3155
3961
|
type: "image/svg+xml;charset=utf-8"
|
|
@@ -3163,7 +3969,7 @@ function MermaidBlock({ code }) {
|
|
|
3163
3969
|
anchor.remove();
|
|
3164
3970
|
window.URL.revokeObjectURL(url);
|
|
3165
3971
|
}, [diagramId, svgMarkup]);
|
|
3166
|
-
const handleCopyCode =
|
|
3972
|
+
const handleCopyCode = React16.useCallback(() => {
|
|
3167
3973
|
if (!code || isCopied) return;
|
|
3168
3974
|
navigator.clipboard.writeText(code).then(() => {
|
|
3169
3975
|
setIsCopied(true);
|
|
@@ -3177,21 +3983,21 @@ function MermaidBlock({ code }) {
|
|
|
3177
3983
|
}, [clearCopyResetTimeout, code, isCopied]);
|
|
3178
3984
|
const hasRenderedDiagram = svgMarkup !== null && !renderError;
|
|
3179
3985
|
const statusMessage = isRendering ? t("markdown.mermaid.rendering") : t("markdown.mermaid.failed");
|
|
3180
|
-
return /* @__PURE__ */
|
|
3181
|
-
/* @__PURE__ */
|
|
3986
|
+
return /* @__PURE__ */ jsxs11(Fragment2, { children: [
|
|
3987
|
+
/* @__PURE__ */ jsx20(
|
|
3182
3988
|
Tabs,
|
|
3183
3989
|
{
|
|
3184
3990
|
className: "w-full",
|
|
3185
3991
|
onValueChange: (value) => setActiveTab(value),
|
|
3186
3992
|
value: activeTab,
|
|
3187
|
-
children: /* @__PURE__ */
|
|
3993
|
+
children: /* @__PURE__ */ jsxs11(
|
|
3188
3994
|
"div",
|
|
3189
3995
|
{
|
|
3190
3996
|
ref: containerRef,
|
|
3191
3997
|
"data-slot": "mermaid-block",
|
|
3192
3998
|
className: "relative overflow-hidden text-card-foreground",
|
|
3193
3999
|
children: [
|
|
3194
|
-
/* @__PURE__ */
|
|
4000
|
+
/* @__PURE__ */ jsx20(
|
|
3195
4001
|
"div",
|
|
3196
4002
|
{
|
|
3197
4003
|
ref: renderHostRef,
|
|
@@ -3200,62 +4006,62 @@ function MermaidBlock({ code }) {
|
|
|
3200
4006
|
"data-slot": "mermaid-render-host"
|
|
3201
4007
|
}
|
|
3202
4008
|
),
|
|
3203
|
-
/* @__PURE__ */
|
|
3204
|
-
/* @__PURE__ */
|
|
3205
|
-
/* @__PURE__ */
|
|
3206
|
-
/* @__PURE__ */
|
|
4009
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap items-center justify-between gap-3 px-4 py-3", children: [
|
|
4010
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex min-w-0 items-center gap-3", children: [
|
|
4011
|
+
/* @__PURE__ */ jsx20("span", { className: "inline-flex size-9 shrink-0 items-center justify-center rounded-full bg-muted text-foreground", children: /* @__PURE__ */ jsx20(Code2Icon, { className: "size-4" }) }),
|
|
4012
|
+
/* @__PURE__ */ jsx20("span", { className: "truncate text-base font-semibold text-foreground", children: t("markdown.mermaid.title") })
|
|
3207
4013
|
] }),
|
|
3208
|
-
/* @__PURE__ */
|
|
3209
|
-
/* @__PURE__ */
|
|
3210
|
-
activeTab === "diagram" && hasRenderedDiagram ? /* @__PURE__ */
|
|
4014
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
4015
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1", children: [
|
|
4016
|
+
activeTab === "diagram" && hasRenderedDiagram ? /* @__PURE__ */ jsx20(
|
|
3211
4017
|
TooltipIconButton,
|
|
3212
4018
|
{
|
|
3213
4019
|
onClick: handleDownload,
|
|
3214
4020
|
tooltip: t("markdown.mermaid.download"),
|
|
3215
|
-
children: /* @__PURE__ */
|
|
4021
|
+
children: /* @__PURE__ */ jsx20(DownloadIcon, { className: "size-4" })
|
|
3216
4022
|
}
|
|
3217
4023
|
) : null,
|
|
3218
|
-
activeTab === "diagram" && hasRenderedDiagram ? /* @__PURE__ */
|
|
4024
|
+
activeTab === "diagram" && hasRenderedDiagram ? /* @__PURE__ */ jsx20(
|
|
3219
4025
|
TooltipIconButton,
|
|
3220
4026
|
{
|
|
3221
4027
|
onClick: () => setIsPreviewOpen(true),
|
|
3222
4028
|
tooltip: t("markdown.mermaid.fullScreen"),
|
|
3223
|
-
children: /* @__PURE__ */
|
|
4029
|
+
children: /* @__PURE__ */ jsx20(ExpandIcon, { className: "size-4" })
|
|
3224
4030
|
}
|
|
3225
4031
|
) : null,
|
|
3226
|
-
activeTab === "code" ? /* @__PURE__ */
|
|
4032
|
+
activeTab === "code" ? /* @__PURE__ */ jsx20(
|
|
3227
4033
|
TooltipIconButton,
|
|
3228
4034
|
{
|
|
3229
4035
|
onClick: handleCopyCode,
|
|
3230
4036
|
tooltip: t("markdown.copy"),
|
|
3231
|
-
children: isCopied ? /* @__PURE__ */
|
|
4037
|
+
children: isCopied ? /* @__PURE__ */ jsx20(CheckIcon, { className: "size-4" }) : /* @__PURE__ */ jsx20(CopyIcon, { className: "size-4" })
|
|
3232
4038
|
}
|
|
3233
4039
|
) : null
|
|
3234
4040
|
] }),
|
|
3235
|
-
/* @__PURE__ */
|
|
3236
|
-
/* @__PURE__ */
|
|
3237
|
-
/* @__PURE__ */
|
|
4041
|
+
/* @__PURE__ */ jsxs11(TabsList, { children: [
|
|
4042
|
+
/* @__PURE__ */ jsx20(TabsTrigger, { value: "diagram", children: t("markdown.mermaid.diagram") }),
|
|
4043
|
+
/* @__PURE__ */ jsx20(TabsTrigger, { value: "code", children: t("markdown.mermaid.code") })
|
|
3238
4044
|
] })
|
|
3239
4045
|
] })
|
|
3240
4046
|
] }),
|
|
3241
|
-
/* @__PURE__ */
|
|
3242
|
-
renderError ? /* @__PURE__ */
|
|
3243
|
-
/* @__PURE__ */
|
|
4047
|
+
/* @__PURE__ */ jsxs11("div", { className: "border-t border-border pt-4", children: [
|
|
4048
|
+
renderError ? /* @__PURE__ */ jsx20("p", { role: "alert", className: "mb-4 text-sm font-medium text-destructive", children: t("markdown.mermaid.failed") }) : null,
|
|
4049
|
+
/* @__PURE__ */ jsx20(TabsContent, { value: "diagram", className: "mt-0 space-y-4", children: /* @__PURE__ */ jsx20(
|
|
3244
4050
|
"div",
|
|
3245
4051
|
{
|
|
3246
4052
|
className: cn(
|
|
3247
4053
|
"relative overflow-auto rounded-[calc(var(--radius)+0.5rem)] border border-border bg-background p-4",
|
|
3248
4054
|
hasRenderedDiagram ? "[&_svg]:mx-auto [&_svg]:h-auto [&_svg]:w-full [&_svg]:max-w-none" : "min-h-[14rem]"
|
|
3249
4055
|
),
|
|
3250
|
-
children: hasRenderedDiagram ? /* @__PURE__ */
|
|
4056
|
+
children: hasRenderedDiagram ? /* @__PURE__ */ jsx20(
|
|
3251
4057
|
"div",
|
|
3252
4058
|
{
|
|
3253
4059
|
"data-slot": "mermaid-diagram",
|
|
3254
4060
|
dangerouslySetInnerHTML: { __html: svgMarkup }
|
|
3255
4061
|
}
|
|
3256
|
-
) : /* @__PURE__ */
|
|
3257
|
-
isRendering ? /* @__PURE__ */
|
|
3258
|
-
/* @__PURE__ */
|
|
4062
|
+
) : /* @__PURE__ */ jsxs11("div", { className: "flex min-h-[12rem] flex-col items-center justify-center gap-3 text-center text-muted-foreground", children: [
|
|
4063
|
+
isRendering ? /* @__PURE__ */ jsx20(Loader2, { className: "size-5 animate-spin" }) : /* @__PURE__ */ jsx20(TriangleAlert, { className: "size-5 text-destructive" }),
|
|
4064
|
+
/* @__PURE__ */ jsx20(
|
|
3259
4065
|
"p",
|
|
3260
4066
|
{
|
|
3261
4067
|
className: cn("text-sm font-medium", !isRendering && "text-destructive"),
|
|
@@ -3266,12 +4072,12 @@ function MermaidBlock({ code }) {
|
|
|
3266
4072
|
] })
|
|
3267
4073
|
}
|
|
3268
4074
|
) }),
|
|
3269
|
-
/* @__PURE__ */
|
|
4075
|
+
/* @__PURE__ */ jsx20(TabsContent, { value: "code", className: "mt-0", children: /* @__PURE__ */ jsx20(
|
|
3270
4076
|
"pre",
|
|
3271
4077
|
{
|
|
3272
4078
|
"data-slot": "mermaid-code",
|
|
3273
4079
|
className: "overflow-x-auto rounded-[calc(var(--radius)+0.5rem)] border border-border bg-zinc-950 px-4 py-4 text-sm text-zinc-50",
|
|
3274
|
-
children: /* @__PURE__ */
|
|
4080
|
+
children: /* @__PURE__ */ jsx20("code", { className: "block whitespace-pre font-mono", children: code })
|
|
3275
4081
|
}
|
|
3276
4082
|
) })
|
|
3277
4083
|
] })
|
|
@@ -3280,7 +4086,7 @@ function MermaidBlock({ code }) {
|
|
|
3280
4086
|
)
|
|
3281
4087
|
}
|
|
3282
4088
|
),
|
|
3283
|
-
svgMarkup ? /* @__PURE__ */
|
|
4089
|
+
svgMarkup ? /* @__PURE__ */ jsx20(
|
|
3284
4090
|
MermaidPreviewDialog,
|
|
3285
4091
|
{
|
|
3286
4092
|
closeLabel: t("sheet.close"),
|
|
@@ -3295,7 +4101,7 @@ function MermaidBlock({ code }) {
|
|
|
3295
4101
|
|
|
3296
4102
|
// src/components/thread/markdown-text.tsx
|
|
3297
4103
|
import "katex/dist/katex.min.css";
|
|
3298
|
-
import { Fragment as Fragment3, jsx as
|
|
4104
|
+
import { Fragment as Fragment3, jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3299
4105
|
var markdownTableMinWidth = "max(7rem, calc(8rem * var(--density-spacing, 1)))";
|
|
3300
4106
|
var markdownTableCellPaddingInline = "calc(var(--density-padding, 1rem) * 1.25)";
|
|
3301
4107
|
var markdownTableCellPaddingBlock = "max(0.5rem, calc(var(--density-padding, 1rem) * 0.75))";
|
|
@@ -3313,7 +4119,7 @@ var isMermaidCodeElement = (child) => isValidElement(child) && typeof child.prop
|
|
|
3313
4119
|
var useCopyToClipboard = ({
|
|
3314
4120
|
copiedDuration = 3e3
|
|
3315
4121
|
} = {}) => {
|
|
3316
|
-
const [isCopied, setIsCopied] =
|
|
4122
|
+
const [isCopied, setIsCopied] = useState9(false);
|
|
3317
4123
|
const copyToClipboard = (value) => {
|
|
3318
4124
|
if (!value) return;
|
|
3319
4125
|
navigator.clipboard.writeText(value).then(() => {
|
|
@@ -3330,23 +4136,23 @@ var CodeHeader = ({ language, code }) => {
|
|
|
3330
4136
|
if (!code || isCopied) return;
|
|
3331
4137
|
copyToClipboard(code);
|
|
3332
4138
|
};
|
|
3333
|
-
return /* @__PURE__ */
|
|
3334
|
-
/* @__PURE__ */
|
|
3335
|
-
/* @__PURE__ */
|
|
4139
|
+
return /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between gap-4 rounded-t-lg bg-zinc-900 px-4 py-2 text-sm font-semibold text-white", children: [
|
|
4140
|
+
/* @__PURE__ */ jsx21("span", { className: "lowercase [&>span]:text-xs", children: language }),
|
|
4141
|
+
/* @__PURE__ */ jsxs12(
|
|
3336
4142
|
TooltipIconButton,
|
|
3337
4143
|
{
|
|
3338
4144
|
tooltip: t("markdown.copy"),
|
|
3339
4145
|
onClick: onCopy,
|
|
3340
4146
|
children: [
|
|
3341
|
-
!isCopied && /* @__PURE__ */
|
|
3342
|
-
isCopied && /* @__PURE__ */
|
|
4147
|
+
!isCopied && /* @__PURE__ */ jsx21(CopyIcon2, {}),
|
|
4148
|
+
isCopied && /* @__PURE__ */ jsx21(CheckIcon2, {})
|
|
3343
4149
|
]
|
|
3344
4150
|
}
|
|
3345
4151
|
)
|
|
3346
4152
|
] });
|
|
3347
4153
|
};
|
|
3348
4154
|
var defaultComponents = {
|
|
3349
|
-
h1: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4155
|
+
h1: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3350
4156
|
"h1",
|
|
3351
4157
|
{
|
|
3352
4158
|
className: cn(
|
|
@@ -3356,7 +4162,7 @@ var defaultComponents = {
|
|
|
3356
4162
|
...props
|
|
3357
4163
|
}
|
|
3358
4164
|
),
|
|
3359
|
-
h2: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4165
|
+
h2: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3360
4166
|
"h2",
|
|
3361
4167
|
{
|
|
3362
4168
|
className: cn(
|
|
@@ -3366,7 +4172,7 @@ var defaultComponents = {
|
|
|
3366
4172
|
...props
|
|
3367
4173
|
}
|
|
3368
4174
|
),
|
|
3369
|
-
h3: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4175
|
+
h3: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3370
4176
|
"h3",
|
|
3371
4177
|
{
|
|
3372
4178
|
className: cn(
|
|
@@ -3376,7 +4182,7 @@ var defaultComponents = {
|
|
|
3376
4182
|
...props
|
|
3377
4183
|
}
|
|
3378
4184
|
),
|
|
3379
|
-
h4: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4185
|
+
h4: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3380
4186
|
"h4",
|
|
3381
4187
|
{
|
|
3382
4188
|
className: cn(
|
|
@@ -3386,7 +4192,7 @@ var defaultComponents = {
|
|
|
3386
4192
|
...props
|
|
3387
4193
|
}
|
|
3388
4194
|
),
|
|
3389
|
-
h5: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4195
|
+
h5: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3390
4196
|
"h5",
|
|
3391
4197
|
{
|
|
3392
4198
|
className: cn(
|
|
@@ -3396,21 +4202,21 @@ var defaultComponents = {
|
|
|
3396
4202
|
...props
|
|
3397
4203
|
}
|
|
3398
4204
|
),
|
|
3399
|
-
h6: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4205
|
+
h6: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3400
4206
|
"h6",
|
|
3401
4207
|
{
|
|
3402
4208
|
className: cn("my-4 font-semibold first:mt-0 last:mb-0", className),
|
|
3403
4209
|
...props
|
|
3404
4210
|
}
|
|
3405
4211
|
),
|
|
3406
|
-
p: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4212
|
+
p: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3407
4213
|
"p",
|
|
3408
4214
|
{
|
|
3409
4215
|
className: cn("mt-5 mb-5 leading-7 first:mt-0 last:mb-0", className),
|
|
3410
4216
|
...props
|
|
3411
4217
|
}
|
|
3412
4218
|
),
|
|
3413
|
-
a: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4219
|
+
a: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3414
4220
|
"a",
|
|
3415
4221
|
{
|
|
3416
4222
|
className: cn(
|
|
@@ -3426,7 +4232,7 @@ var defaultComponents = {
|
|
|
3426
4232
|
className,
|
|
3427
4233
|
node: _node,
|
|
3428
4234
|
...props
|
|
3429
|
-
}) => /* @__PURE__ */
|
|
4235
|
+
}) => /* @__PURE__ */ jsx21(
|
|
3430
4236
|
"blockquote",
|
|
3431
4237
|
{
|
|
3432
4238
|
className: cn(
|
|
@@ -3436,21 +4242,21 @@ var defaultComponents = {
|
|
|
3436
4242
|
...props
|
|
3437
4243
|
}
|
|
3438
4244
|
),
|
|
3439
|
-
ul: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4245
|
+
ul: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3440
4246
|
"ul",
|
|
3441
4247
|
{
|
|
3442
4248
|
className: cn("my-5 list-outside list-disc pl-6 [&>li]:mt-2", className),
|
|
3443
4249
|
...props
|
|
3444
4250
|
}
|
|
3445
4251
|
),
|
|
3446
|
-
ol: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4252
|
+
ol: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3447
4253
|
"ol",
|
|
3448
4254
|
{
|
|
3449
4255
|
className: cn("my-5 list-outside list-decimal pl-8 [&>li]:mt-2", className),
|
|
3450
4256
|
...props
|
|
3451
4257
|
}
|
|
3452
4258
|
),
|
|
3453
|
-
hr: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4259
|
+
hr: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3454
4260
|
"hr",
|
|
3455
4261
|
{
|
|
3456
4262
|
className: cn("my-5 border-b", className),
|
|
@@ -3462,12 +4268,12 @@ var defaultComponents = {
|
|
|
3462
4268
|
node: _node,
|
|
3463
4269
|
style,
|
|
3464
4270
|
...props
|
|
3465
|
-
}) => /* @__PURE__ */
|
|
4271
|
+
}) => /* @__PURE__ */ jsx21(
|
|
3466
4272
|
"div",
|
|
3467
4273
|
{
|
|
3468
4274
|
"data-slot": "markdown-table-container",
|
|
3469
4275
|
className: "my-5 max-w-full overflow-x-auto rounded-xl border border-border bg-background",
|
|
3470
|
-
children: /* @__PURE__ */
|
|
4276
|
+
children: /* @__PURE__ */ jsx21(
|
|
3471
4277
|
"table",
|
|
3472
4278
|
{
|
|
3473
4279
|
className: cn(
|
|
@@ -3488,7 +4294,7 @@ var defaultComponents = {
|
|
|
3488
4294
|
node: _node,
|
|
3489
4295
|
style,
|
|
3490
4296
|
...props
|
|
3491
|
-
}) => /* @__PURE__ */
|
|
4297
|
+
}) => /* @__PURE__ */ jsx21(
|
|
3492
4298
|
"th",
|
|
3493
4299
|
{
|
|
3494
4300
|
className: cn(
|
|
@@ -3509,7 +4315,7 @@ var defaultComponents = {
|
|
|
3509
4315
|
node: _node,
|
|
3510
4316
|
style,
|
|
3511
4317
|
...props
|
|
3512
|
-
}) => /* @__PURE__ */
|
|
4318
|
+
}) => /* @__PURE__ */ jsx21(
|
|
3513
4319
|
"td",
|
|
3514
4320
|
{
|
|
3515
4321
|
className: cn(
|
|
@@ -3525,7 +4331,7 @@ var defaultComponents = {
|
|
|
3525
4331
|
...props
|
|
3526
4332
|
}
|
|
3527
4333
|
),
|
|
3528
|
-
tr: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4334
|
+
tr: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3529
4335
|
"tr",
|
|
3530
4336
|
{
|
|
3531
4337
|
className: cn(
|
|
@@ -3535,14 +4341,14 @@ var defaultComponents = {
|
|
|
3535
4341
|
...props
|
|
3536
4342
|
}
|
|
3537
4343
|
),
|
|
3538
|
-
sup: ({ className, node: _node, ...props }) => /* @__PURE__ */
|
|
4344
|
+
sup: ({ className, node: _node, ...props }) => /* @__PURE__ */ jsx21(
|
|
3539
4345
|
"sup",
|
|
3540
4346
|
{
|
|
3541
4347
|
className: cn("[&>a]:text-xs [&>a]:no-underline", className),
|
|
3542
4348
|
...props
|
|
3543
4349
|
}
|
|
3544
4350
|
),
|
|
3545
|
-
pre: ({ className, children, node: _node }) => Children.toArray(children).length === 1 && (isMermaidBlockChild(Children.toArray(children)[0]) || isMermaidCodeElement(Children.toArray(children)[0])) ? /* @__PURE__ */
|
|
4351
|
+
pre: ({ className, children, node: _node }) => Children.toArray(children).length === 1 && (isMermaidBlockChild(Children.toArray(children)[0]) || isMermaidCodeElement(Children.toArray(children)[0])) ? /* @__PURE__ */ jsx21(Fragment3, { children }) : /* @__PURE__ */ jsx21(
|
|
3546
4352
|
"div",
|
|
3547
4353
|
{
|
|
3548
4354
|
className: cn(
|
|
@@ -3566,17 +4372,17 @@ var defaultComponents = {
|
|
|
3566
4372
|
const language = match[1];
|
|
3567
4373
|
const normalizedCode = code.replace(/\n$/, "");
|
|
3568
4374
|
if (language === "mermaid") {
|
|
3569
|
-
return /* @__PURE__ */
|
|
4375
|
+
return /* @__PURE__ */ jsx21(MermaidBlock, { code: normalizedCode });
|
|
3570
4376
|
}
|
|
3571
|
-
return /* @__PURE__ */
|
|
3572
|
-
/* @__PURE__ */
|
|
4377
|
+
return /* @__PURE__ */ jsxs12(Fragment3, { children: [
|
|
4378
|
+
/* @__PURE__ */ jsx21(
|
|
3573
4379
|
CodeHeader,
|
|
3574
4380
|
{
|
|
3575
4381
|
language,
|
|
3576
4382
|
code: normalizedCode
|
|
3577
4383
|
}
|
|
3578
4384
|
),
|
|
3579
|
-
/* @__PURE__ */
|
|
4385
|
+
/* @__PURE__ */ jsx21(
|
|
3580
4386
|
SyntaxHighlighter,
|
|
3581
4387
|
{
|
|
3582
4388
|
language,
|
|
@@ -3587,63 +4393,870 @@ var defaultComponents = {
|
|
|
3587
4393
|
] });
|
|
3588
4394
|
}
|
|
3589
4395
|
if (isBlockCode) {
|
|
3590
|
-
return /* @__PURE__ */
|
|
4396
|
+
return /* @__PURE__ */ jsx21(
|
|
3591
4397
|
"code",
|
|
3592
4398
|
{
|
|
3593
4399
|
className: cn(
|
|
3594
|
-
"block min-w-full whitespace-pre px-4 py-4 font-mono text-inherit",
|
|
3595
|
-
className
|
|
4400
|
+
"block min-w-full whitespace-pre px-4 py-4 font-mono text-inherit",
|
|
4401
|
+
className
|
|
4402
|
+
),
|
|
4403
|
+
...props,
|
|
4404
|
+
children: code.replace(/\n$/, "")
|
|
4405
|
+
}
|
|
4406
|
+
);
|
|
4407
|
+
}
|
|
4408
|
+
return /* @__PURE__ */ jsx21(
|
|
4409
|
+
"code",
|
|
4410
|
+
{
|
|
4411
|
+
className: cn(
|
|
4412
|
+
"bg-muted rounded font-mono text-[0.9em] font-semibold whitespace-pre-wrap [overflow-wrap:anywhere]",
|
|
4413
|
+
className
|
|
4414
|
+
),
|
|
4415
|
+
style: {
|
|
4416
|
+
paddingInline: markdownInlineCodePaddingInline,
|
|
4417
|
+
paddingBlock: markdownInlineCodePaddingBlock,
|
|
4418
|
+
...style
|
|
4419
|
+
},
|
|
4420
|
+
...props,
|
|
4421
|
+
children
|
|
4422
|
+
}
|
|
4423
|
+
);
|
|
4424
|
+
}
|
|
4425
|
+
};
|
|
4426
|
+
var MarkdownTextImpl = ({ children }) => {
|
|
4427
|
+
return /* @__PURE__ */ jsx21("div", { className: "markdown-content", children: /* @__PURE__ */ jsx21(
|
|
4428
|
+
ReactMarkdown,
|
|
4429
|
+
{
|
|
4430
|
+
remarkPlugins: [remarkGfm, remarkMath],
|
|
4431
|
+
rehypePlugins: [rehypeKatex],
|
|
4432
|
+
components: defaultComponents,
|
|
4433
|
+
children
|
|
4434
|
+
}
|
|
4435
|
+
) });
|
|
4436
|
+
};
|
|
4437
|
+
var MarkdownText = memo(MarkdownTextImpl);
|
|
4438
|
+
|
|
4439
|
+
// src/components/thread/messages/tool-component-group.tsx
|
|
4440
|
+
import * as React17 from "react";
|
|
4441
|
+
import {
|
|
4442
|
+
Check as Check2,
|
|
4443
|
+
CheckCircle2 as CheckCircle22,
|
|
4444
|
+
ChevronRight as ChevronRight2,
|
|
4445
|
+
Copy,
|
|
4446
|
+
Loader2 as Loader22,
|
|
4447
|
+
XCircle
|
|
4448
|
+
} from "lucide-react";
|
|
4449
|
+
|
|
4450
|
+
// src/i18n/localized-text.ts
|
|
4451
|
+
function resolveLocalizedText(value, language) {
|
|
4452
|
+
if (typeof value === "string") {
|
|
4453
|
+
const trimmed = value.trim();
|
|
4454
|
+
return trimmed || null;
|
|
4455
|
+
}
|
|
4456
|
+
if (!value || typeof value !== "object") return null;
|
|
4457
|
+
const localized = value;
|
|
4458
|
+
const normalizedLanguage = language.trim();
|
|
4459
|
+
const underscoredLanguage = normalizedLanguage.replace(/-/g, "_");
|
|
4460
|
+
const languagePrefix = normalizedLanguage.split("-")[0];
|
|
4461
|
+
const preferredKeys = normalizedLanguage.startsWith("zh") ? [
|
|
4462
|
+
normalizedLanguage,
|
|
4463
|
+
underscoredLanguage,
|
|
4464
|
+
"zh_Hans",
|
|
4465
|
+
"zh-Hans",
|
|
4466
|
+
"zh_CN",
|
|
4467
|
+
"zh-CN",
|
|
4468
|
+
"zh",
|
|
4469
|
+
"en_US",
|
|
4470
|
+
"en-US",
|
|
4471
|
+
"en"
|
|
4472
|
+
] : [
|
|
4473
|
+
normalizedLanguage,
|
|
4474
|
+
underscoredLanguage,
|
|
4475
|
+
"en_US",
|
|
4476
|
+
"en-US",
|
|
4477
|
+
"en",
|
|
4478
|
+
languagePrefix,
|
|
4479
|
+
"zh_Hans",
|
|
4480
|
+
"zh-Hans",
|
|
4481
|
+
"zh_CN",
|
|
4482
|
+
"zh-CN",
|
|
4483
|
+
"zh"
|
|
4484
|
+
];
|
|
4485
|
+
for (const key of preferredKeys) {
|
|
4486
|
+
const candidate = localized[key];
|
|
4487
|
+
if (typeof candidate === "string" && candidate.trim()) {
|
|
4488
|
+
return candidate.trim();
|
|
4489
|
+
}
|
|
4490
|
+
}
|
|
4491
|
+
for (const candidate of Object.values(localized)) {
|
|
4492
|
+
if (typeof candidate === "string" && candidate.trim()) {
|
|
4493
|
+
return candidate.trim();
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
return null;
|
|
4497
|
+
}
|
|
4498
|
+
|
|
4499
|
+
// src/components/thread/messages/tool-component-group.tsx
|
|
4500
|
+
import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
4501
|
+
var toolStatusConfig = {
|
|
4502
|
+
success: {
|
|
4503
|
+
iconClass: "border-green-500 text-green-700",
|
|
4504
|
+
icon: CheckCircle22
|
|
4505
|
+
},
|
|
4506
|
+
fail: {
|
|
4507
|
+
iconClass: "border-red-500 text-red-700",
|
|
4508
|
+
icon: XCircle
|
|
4509
|
+
},
|
|
4510
|
+
running: {
|
|
4511
|
+
iconClass: "border-blue-500 text-blue-700",
|
|
4512
|
+
icon: Loader22
|
|
4513
|
+
}
|
|
4514
|
+
};
|
|
4515
|
+
var TOOL_GROUP_CATEGORY_ORDER = [
|
|
4516
|
+
"files",
|
|
4517
|
+
"searches",
|
|
4518
|
+
"commands",
|
|
4519
|
+
"lists",
|
|
4520
|
+
"tasks",
|
|
4521
|
+
"knowledges",
|
|
4522
|
+
"tools"
|
|
4523
|
+
];
|
|
4524
|
+
var TOOL_GROUP_TOKEN_CATEGORY = {
|
|
4525
|
+
file: "files",
|
|
4526
|
+
files: "files",
|
|
4527
|
+
web_search: "searches",
|
|
4528
|
+
search: "searches",
|
|
4529
|
+
searches: "searches",
|
|
4530
|
+
program: "commands",
|
|
4531
|
+
command: "commands",
|
|
4532
|
+
commands: "commands",
|
|
4533
|
+
shell: "commands",
|
|
4534
|
+
terminal: "commands",
|
|
4535
|
+
list: "lists",
|
|
4536
|
+
lists: "lists",
|
|
4537
|
+
task: "tasks",
|
|
4538
|
+
tasks: "tasks",
|
|
4539
|
+
todo: "tasks",
|
|
4540
|
+
todos: "tasks",
|
|
4541
|
+
knowledge: "knowledges",
|
|
4542
|
+
knowledges: "knowledges",
|
|
4543
|
+
retriever: "knowledges",
|
|
4544
|
+
retrieval: "knowledges",
|
|
4545
|
+
tool: "tools",
|
|
4546
|
+
tools: "tools"
|
|
4547
|
+
};
|
|
4548
|
+
var TOOL_CALL_OUTPUT_RENDERERS = {};
|
|
4549
|
+
function getToolStepData(content) {
|
|
4550
|
+
return content.data ?? {};
|
|
4551
|
+
}
|
|
4552
|
+
function safeJson(value) {
|
|
4553
|
+
try {
|
|
4554
|
+
return JSON.stringify(value, null, 2) ?? String(value);
|
|
4555
|
+
} catch {
|
|
4556
|
+
return String(value);
|
|
4557
|
+
}
|
|
4558
|
+
}
|
|
4559
|
+
function formatDisplayValue(value) {
|
|
4560
|
+
return typeof value === "string" ? value : safeJson(value);
|
|
4561
|
+
}
|
|
4562
|
+
function parseStepDate(value) {
|
|
4563
|
+
if (value instanceof Date) {
|
|
4564
|
+
const timestamp2 = value.getTime();
|
|
4565
|
+
return Number.isNaN(timestamp2) ? null : timestamp2;
|
|
4566
|
+
}
|
|
4567
|
+
if (typeof value !== "string") {
|
|
4568
|
+
return null;
|
|
4569
|
+
}
|
|
4570
|
+
const timestamp = Date.parse(value);
|
|
4571
|
+
return Number.isNaN(timestamp) ? null : timestamp;
|
|
4572
|
+
}
|
|
4573
|
+
function formatStepDuration(durationMs) {
|
|
4574
|
+
if (durationMs < 1e3) {
|
|
4575
|
+
return `${durationMs}ms`;
|
|
4576
|
+
}
|
|
4577
|
+
if (durationMs < 1e4) {
|
|
4578
|
+
return `${(durationMs / 1e3).toFixed(1)}s`;
|
|
4579
|
+
}
|
|
4580
|
+
if (durationMs < 6e4) {
|
|
4581
|
+
return `${Math.round(durationMs / 1e3)}s`;
|
|
4582
|
+
}
|
|
4583
|
+
const hours = Math.floor(durationMs / 36e5);
|
|
4584
|
+
const minutes = Math.floor(durationMs % 36e5 / 6e4);
|
|
4585
|
+
const seconds = Math.floor(durationMs % 6e4 / 1e3);
|
|
4586
|
+
if (hours > 0) {
|
|
4587
|
+
return `${hours}h ${minutes}m ${seconds}s`;
|
|
4588
|
+
}
|
|
4589
|
+
return `${minutes}m ${seconds}s`;
|
|
4590
|
+
}
|
|
4591
|
+
function useToolStepDurationLabel(data) {
|
|
4592
|
+
const [durationNow, setDurationNow] = React17.useState(() => Date.now());
|
|
4593
|
+
const createdAt = parseStepDate(data.created_date);
|
|
4594
|
+
const endedAt = parseStepDate(data.end_date);
|
|
4595
|
+
const status = data.status;
|
|
4596
|
+
React17.useEffect(() => {
|
|
4597
|
+
if (status !== "running" || createdAt === null || endedAt !== null) {
|
|
4598
|
+
return;
|
|
4599
|
+
}
|
|
4600
|
+
setDurationNow(Date.now());
|
|
4601
|
+
const timer = window.setInterval(() => {
|
|
4602
|
+
setDurationNow(Date.now());
|
|
4603
|
+
}, 100);
|
|
4604
|
+
return () => {
|
|
4605
|
+
window.clearInterval(timer);
|
|
4606
|
+
};
|
|
4607
|
+
}, [createdAt, endedAt, status]);
|
|
4608
|
+
if (createdAt === null) return null;
|
|
4609
|
+
const durationMs = Math.max(0, (endedAt ?? durationNow) - createdAt);
|
|
4610
|
+
return formatStepDuration(durationMs);
|
|
4611
|
+
}
|
|
4612
|
+
function isJsonObjectValue(value) {
|
|
4613
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4614
|
+
}
|
|
4615
|
+
function canUseAsJsonValue(value) {
|
|
4616
|
+
if (value === null) return true;
|
|
4617
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
4618
|
+
return true;
|
|
4619
|
+
}
|
|
4620
|
+
if (Array.isArray(value)) {
|
|
4621
|
+
return value.every(canUseAsJsonValue);
|
|
4622
|
+
}
|
|
4623
|
+
if (typeof value === "object") {
|
|
4624
|
+
return Object.values(value).every(canUseAsJsonValue);
|
|
4625
|
+
}
|
|
4626
|
+
return false;
|
|
4627
|
+
}
|
|
4628
|
+
function parseJsonString(value) {
|
|
4629
|
+
const trimmed = value.trim();
|
|
4630
|
+
if (!trimmed) return null;
|
|
4631
|
+
const first = trimmed[0];
|
|
4632
|
+
if (first !== "{" && first !== "[") return null;
|
|
4633
|
+
try {
|
|
4634
|
+
const parsed = JSON.parse(trimmed);
|
|
4635
|
+
return canUseAsJsonValue(parsed) ? parsed : null;
|
|
4636
|
+
} catch {
|
|
4637
|
+
return null;
|
|
4638
|
+
}
|
|
4639
|
+
}
|
|
4640
|
+
function detectJsonValue(value) {
|
|
4641
|
+
if (typeof value === "string") {
|
|
4642
|
+
const parsed = parseJsonString(value);
|
|
4643
|
+
if (parsed !== null) {
|
|
4644
|
+
return {
|
|
4645
|
+
kind: "json",
|
|
4646
|
+
value: parsed,
|
|
4647
|
+
raw: safeJson(parsed)
|
|
4648
|
+
};
|
|
4649
|
+
}
|
|
4650
|
+
return { kind: "text", text: value };
|
|
4651
|
+
}
|
|
4652
|
+
if (canUseAsJsonValue(value) && value !== null && typeof value === "object") {
|
|
4653
|
+
return {
|
|
4654
|
+
kind: "json",
|
|
4655
|
+
value,
|
|
4656
|
+
raw: safeJson(value)
|
|
4657
|
+
};
|
|
4658
|
+
}
|
|
4659
|
+
return { kind: "text", text: formatDisplayValue(value) };
|
|
4660
|
+
}
|
|
4661
|
+
function isComponentContent(content) {
|
|
4662
|
+
return content.type === "component";
|
|
4663
|
+
}
|
|
4664
|
+
function isTextContent(content) {
|
|
4665
|
+
return content.type === "text";
|
|
4666
|
+
}
|
|
4667
|
+
function isReasoningContent(content) {
|
|
4668
|
+
return content.type === "reasoning";
|
|
4669
|
+
}
|
|
4670
|
+
function isWidgetComponent(content) {
|
|
4671
|
+
const data = content.data;
|
|
4672
|
+
return data?.type === "Widget" && Array.isArray(data.widgets);
|
|
4673
|
+
}
|
|
4674
|
+
function isGroupableToolComponent(content) {
|
|
4675
|
+
if (!content || typeof content === "string") return false;
|
|
4676
|
+
return isComponentContent(content) && !isWidgetComponent(content) && content.data?.category === "Tool";
|
|
4677
|
+
}
|
|
4678
|
+
function isSkippableToolGroupSeparator(content) {
|
|
4679
|
+
if (typeof content === "string") return !content.trim();
|
|
4680
|
+
if (!content) return true;
|
|
4681
|
+
if (isTextContent(content)) {
|
|
4682
|
+
return !content.text?.trim();
|
|
4683
|
+
}
|
|
4684
|
+
if (isReasoningContent(content)) {
|
|
4685
|
+
return !content.text?.trim();
|
|
4686
|
+
}
|
|
4687
|
+
return false;
|
|
4688
|
+
}
|
|
4689
|
+
function normalizeToolToken(value) {
|
|
4690
|
+
if (typeof value !== "string") return null;
|
|
4691
|
+
const normalized = value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
4692
|
+
return normalized || null;
|
|
4693
|
+
}
|
|
4694
|
+
function classifyToolToken(value) {
|
|
4695
|
+
const normalized = normalizeToolToken(
|
|
4696
|
+
typeof value === "string" ? value : resolveLocalizedText(value, "en-US")
|
|
4697
|
+
);
|
|
4698
|
+
if (!normalized) return null;
|
|
4699
|
+
const directMatch = TOOL_GROUP_TOKEN_CATEGORY[normalized];
|
|
4700
|
+
if (directMatch) return directMatch;
|
|
4701
|
+
if (normalized.includes("search")) return "searches";
|
|
4702
|
+
if (normalized.includes("file")) return "files";
|
|
4703
|
+
if (normalized.includes("command") || normalized.includes("cmd") || normalized.includes("program") || normalized.includes("exec") || normalized.startsWith("run_") || normalized.includes("_run")) {
|
|
4704
|
+
return "commands";
|
|
4705
|
+
}
|
|
4706
|
+
if (normalized.includes("list")) return "lists";
|
|
4707
|
+
if (normalized.includes("task") || normalized.includes("todo")) return "tasks";
|
|
4708
|
+
if (normalized.includes("knowledge") || normalized.includes("retriever")) {
|
|
4709
|
+
return "knowledges";
|
|
4710
|
+
}
|
|
4711
|
+
return null;
|
|
4712
|
+
}
|
|
4713
|
+
function getToolGroupCategory(content) {
|
|
4714
|
+
const data = getToolStepData(content);
|
|
4715
|
+
return classifyToolToken(data.type) ?? classifyToolToken(data.tool) ?? classifyToolToken(data.title) ?? classifyToolToken(data.message) ?? "tools";
|
|
4716
|
+
}
|
|
4717
|
+
function getToolGroupCategoryCounts(items) {
|
|
4718
|
+
return items.reduce((counts, item) => {
|
|
4719
|
+
const category = getToolGroupCategory(item);
|
|
4720
|
+
counts[category] = (counts[category] ?? 0) + 1;
|
|
4721
|
+
return counts;
|
|
4722
|
+
}, {});
|
|
4723
|
+
}
|
|
4724
|
+
function getToolGroupDisplayStatus(items) {
|
|
4725
|
+
if (items.some((item) => getToolStepData(item).status === "fail")) {
|
|
4726
|
+
return "fail";
|
|
4727
|
+
}
|
|
4728
|
+
return "success";
|
|
4729
|
+
}
|
|
4730
|
+
function getToolActivityLabel(content, language) {
|
|
4731
|
+
const data = getToolStepData(content);
|
|
4732
|
+
const runningCandidates = [data.message, data.title, data.tool, data.type];
|
|
4733
|
+
const completedCandidates = [data.title, data.message, data.tool, data.type];
|
|
4734
|
+
const candidates = data.status === "running" ? runningCandidates : completedCandidates;
|
|
4735
|
+
for (const candidate of candidates) {
|
|
4736
|
+
const label = resolveLocalizedText(candidate, language);
|
|
4737
|
+
if (label) return label;
|
|
4738
|
+
}
|
|
4739
|
+
return "Tool";
|
|
4740
|
+
}
|
|
4741
|
+
function flushPendingTools(units, pendingTools) {
|
|
4742
|
+
if (pendingTools.length === 0) return;
|
|
4743
|
+
units.push({
|
|
4744
|
+
type: "tool-group",
|
|
4745
|
+
items: pendingTools.map((tool) => tool.item),
|
|
4746
|
+
startIndex: pendingTools[0].index
|
|
4747
|
+
});
|
|
4748
|
+
pendingTools.length = 0;
|
|
4749
|
+
}
|
|
4750
|
+
function buildToolComponentRenderUnits(content, options) {
|
|
4751
|
+
const units = [];
|
|
4752
|
+
const pendingTools = [];
|
|
4753
|
+
content.forEach((item, index) => {
|
|
4754
|
+
if (isGroupableToolComponent(item) && options?.shouldGroupComponent?.(item) !== false) {
|
|
4755
|
+
pendingTools.push({ item, index });
|
|
4756
|
+
return;
|
|
4757
|
+
}
|
|
4758
|
+
if (isSkippableToolGroupSeparator(item)) {
|
|
4759
|
+
return;
|
|
4760
|
+
}
|
|
4761
|
+
if (item === void 0) {
|
|
4762
|
+
return;
|
|
4763
|
+
}
|
|
4764
|
+
flushPendingTools(units, pendingTools);
|
|
4765
|
+
units.push({ type: "item", item, index });
|
|
4766
|
+
});
|
|
4767
|
+
flushPendingTools(units, pendingTools);
|
|
4768
|
+
return units;
|
|
4769
|
+
}
|
|
4770
|
+
function getToolCallOutputRenderer(data) {
|
|
4771
|
+
const keys = [data.tool, data.type].filter(
|
|
4772
|
+
(value) => typeof value === "string" && Boolean(value.trim())
|
|
4773
|
+
);
|
|
4774
|
+
for (const key of keys) {
|
|
4775
|
+
const renderer = TOOL_CALL_OUTPUT_RENDERERS[key];
|
|
4776
|
+
if (renderer) return renderer;
|
|
4777
|
+
}
|
|
4778
|
+
return DefaultToolCallOutput;
|
|
4779
|
+
}
|
|
4780
|
+
function getJsonValueSummary(value) {
|
|
4781
|
+
if (Array.isArray(value)) {
|
|
4782
|
+
return `Array(${value.length})`;
|
|
4783
|
+
}
|
|
4784
|
+
if (isJsonObjectValue(value)) {
|
|
4785
|
+
return `Object(${Object.keys(value).length})`;
|
|
4786
|
+
}
|
|
4787
|
+
return "JSON";
|
|
4788
|
+
}
|
|
4789
|
+
function formatJsonPrimitive(value) {
|
|
4790
|
+
if (value === null) return "null";
|
|
4791
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
4792
|
+
return String(value);
|
|
4793
|
+
}
|
|
4794
|
+
function JsonTreeNode({
|
|
4795
|
+
label,
|
|
4796
|
+
value,
|
|
4797
|
+
depth = 0
|
|
4798
|
+
}) {
|
|
4799
|
+
const isArray = Array.isArray(value);
|
|
4800
|
+
const isObject = isJsonObjectValue(value);
|
|
4801
|
+
const isExpandable = isArray || isObject;
|
|
4802
|
+
const [isExpanded, setIsExpanded] = React17.useState(depth < 2);
|
|
4803
|
+
if (!isExpandable) {
|
|
4804
|
+
return /* @__PURE__ */ jsxs13("div", { className: "flex min-w-0 gap-2 leading-6", children: [
|
|
4805
|
+
label ? /* @__PURE__ */ jsxs13("span", { className: "shrink-0 font-medium text-foreground/80", children: [
|
|
4806
|
+
label,
|
|
4807
|
+
":"
|
|
4808
|
+
] }) : null,
|
|
4809
|
+
/* @__PURE__ */ jsx22(
|
|
4810
|
+
"span",
|
|
4811
|
+
{
|
|
4812
|
+
className: cn(
|
|
4813
|
+
"min-w-0 wrap-break-word",
|
|
4814
|
+
typeof value === "string" ? "text-emerald-700" : typeof value === "number" ? "text-blue-700" : typeof value === "boolean" ? "text-purple-700" : "text-muted-foreground"
|
|
3596
4815
|
),
|
|
3597
|
-
|
|
3598
|
-
children: code.replace(/\n$/, "")
|
|
4816
|
+
children: formatJsonPrimitive(value)
|
|
3599
4817
|
}
|
|
3600
|
-
)
|
|
4818
|
+
)
|
|
4819
|
+
] });
|
|
4820
|
+
}
|
|
4821
|
+
const entries = isArray ? value.map((item, index) => [String(index), item]) : Object.entries(value);
|
|
4822
|
+
const summary = isArray ? `Array(${value.length})` : `Object(${entries.length})`;
|
|
4823
|
+
return /* @__PURE__ */ jsxs13("div", { className: "min-w-0", children: [
|
|
4824
|
+
/* @__PURE__ */ jsxs13(
|
|
4825
|
+
"button",
|
|
4826
|
+
{
|
|
4827
|
+
type: "button",
|
|
4828
|
+
className: "flex min-w-0 items-center gap-1 leading-6 text-left hover:text-foreground",
|
|
4829
|
+
"aria-expanded": isExpanded,
|
|
4830
|
+
onClick: () => setIsExpanded((prev) => !prev),
|
|
4831
|
+
children: [
|
|
4832
|
+
/* @__PURE__ */ jsx22(
|
|
4833
|
+
ChevronRight2,
|
|
4834
|
+
{
|
|
4835
|
+
"aria-hidden": "true",
|
|
4836
|
+
className: cn(
|
|
4837
|
+
"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",
|
|
4838
|
+
isExpanded && "rotate-90"
|
|
4839
|
+
)
|
|
4840
|
+
}
|
|
4841
|
+
),
|
|
4842
|
+
label ? /* @__PURE__ */ jsxs13("span", { className: "min-w-0 truncate font-medium text-foreground/80", children: [
|
|
4843
|
+
label,
|
|
4844
|
+
":"
|
|
4845
|
+
] }) : null,
|
|
4846
|
+
/* @__PURE__ */ jsx22("span", { className: "shrink-0 text-muted-foreground", children: summary })
|
|
4847
|
+
]
|
|
4848
|
+
}
|
|
4849
|
+
),
|
|
4850
|
+
isExpanded ? /* @__PURE__ */ jsx22("div", { className: "ml-4 border-l border-border/70 pl-3", children: entries.map(([entryLabel, entryValue]) => /* @__PURE__ */ jsx22(
|
|
4851
|
+
JsonTreeNode,
|
|
4852
|
+
{
|
|
4853
|
+
label: entryLabel,
|
|
4854
|
+
value: entryValue,
|
|
4855
|
+
depth: depth + 1
|
|
4856
|
+
},
|
|
4857
|
+
entryLabel
|
|
4858
|
+
)) }) : null
|
|
4859
|
+
] });
|
|
4860
|
+
}
|
|
4861
|
+
function JsonTreeView({ value }) {
|
|
4862
|
+
return /* @__PURE__ */ jsx22("div", { className: "min-w-0 font-mono text-[11px]", children: /* @__PURE__ */ jsx22(JsonTreeNode, { value }) });
|
|
4863
|
+
}
|
|
4864
|
+
function RawJsonBlock({ raw }) {
|
|
4865
|
+
return /* @__PURE__ */ jsx22("pre", { className: "whitespace-pre-wrap wrap-break-word font-mono text-[11px]", children: raw });
|
|
4866
|
+
}
|
|
4867
|
+
function PlainTextBlock({ value, destructive = false }) {
|
|
4868
|
+
return /* @__PURE__ */ jsx22(
|
|
4869
|
+
"pre",
|
|
4870
|
+
{
|
|
4871
|
+
className: cn(
|
|
4872
|
+
"whitespace-pre-wrap wrap-break-word",
|
|
4873
|
+
destructive && "text-destructive"
|
|
4874
|
+
),
|
|
4875
|
+
children: value
|
|
3601
4876
|
}
|
|
3602
|
-
|
|
3603
|
-
|
|
4877
|
+
);
|
|
4878
|
+
}
|
|
4879
|
+
function ToolCallCopyButton({ value }) {
|
|
4880
|
+
const { t } = useChatkitTranslation();
|
|
4881
|
+
const [isCopied, setIsCopied] = React17.useState(false);
|
|
4882
|
+
const resetTimeoutRef = React17.useRef(null);
|
|
4883
|
+
const clearResetTimeout = React17.useCallback(() => {
|
|
4884
|
+
if (resetTimeoutRef.current === null) return;
|
|
4885
|
+
window.clearTimeout(resetTimeoutRef.current);
|
|
4886
|
+
resetTimeoutRef.current = null;
|
|
4887
|
+
}, []);
|
|
4888
|
+
React17.useEffect(() => clearResetTimeout, [clearResetTimeout]);
|
|
4889
|
+
const handleCopy = React17.useCallback(() => {
|
|
4890
|
+
if (typeof navigator === "undefined" || !navigator.clipboard) return;
|
|
4891
|
+
void navigator.clipboard.writeText(value).then(() => {
|
|
4892
|
+
setIsCopied(true);
|
|
4893
|
+
clearResetTimeout();
|
|
4894
|
+
resetTimeoutRef.current = window.setTimeout(() => {
|
|
4895
|
+
setIsCopied(false);
|
|
4896
|
+
resetTimeoutRef.current = null;
|
|
4897
|
+
}, 1500);
|
|
4898
|
+
}).catch(() => void 0);
|
|
4899
|
+
}, [clearResetTimeout, value]);
|
|
4900
|
+
const label = isCopied ? t("message.toolGroup.copied") : t("message.toolGroup.copy");
|
|
4901
|
+
return /* @__PURE__ */ jsx22(
|
|
4902
|
+
"button",
|
|
4903
|
+
{
|
|
4904
|
+
type: "button",
|
|
4905
|
+
className: "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
|
|
4906
|
+
"aria-label": label,
|
|
4907
|
+
title: label,
|
|
4908
|
+
onClick: handleCopy,
|
|
4909
|
+
children: isCopied ? /* @__PURE__ */ jsx22(Check2, { className: "h-3.5 w-3.5", "aria-hidden": "true" }) : /* @__PURE__ */ jsx22(Copy, { className: "h-3.5 w-3.5", "aria-hidden": "true" })
|
|
4910
|
+
}
|
|
4911
|
+
);
|
|
4912
|
+
}
|
|
4913
|
+
function ToolCallValueBlock({
|
|
4914
|
+
value,
|
|
4915
|
+
destructive = false
|
|
4916
|
+
}) {
|
|
4917
|
+
const { t } = useChatkitTranslation();
|
|
4918
|
+
const detected = detectJsonValue(value);
|
|
4919
|
+
if (detected.kind === "text") {
|
|
4920
|
+
return /* @__PURE__ */ jsxs13("div", { className: "min-w-0 space-y-1", children: [
|
|
4921
|
+
/* @__PURE__ */ jsx22("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx22(ToolCallCopyButton, { value: detected.text }) }),
|
|
4922
|
+
/* @__PURE__ */ jsx22(PlainTextBlock, { value: detected.text, destructive })
|
|
4923
|
+
] });
|
|
4924
|
+
}
|
|
4925
|
+
return /* @__PURE__ */ jsxs13(Tabs, { defaultValue: "tree", className: "min-w-0", children: [
|
|
4926
|
+
/* @__PURE__ */ jsxs13("div", { className: "mb-2 flex min-w-0 items-center justify-between gap-2", children: [
|
|
4927
|
+
/* @__PURE__ */ jsxs13("span", { className: "min-w-0 truncate text-[11px] text-muted-foreground", children: [
|
|
4928
|
+
t("message.toolGroup.jsonTitle"),
|
|
4929
|
+
" \xB7 ",
|
|
4930
|
+
getJsonValueSummary(detected.value)
|
|
4931
|
+
] }),
|
|
4932
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
4933
|
+
/* @__PURE__ */ jsx22(ToolCallCopyButton, { value: detected.raw }),
|
|
4934
|
+
/* @__PURE__ */ jsxs13(TabsList, { className: "rounded-md p-0.5", children: [
|
|
4935
|
+
/* @__PURE__ */ jsx22(TabsTrigger, { className: "px-2 py-0.5 text-[11px]", value: "tree", children: t("message.toolGroup.jsonTree") }),
|
|
4936
|
+
/* @__PURE__ */ jsx22(TabsTrigger, { className: "px-2 py-0.5 text-[11px]", value: "raw", children: t("message.toolGroup.jsonRaw") })
|
|
4937
|
+
] })
|
|
4938
|
+
] })
|
|
4939
|
+
] }),
|
|
4940
|
+
/* @__PURE__ */ jsx22(TabsContent, { value: "tree", className: "mt-0", children: /* @__PURE__ */ jsx22(JsonTreeView, { value: detected.value }) }),
|
|
4941
|
+
/* @__PURE__ */ jsx22(TabsContent, { value: "raw", className: "mt-0", children: /* @__PURE__ */ jsx22(RawJsonBlock, { raw: detected.raw }) })
|
|
4942
|
+
] });
|
|
4943
|
+
}
|
|
4944
|
+
function DefaultToolCallOutput({ data }) {
|
|
4945
|
+
const { t } = useChatkitTranslation();
|
|
4946
|
+
const output = data.output ?? null;
|
|
4947
|
+
const error = data.error ?? null;
|
|
4948
|
+
if (error) {
|
|
4949
|
+
return /* @__PURE__ */ jsxs13("div", { className: "space-y-1", children: [
|
|
4950
|
+
/* @__PURE__ */ jsx22("div", { className: "text-[11px] font-medium text-destructive", children: t("message.toolGroup.errorTitle") }),
|
|
4951
|
+
/* @__PURE__ */ jsx22(ToolCallValueBlock, { value: error, destructive: true })
|
|
4952
|
+
] });
|
|
4953
|
+
}
|
|
4954
|
+
if (output === null) return null;
|
|
4955
|
+
return /* @__PURE__ */ jsxs13("div", { className: "space-y-1", children: [
|
|
4956
|
+
/* @__PURE__ */ jsx22("div", { className: "text-[11px] font-medium text-muted-foreground", children: t("message.toolGroup.outputTitle") }),
|
|
4957
|
+
/* @__PURE__ */ jsx22(ToolCallValueBlock, { value: output })
|
|
4958
|
+
] });
|
|
4959
|
+
}
|
|
4960
|
+
function ToolCallDetails({ content }) {
|
|
4961
|
+
const { t } = useChatkitTranslation();
|
|
4962
|
+
const data = getToolStepData(content);
|
|
4963
|
+
const OutputRenderer = getToolCallOutputRenderer(data);
|
|
4964
|
+
const hasInput = data.input !== void 0 && data.input !== null;
|
|
4965
|
+
const hasOutput = data.error !== void 0 || data.output !== void 0;
|
|
4966
|
+
if (!hasInput && !hasOutput) return null;
|
|
4967
|
+
return /* @__PURE__ */ jsxs13("div", { className: "ml-6 mt-1 max-h-60 overflow-auto rounded-md bg-muted/30 px-3 py-2 text-xs text-muted-foreground", children: [
|
|
4968
|
+
hasInput && /* @__PURE__ */ jsxs13("div", { className: "space-y-1", children: [
|
|
4969
|
+
/* @__PURE__ */ jsx22("div", { className: "text-[11px] font-medium text-muted-foreground", children: t("message.toolGroup.inputTitle") }),
|
|
4970
|
+
/* @__PURE__ */ jsx22(ToolCallValueBlock, { value: data.input })
|
|
4971
|
+
] }),
|
|
4972
|
+
hasInput && hasOutput ? /* @__PURE__ */ jsx22("div", { className: "h-2" }) : null,
|
|
4973
|
+
hasOutput ? /* @__PURE__ */ jsx22(OutputRenderer, { content, data }) : null
|
|
4974
|
+
] });
|
|
4975
|
+
}
|
|
4976
|
+
function ToolCallRow({ content }) {
|
|
4977
|
+
const { i18n: i18n2 } = useChatkitTranslation();
|
|
4978
|
+
const data = getToolStepData(content);
|
|
4979
|
+
const status = data.status;
|
|
4980
|
+
const itemConfig = status ? toolStatusConfig[status] : null;
|
|
4981
|
+
const ItemStatusIcon = itemConfig?.icon;
|
|
4982
|
+
const hasError = status === "fail" || Boolean(data.error);
|
|
4983
|
+
const label = getToolActivityLabel(content, i18n2.language);
|
|
4984
|
+
const detailsId = React17.useId();
|
|
4985
|
+
const hasDetails = data.input !== void 0 || data.error !== void 0 || data.output !== void 0;
|
|
4986
|
+
const durationLabel = useToolStepDurationLabel(data);
|
|
4987
|
+
const [isExpanded, setIsExpanded] = React17.useState(false);
|
|
4988
|
+
React17.useEffect(() => {
|
|
4989
|
+
if (status === "running" && data.output !== void 0) {
|
|
4990
|
+
setIsExpanded(true);
|
|
4991
|
+
}
|
|
4992
|
+
}, [data.output, status]);
|
|
4993
|
+
return /* @__PURE__ */ jsxs13("li", { className: "min-w-0", children: [
|
|
4994
|
+
/* @__PURE__ */ jsxs13(
|
|
4995
|
+
"button",
|
|
3604
4996
|
{
|
|
4997
|
+
type: "button",
|
|
3605
4998
|
className: cn(
|
|
3606
|
-
"
|
|
3607
|
-
|
|
4999
|
+
"flex w-full min-w-0 items-center gap-2 text-left text-sm leading-6 text-muted-foreground",
|
|
5000
|
+
hasDetails && "cursor-pointer hover:text-foreground",
|
|
5001
|
+
hasError && "text-destructive hover:text-destructive"
|
|
3608
5002
|
),
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
5003
|
+
"aria-expanded": hasDetails ? isExpanded : void 0,
|
|
5004
|
+
"aria-controls": hasDetails ? detailsId : void 0,
|
|
5005
|
+
disabled: !hasDetails,
|
|
5006
|
+
onClick: () => {
|
|
5007
|
+
if (hasDetails) setIsExpanded((prev) => !prev);
|
|
3613
5008
|
},
|
|
3614
|
-
|
|
3615
|
-
|
|
5009
|
+
children: [
|
|
5010
|
+
ItemStatusIcon ? /* @__PURE__ */ jsx22(
|
|
5011
|
+
ItemStatusIcon,
|
|
5012
|
+
{
|
|
5013
|
+
className: cn(
|
|
5014
|
+
"h-3.5 w-3.5 shrink-0",
|
|
5015
|
+
itemConfig?.iconClass,
|
|
5016
|
+
status === "running" && "animate-spin"
|
|
5017
|
+
)
|
|
5018
|
+
}
|
|
5019
|
+
) : /* @__PURE__ */ jsx22("span", { className: "h-3.5 w-3.5 shrink-0", "aria-hidden": "true" }),
|
|
5020
|
+
/* @__PURE__ */ jsx22("span", { className: "min-w-0 flex-1 truncate", title: label, children: label }),
|
|
5021
|
+
durationLabel ? /* @__PURE__ */ jsx22("span", { className: "shrink-0 text-[11px] tabular-nums text-muted-foreground/80", children: durationLabel }) : null,
|
|
5022
|
+
hasDetails ? /* @__PURE__ */ jsx22(
|
|
5023
|
+
ChevronRight2,
|
|
5024
|
+
{
|
|
5025
|
+
"aria-hidden": "true",
|
|
5026
|
+
className: cn(
|
|
5027
|
+
"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",
|
|
5028
|
+
isExpanded && "rotate-90"
|
|
5029
|
+
)
|
|
5030
|
+
}
|
|
5031
|
+
) : null
|
|
5032
|
+
]
|
|
3616
5033
|
}
|
|
3617
|
-
)
|
|
5034
|
+
),
|
|
5035
|
+
hasDetails && isExpanded ? /* @__PURE__ */ jsx22("div", { id: detailsId, children: /* @__PURE__ */ jsx22(ToolCallDetails, { content }) }) : null
|
|
5036
|
+
] });
|
|
5037
|
+
}
|
|
5038
|
+
function ToolComponentGroup({
|
|
5039
|
+
items,
|
|
5040
|
+
hasFollowingItem
|
|
5041
|
+
}) {
|
|
5042
|
+
const { t } = useChatkitTranslation();
|
|
5043
|
+
const contentId = React17.useId();
|
|
5044
|
+
const groupStatus = getToolGroupDisplayStatus(items);
|
|
5045
|
+
const [isExpanded, setIsExpanded] = React17.useState(!hasFollowingItem);
|
|
5046
|
+
const categoryCounts = getToolGroupCategoryCounts(items);
|
|
5047
|
+
const categorySummary = TOOL_GROUP_CATEGORY_ORDER.flatMap((category) => {
|
|
5048
|
+
const count = categoryCounts[category] ?? 0;
|
|
5049
|
+
if (count === 0) return [];
|
|
5050
|
+
return [
|
|
5051
|
+
t(
|
|
5052
|
+
`message.toolGroup.categories.${category}.${count === 1 ? "one" : "other"}`,
|
|
5053
|
+
{ count }
|
|
5054
|
+
)
|
|
5055
|
+
];
|
|
5056
|
+
}).join(t("message.toolGroup.separator"));
|
|
5057
|
+
const summary = `${t(`message.toolGroup.status.${groupStatus}`)} ${categorySummary}`;
|
|
5058
|
+
const config = toolStatusConfig[groupStatus];
|
|
5059
|
+
const StatusIcon = config.icon;
|
|
5060
|
+
React17.useEffect(() => {
|
|
5061
|
+
setIsExpanded(!hasFollowingItem);
|
|
5062
|
+
}, [hasFollowingItem, items.length]);
|
|
5063
|
+
return /* @__PURE__ */ jsxs13("div", { className: "px-1 py-1", children: [
|
|
5064
|
+
/* @__PURE__ */ jsxs13(
|
|
5065
|
+
"button",
|
|
5066
|
+
{
|
|
5067
|
+
type: "button",
|
|
5068
|
+
className: "flex w-full items-center justify-between gap-3 text-left opacity-60 hover:opacity-100 disabled:pointer-events-none data-[state=open]:bg-muted",
|
|
5069
|
+
"aria-expanded": isExpanded,
|
|
5070
|
+
"aria-controls": contentId,
|
|
5071
|
+
onClick: () => setIsExpanded((prev) => !prev),
|
|
5072
|
+
children: [
|
|
5073
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex min-w-0 items-center gap-2 text-sm font-medium text-muted-foreground", children: [
|
|
5074
|
+
/* @__PURE__ */ jsx22(
|
|
5075
|
+
StatusIcon,
|
|
5076
|
+
{
|
|
5077
|
+
className: cn(
|
|
5078
|
+
"h-4 w-4 shrink-0",
|
|
5079
|
+
config.iconClass
|
|
5080
|
+
)
|
|
5081
|
+
}
|
|
5082
|
+
),
|
|
5083
|
+
/* @__PURE__ */ jsx22("span", { className: "truncate", children: summary })
|
|
5084
|
+
] }),
|
|
5085
|
+
/* @__PURE__ */ jsx22(
|
|
5086
|
+
ChevronRight2,
|
|
5087
|
+
{
|
|
5088
|
+
"aria-hidden": "true",
|
|
5089
|
+
className: cn(
|
|
5090
|
+
"h-4 w-4 shrink-0 text-muted-foreground transition-transform",
|
|
5091
|
+
isExpanded && "rotate-90"
|
|
5092
|
+
)
|
|
5093
|
+
}
|
|
5094
|
+
)
|
|
5095
|
+
]
|
|
5096
|
+
}
|
|
5097
|
+
),
|
|
5098
|
+
isExpanded && /* @__PURE__ */ jsx22("ul", { id: contentId, className: "mt-2 max-h-[200px] space-y-1.5 overflow-y-auto pr-1", children: items.map((item, index) => /* @__PURE__ */ jsx22(ToolCallRow, { content: item }, item.id ?? `tool-item-${index}`)) })
|
|
5099
|
+
] });
|
|
5100
|
+
}
|
|
5101
|
+
|
|
5102
|
+
// src/components/thread/messages/request-user-input-result-card.tsx
|
|
5103
|
+
import "react";
|
|
5104
|
+
import {
|
|
5105
|
+
REQUEST_USER_INPUT_TOOL_NAME as REQUEST_USER_INPUT_TOOL_NAME2
|
|
5106
|
+
} from "@xpert-ai/chatkit-types";
|
|
5107
|
+
import { CheckCircle2 as CheckCircle23 } from "lucide-react";
|
|
5108
|
+
import { jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5109
|
+
function isRecord2(value) {
|
|
5110
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
5111
|
+
}
|
|
5112
|
+
function readString(record, keys) {
|
|
5113
|
+
for (const key of keys) {
|
|
5114
|
+
const value = record[key];
|
|
5115
|
+
if (typeof value === "string" && value.trim()) {
|
|
5116
|
+
return value.trim();
|
|
5117
|
+
}
|
|
3618
5118
|
}
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
5119
|
+
return null;
|
|
5120
|
+
}
|
|
5121
|
+
function getToolCallId(value) {
|
|
5122
|
+
if (!isRecord2(value)) return null;
|
|
5123
|
+
return readString(value, ["id"]);
|
|
5124
|
+
}
|
|
5125
|
+
function getToolCallName(value) {
|
|
5126
|
+
if (!isRecord2(value)) return null;
|
|
5127
|
+
return readString(value, ["name"]);
|
|
5128
|
+
}
|
|
5129
|
+
function pushClientToolCallsFromRecord(record, calls) {
|
|
5130
|
+
const clientToolCalls = record.clientToolCalls;
|
|
5131
|
+
if (Array.isArray(clientToolCalls)) {
|
|
5132
|
+
calls.push(...clientToolCalls);
|
|
5133
|
+
}
|
|
5134
|
+
}
|
|
5135
|
+
function collectPotentialToolCalls(messages) {
|
|
5136
|
+
const calls = [];
|
|
5137
|
+
const messageList = Array.isArray(messages) ? messages : [messages];
|
|
5138
|
+
for (const message of messageList) {
|
|
5139
|
+
const rawMessage = message;
|
|
5140
|
+
pushClientToolCallsFromRecord(rawMessage, calls);
|
|
5141
|
+
}
|
|
5142
|
+
return calls;
|
|
5143
|
+
}
|
|
5144
|
+
function findRequestUserInputClientToolCallById(messages, id) {
|
|
5145
|
+
if (!id) return null;
|
|
5146
|
+
return collectPotentialToolCalls(messages).find(
|
|
5147
|
+
(call) => getToolCallId(call) === id && getToolCallName(call) === REQUEST_USER_INPUT_TOOL_NAME2
|
|
5148
|
+
) ?? null;
|
|
5149
|
+
}
|
|
5150
|
+
function normalizeAnswer(value) {
|
|
5151
|
+
if (!isRecord2(value)) return null;
|
|
5152
|
+
const id = readString(value, ["id"]);
|
|
5153
|
+
const question = readString(value, ["question"]);
|
|
5154
|
+
const answerValue = readString(value, ["value"]);
|
|
5155
|
+
const type = readString(value, ["type"]);
|
|
5156
|
+
if (!id || !question || !answerValue || type !== "option" && type !== "other") {
|
|
5157
|
+
return null;
|
|
5158
|
+
}
|
|
5159
|
+
const label = readString(value, ["label"]);
|
|
5160
|
+
const description = readString(value, ["description"]);
|
|
5161
|
+
return {
|
|
5162
|
+
id,
|
|
5163
|
+
question,
|
|
5164
|
+
value: answerValue,
|
|
5165
|
+
type,
|
|
5166
|
+
...label ? { label } : {},
|
|
5167
|
+
...description ? { description } : {}
|
|
5168
|
+
};
|
|
5169
|
+
}
|
|
5170
|
+
function parseResultOutput(output) {
|
|
5171
|
+
let result = output;
|
|
5172
|
+
if (typeof output === "string") {
|
|
5173
|
+
try {
|
|
5174
|
+
result = JSON.parse(output);
|
|
5175
|
+
} catch {
|
|
5176
|
+
return null;
|
|
5177
|
+
}
|
|
5178
|
+
}
|
|
5179
|
+
if (!isRecord2(result) || !Array.isArray(result.answers)) {
|
|
5180
|
+
return null;
|
|
5181
|
+
}
|
|
5182
|
+
const answers = result.answers.map(normalizeAnswer);
|
|
5183
|
+
if (answers.some((answer) => answer === null)) {
|
|
5184
|
+
return null;
|
|
5185
|
+
}
|
|
5186
|
+
return answers;
|
|
5187
|
+
}
|
|
5188
|
+
function getRequestUserInputResultCardData(content, messages) {
|
|
5189
|
+
const data = isRecord2(content.data) ? content.data : null;
|
|
5190
|
+
if (data?.status !== "success") {
|
|
5191
|
+
return null;
|
|
5192
|
+
}
|
|
5193
|
+
const toolCall = findRequestUserInputClientToolCallById(messages, content.id);
|
|
5194
|
+
if (!toolCall) {
|
|
5195
|
+
return null;
|
|
5196
|
+
}
|
|
5197
|
+
const answers = parseResultOutput(data.output);
|
|
5198
|
+
if (!answers || answers.length === 0) {
|
|
5199
|
+
return null;
|
|
5200
|
+
}
|
|
5201
|
+
return {
|
|
5202
|
+
toolCallId: content.id,
|
|
5203
|
+
answers
|
|
5204
|
+
};
|
|
5205
|
+
}
|
|
5206
|
+
function RequestUserInputResultCard({
|
|
5207
|
+
result,
|
|
5208
|
+
className
|
|
5209
|
+
}) {
|
|
5210
|
+
const { t } = useChatkitTranslation();
|
|
5211
|
+
return /* @__PURE__ */ jsxs14(
|
|
5212
|
+
"section",
|
|
3623
5213
|
{
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
5214
|
+
"aria-label": t("message.requestUserInputResult.title"),
|
|
5215
|
+
className: cn(
|
|
5216
|
+
"rounded-lg border border-border bg-muted/25 px-3 py-2.5",
|
|
5217
|
+
className
|
|
5218
|
+
),
|
|
5219
|
+
children: [
|
|
5220
|
+
/* @__PURE__ */ jsxs14("div", { className: "mb-2 flex items-center gap-2 text-sm font-semibold text-foreground", children: [
|
|
5221
|
+
/* @__PURE__ */ jsx23(CheckCircle23, { className: "h-4 w-4 text-primary" }),
|
|
5222
|
+
/* @__PURE__ */ jsx23("span", { children: t("message.requestUserInputResult.title") })
|
|
5223
|
+
] }),
|
|
5224
|
+
/* @__PURE__ */ jsx23("div", { className: "space-y-2", children: result.answers.map((answer, index) => /* @__PURE__ */ jsxs14(
|
|
5225
|
+
"div",
|
|
5226
|
+
{
|
|
5227
|
+
className: "rounded-md bg-background/70 px-2.5 py-2",
|
|
5228
|
+
children: [
|
|
5229
|
+
/* @__PURE__ */ jsx23("div", { className: "text-xs font-medium leading-5 text-muted-foreground", children: answer.question }),
|
|
5230
|
+
/* @__PURE__ */ jsxs14("div", { className: "mt-0.5 flex min-w-0 flex-wrap items-center gap-1.5", children: [
|
|
5231
|
+
/* @__PURE__ */ jsx23("span", { className: "min-w-0 wrap-break-word text-sm font-semibold text-foreground", children: answer.label ?? answer.value }),
|
|
5232
|
+
/* @__PURE__ */ jsx23("span", { className: "rounded-full bg-muted px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground", children: t(
|
|
5233
|
+
answer.type === "other" ? "message.requestUserInputResult.other" : "message.requestUserInputResult.option"
|
|
5234
|
+
) })
|
|
5235
|
+
] }),
|
|
5236
|
+
answer.description ? /* @__PURE__ */ jsx23("div", { className: "mt-1 text-xs leading-5 text-muted-foreground", children: answer.description }) : null
|
|
5237
|
+
]
|
|
5238
|
+
},
|
|
5239
|
+
`${answer.id}-${index}`
|
|
5240
|
+
)) })
|
|
5241
|
+
]
|
|
3628
5242
|
}
|
|
3629
|
-
)
|
|
3630
|
-
}
|
|
3631
|
-
var MarkdownText = memo(MarkdownTextImpl);
|
|
5243
|
+
);
|
|
5244
|
+
}
|
|
3632
5245
|
|
|
3633
5246
|
// src/components/thread/messages/widget.tsx
|
|
3634
5247
|
import { SurfaceRenderer } from "@xpert-ai/a2ui-react";
|
|
3635
|
-
import { jsx as
|
|
5248
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
3636
5249
|
function WidgetMessage({ messageId, data }) {
|
|
3637
5250
|
const widgets = Array.isArray(data.widgets) ? data.widgets : [];
|
|
3638
5251
|
if (widgets.length === 0) return null;
|
|
3639
5252
|
const baseSurfaceId = `widget-${messageId}`;
|
|
3640
|
-
return /* @__PURE__ */
|
|
5253
|
+
return /* @__PURE__ */ jsx24("div", { className: "space-y-3", children: widgets.map((widget, index) => {
|
|
3641
5254
|
const config = widget?.config;
|
|
3642
5255
|
if (!config || typeof config !== "object") {
|
|
3643
5256
|
return null;
|
|
3644
5257
|
}
|
|
3645
5258
|
const surfaceId = widgets.length > 1 ? `${baseSurfaceId}-${index}` : baseSurfaceId;
|
|
3646
|
-
return /* @__PURE__ */
|
|
5259
|
+
return /* @__PURE__ */ jsx24(
|
|
3647
5260
|
SurfaceRenderer,
|
|
3648
5261
|
{
|
|
3649
5262
|
surfaceId,
|
|
@@ -3655,58 +5268,44 @@ function WidgetMessage({ messageId, data }) {
|
|
|
3655
5268
|
}
|
|
3656
5269
|
|
|
3657
5270
|
// src/components/thread/messages/ai.tsx
|
|
3658
|
-
import { jsx as
|
|
3659
|
-
function
|
|
5271
|
+
import { jsx as jsx25, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
5272
|
+
function isTextContent2(content) {
|
|
3660
5273
|
return content.type === "text";
|
|
3661
5274
|
}
|
|
3662
|
-
function
|
|
5275
|
+
function isReasoningContent2(content) {
|
|
3663
5276
|
return content.type === "reasoning";
|
|
3664
5277
|
}
|
|
3665
5278
|
function isImageContent(content) {
|
|
3666
5279
|
return content.type === "image_url";
|
|
3667
5280
|
}
|
|
3668
|
-
function
|
|
5281
|
+
function isComponentContent2(content) {
|
|
3669
5282
|
return content.type === "component";
|
|
3670
5283
|
}
|
|
3671
|
-
|
|
3672
|
-
success: {
|
|
3673
|
-
iconClass: "border-green-500 text-green-700",
|
|
3674
|
-
icon: CheckCircle22
|
|
3675
|
-
},
|
|
3676
|
-
fail: {
|
|
3677
|
-
iconClass: "border-red-500 text-red-700",
|
|
3678
|
-
icon: XCircle
|
|
3679
|
-
},
|
|
3680
|
-
running: {
|
|
3681
|
-
iconClass: "border-blue-500 text-blue-700",
|
|
3682
|
-
icon: Loader22
|
|
3683
|
-
}
|
|
3684
|
-
};
|
|
3685
|
-
function isWidgetComponent(content) {
|
|
5284
|
+
function isWidgetComponent2(content) {
|
|
3686
5285
|
const data = content.data;
|
|
3687
5286
|
return data?.type === "Widget" && Array.isArray(data.widgets);
|
|
3688
5287
|
}
|
|
3689
5288
|
function isMemoryContent(content) {
|
|
3690
5289
|
return content.type === "memory";
|
|
3691
5290
|
}
|
|
3692
|
-
function
|
|
5291
|
+
function safeJson2(value) {
|
|
3693
5292
|
try {
|
|
3694
5293
|
return JSON.stringify(value, null, 2);
|
|
3695
5294
|
} catch {
|
|
3696
5295
|
return String(value);
|
|
3697
5296
|
}
|
|
3698
5297
|
}
|
|
3699
|
-
function
|
|
3700
|
-
return typeof value === "string" ? value :
|
|
5298
|
+
function formatDisplayValue2(value) {
|
|
5299
|
+
return typeof value === "string" ? value : safeJson2(value);
|
|
3701
5300
|
}
|
|
3702
5301
|
function ReasoningBlock({ reasoning }) {
|
|
3703
5302
|
const blocks = reasoning.filter((item) => item.text?.trim());
|
|
3704
5303
|
if (blocks.length === 0) return null;
|
|
3705
|
-
return /* @__PURE__ */
|
|
5304
|
+
return /* @__PURE__ */ jsx25("div", { className: "space-y-2", children: blocks.map((item, index) => /* @__PURE__ */ jsx25(
|
|
3706
5305
|
"div",
|
|
3707
5306
|
{
|
|
3708
5307
|
className: "rounded-lg border bg-muted/40 p-3 text-xs text-muted-foreground",
|
|
3709
|
-
children: /* @__PURE__ */
|
|
5308
|
+
children: /* @__PURE__ */ jsx25("p", { className: "whitespace-pre-wrap wrap-break-word leading-relaxed", children: item.text })
|
|
3710
5309
|
},
|
|
3711
5310
|
item.id ?? `reasoning-${index}`
|
|
3712
5311
|
)) });
|
|
@@ -3714,23 +5313,23 @@ function ReasoningBlock({ reasoning }) {
|
|
|
3714
5313
|
function ImageBlock({ content }) {
|
|
3715
5314
|
const imageUrl = typeof content.image_url === "string" ? content.image_url : typeof content.image_url?.url === "string" ? content.image_url.url : null;
|
|
3716
5315
|
if (!imageUrl) {
|
|
3717
|
-
return /* @__PURE__ */
|
|
3718
|
-
/* @__PURE__ */
|
|
3719
|
-
/* @__PURE__ */
|
|
5316
|
+
return /* @__PURE__ */ jsxs15(Card, { children: [
|
|
5317
|
+
/* @__PURE__ */ jsx25(CardHeader, { className: "space-y-1", children: /* @__PURE__ */ jsx25(CardTitle, { className: "text-sm", children: "Image" }) }),
|
|
5318
|
+
/* @__PURE__ */ jsx25(CardContent, { className: "text-xs text-muted-foreground", children: safeJson2(content) })
|
|
3720
5319
|
] });
|
|
3721
5320
|
}
|
|
3722
|
-
return /* @__PURE__ */
|
|
5321
|
+
return /* @__PURE__ */ jsx25("figure", { className: "overflow-hidden rounded-lg border bg-background", children: /* @__PURE__ */ jsx25("img", { src: imageUrl, alt: "Assistant output", className: "h-auto w-full object-cover" }) });
|
|
3723
5322
|
}
|
|
3724
5323
|
function MemoryBlock({ content }) {
|
|
3725
|
-
return /* @__PURE__ */
|
|
3726
|
-
/* @__PURE__ */
|
|
3727
|
-
/* @__PURE__ */
|
|
3728
|
-
/* @__PURE__ */
|
|
5324
|
+
return /* @__PURE__ */ jsxs15(Card, { children: [
|
|
5325
|
+
/* @__PURE__ */ jsxs15(CardHeader, { className: "flex flex-row items-center justify-between gap-2", children: [
|
|
5326
|
+
/* @__PURE__ */ jsx25(CardTitle, { className: "text-sm", children: "Memory" }),
|
|
5327
|
+
/* @__PURE__ */ jsx25(Badge, { variant: "secondary", children: "Memory" })
|
|
3729
5328
|
] }),
|
|
3730
|
-
/* @__PURE__ */
|
|
5329
|
+
/* @__PURE__ */ jsx25(CardContent, { className: "text-xs text-muted-foreground", children: /* @__PURE__ */ jsx25("pre", { className: "whitespace-pre-wrap wrap-break-word", children: safeJson2(content.data ?? []) }) })
|
|
3731
5330
|
] });
|
|
3732
5331
|
}
|
|
3733
|
-
function
|
|
5332
|
+
function parseStepDate2(value) {
|
|
3734
5333
|
if (value instanceof Date) {
|
|
3735
5334
|
const timestamp2 = value.getTime();
|
|
3736
5335
|
return Number.isNaN(timestamp2) ? null : timestamp2;
|
|
@@ -3741,7 +5340,7 @@ function parseStepDate(value) {
|
|
|
3741
5340
|
const timestamp = Date.parse(value);
|
|
3742
5341
|
return Number.isNaN(timestamp) ? null : timestamp;
|
|
3743
5342
|
}
|
|
3744
|
-
function
|
|
5343
|
+
function formatStepDuration2(durationMs) {
|
|
3745
5344
|
if (durationMs < 1e3) {
|
|
3746
5345
|
return `${durationMs}ms`;
|
|
3747
5346
|
}
|
|
@@ -3760,28 +5359,29 @@ function formatStepDuration(durationMs) {
|
|
|
3760
5359
|
return `${minutes}m ${seconds}s`;
|
|
3761
5360
|
}
|
|
3762
5361
|
function ComponentBlock({ content }) {
|
|
3763
|
-
const
|
|
3764
|
-
const
|
|
3765
|
-
const
|
|
3766
|
-
const
|
|
3767
|
-
const
|
|
3768
|
-
const
|
|
5362
|
+
const { i18n: i18n2 } = useChatkitTranslation();
|
|
5363
|
+
const [isExpanded, setIsExpanded] = React19.useState(false);
|
|
5364
|
+
const contentRef = React19.useRef(null);
|
|
5365
|
+
const shouldAutoScrollRef = React19.useRef(true);
|
|
5366
|
+
const previousScrollTopRef = React19.useRef(0);
|
|
5367
|
+
const [durationNow, setDurationNow] = React19.useState(() => Date.now());
|
|
5368
|
+
const data = getToolStepData(content);
|
|
3769
5369
|
const category = data.category ?? "Component";
|
|
3770
|
-
const title =
|
|
5370
|
+
const title = getToolActivityLabel(content, i18n2.language);
|
|
3771
5371
|
const status = data.status ?? null;
|
|
3772
5372
|
const message = data.message ?? null;
|
|
3773
5373
|
const output = data.output ?? null;
|
|
3774
5374
|
const error = data.error ?? null;
|
|
3775
5375
|
const fallback = message ?? output ?? data.data ?? data;
|
|
3776
5376
|
const hasOutput = message !== null || output !== null;
|
|
3777
|
-
const createdAt =
|
|
3778
|
-
const endedAt =
|
|
5377
|
+
const createdAt = parseStepDate2(data.created_date);
|
|
5378
|
+
const endedAt = parseStepDate2(data.end_date);
|
|
3779
5379
|
const durationMs = createdAt === null ? null : Math.max(0, (endedAt ?? durationNow) - createdAt);
|
|
3780
|
-
const durationLabel = durationMs === null ? null :
|
|
3781
|
-
|
|
5380
|
+
const durationLabel = durationMs === null ? null : formatStepDuration2(durationMs);
|
|
5381
|
+
React19.useEffect(() => {
|
|
3782
5382
|
if (status === "running" && output !== null) setIsExpanded(true);
|
|
3783
5383
|
}, [status, output]);
|
|
3784
|
-
|
|
5384
|
+
React19.useEffect(() => {
|
|
3785
5385
|
if (status !== "running" || createdAt === null || endedAt !== null) {
|
|
3786
5386
|
return;
|
|
3787
5387
|
}
|
|
@@ -3793,7 +5393,7 @@ function ComponentBlock({ content }) {
|
|
|
3793
5393
|
window.clearInterval(timer);
|
|
3794
5394
|
};
|
|
3795
5395
|
}, [createdAt, endedAt, status]);
|
|
3796
|
-
|
|
5396
|
+
React19.useEffect(() => {
|
|
3797
5397
|
const element = contentRef.current;
|
|
3798
5398
|
if (!element) return;
|
|
3799
5399
|
previousScrollTopRef.current = element.scrollTop;
|
|
@@ -3813,7 +5413,7 @@ function ComponentBlock({ content }) {
|
|
|
3813
5413
|
element.removeEventListener("scroll", updateAutoScrollState);
|
|
3814
5414
|
};
|
|
3815
5415
|
}, [isExpanded]);
|
|
3816
|
-
|
|
5416
|
+
React19.useEffect(() => {
|
|
3817
5417
|
if (status !== "running") {
|
|
3818
5418
|
shouldAutoScrollRef.current = true;
|
|
3819
5419
|
return;
|
|
@@ -3824,26 +5424,26 @@ function ComponentBlock({ content }) {
|
|
|
3824
5424
|
}
|
|
3825
5425
|
element.scrollTop = element.scrollHeight;
|
|
3826
5426
|
}, [isExpanded, output, status]);
|
|
3827
|
-
const config = status ?
|
|
5427
|
+
const config = status ? toolStatusConfig[status] : null;
|
|
3828
5428
|
const StatusIcon = config?.icon;
|
|
3829
|
-
return /* @__PURE__ */
|
|
3830
|
-
/* @__PURE__ */
|
|
3831
|
-
/* @__PURE__ */
|
|
3832
|
-
status && StatusIcon && /* @__PURE__ */
|
|
3833
|
-
/* @__PURE__ */
|
|
5429
|
+
return /* @__PURE__ */ jsxs15(Card, { children: [
|
|
5430
|
+
/* @__PURE__ */ jsxs15(CardHeader, { className: "flex flex-row items-center justify-between gap-2 px-2 py-1 cursor-pointer", onClick: () => setIsExpanded(!isExpanded), children: [
|
|
5431
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-center space-x-1 flex-1 min-w-0", children: [
|
|
5432
|
+
status && StatusIcon && /* @__PURE__ */ jsx25(StatusIcon, { className: cn("h-4 w-4", config?.iconClass, status === "running" && "animate-spin") }),
|
|
5433
|
+
/* @__PURE__ */ jsx25(CardTitle, { className: "text-sm truncate", children: title })
|
|
3834
5434
|
] }),
|
|
3835
|
-
/* @__PURE__ */
|
|
3836
|
-
durationLabel && /* @__PURE__ */
|
|
3837
|
-
/* @__PURE__ */
|
|
3838
|
-
/* @__PURE__ */
|
|
5435
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex flex-wrap items-center gap-2 shrink-0", children: [
|
|
5436
|
+
durationLabel && /* @__PURE__ */ jsxs15("div", { className: "inline-flex items-center gap-1 text-[11px] text-muted-foreground tabular-nums", children: [
|
|
5437
|
+
/* @__PURE__ */ jsx25(Clock3, { className: "h-3 w-3" }),
|
|
5438
|
+
/* @__PURE__ */ jsx25("span", { children: durationLabel })
|
|
3839
5439
|
] }),
|
|
3840
|
-
/* @__PURE__ */
|
|
3841
|
-
/* @__PURE__ */
|
|
5440
|
+
/* @__PURE__ */ jsx25(Badge, { variant: "secondary", className: "rounded-lg px-1.5", children: category }),
|
|
5441
|
+
/* @__PURE__ */ jsx25(
|
|
3842
5442
|
"button",
|
|
3843
5443
|
{
|
|
3844
5444
|
className: "text-muted-foreground hover:text-foreground transition-colors",
|
|
3845
5445
|
"aria-label": isExpanded ? "Collapse" : "Expand",
|
|
3846
|
-
children: /* @__PURE__ */
|
|
5446
|
+
children: /* @__PURE__ */ jsx25(
|
|
3847
5447
|
ChevronDown2,
|
|
3848
5448
|
{
|
|
3849
5449
|
className: cn("h-4 w-4 transition-transform", isExpanded && "rotate-180")
|
|
@@ -3853,55 +5453,83 @@ function ComponentBlock({ content }) {
|
|
|
3853
5453
|
)
|
|
3854
5454
|
] })
|
|
3855
5455
|
] }),
|
|
3856
|
-
isExpanded && /* @__PURE__ */
|
|
3857
|
-
data.input && /* @__PURE__ */
|
|
3858
|
-
error ? /* @__PURE__ */
|
|
5456
|
+
isExpanded && /* @__PURE__ */ jsxs15(CardContent, { ref: contentRef, className: "text-xs text-muted-foreground max-h-60 overflow-auto", children: [
|
|
5457
|
+
data.input && /* @__PURE__ */ jsx25("pre", { className: "whitespace-pre-wrap wrap-break-word", children: formatDisplayValue2(data.input) }),
|
|
5458
|
+
error ? /* @__PURE__ */ jsx25("pre", { className: "whitespace-pre-wrap wrap-break-word text-destructive", children: formatDisplayValue2(error) }) : hasOutput && /* @__PURE__ */ jsx25("pre", { className: "whitespace-pre-wrap wrap-break-word", children: formatDisplayValue2(fallback) })
|
|
3859
5459
|
] })
|
|
3860
5460
|
] });
|
|
3861
5461
|
}
|
|
3862
5462
|
function UnknownBlock({ content }) {
|
|
3863
|
-
return /* @__PURE__ */
|
|
3864
|
-
/* @__PURE__ */
|
|
3865
|
-
/* @__PURE__ */
|
|
3866
|
-
/* @__PURE__ */
|
|
5463
|
+
return /* @__PURE__ */ jsxs15(Card, { children: [
|
|
5464
|
+
/* @__PURE__ */ jsxs15(CardHeader, { className: "flex flex-row items-center justify-between gap-2", children: [
|
|
5465
|
+
/* @__PURE__ */ jsx25(CardTitle, { className: "text-sm", children: "Assistant Content" }),
|
|
5466
|
+
/* @__PURE__ */ jsx25(Badge, { variant: "outline", children: content.type ?? "unknown" })
|
|
3867
5467
|
] }),
|
|
3868
|
-
/* @__PURE__ */
|
|
5468
|
+
/* @__PURE__ */ jsx25(CardContent, { className: "text-xs text-muted-foreground", children: /* @__PURE__ */ jsx25("pre", { className: "whitespace-pre-wrap break-words", children: safeJson2(content) }) })
|
|
3869
5469
|
] });
|
|
3870
5470
|
}
|
|
3871
|
-
function renderContentItem(content, index,
|
|
5471
|
+
function renderContentItem(content, index, message, lookupMessages) {
|
|
5472
|
+
const messageId = message.id;
|
|
3872
5473
|
if (typeof content === "string") {
|
|
3873
|
-
return /* @__PURE__ */
|
|
3874
|
-
/* @__PURE__ */ jsx22(MarkdownText, { children: content }),
|
|
3875
|
-
";"
|
|
3876
|
-
] }, `text-${index}`);
|
|
5474
|
+
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(MarkdownText, { children: content }) }, `text-${index}`);
|
|
3877
5475
|
}
|
|
3878
|
-
if (
|
|
3879
|
-
return /* @__PURE__ */
|
|
5476
|
+
if (isTextContent2(content)) {
|
|
5477
|
+
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(MarkdownText, { children: content.text }) }, content.id ?? `text-${index}`);
|
|
3880
5478
|
}
|
|
3881
|
-
if (
|
|
3882
|
-
return /* @__PURE__ */
|
|
5479
|
+
if (isReasoningContent2(content)) {
|
|
5480
|
+
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(ReasoningBlock, { reasoning: [content] }) }, content.id ?? `reasoning-${index}`);
|
|
3883
5481
|
}
|
|
3884
5482
|
if (isImageContent(content)) {
|
|
3885
|
-
return /* @__PURE__ */
|
|
5483
|
+
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(ImageBlock, { content }) }, content.id ?? `image-${index}`);
|
|
3886
5484
|
}
|
|
3887
|
-
if (
|
|
3888
|
-
|
|
3889
|
-
|
|
5485
|
+
if (isComponentContent2(content)) {
|
|
5486
|
+
const requestUserInputResult = getRequestUserInputResultCardData(
|
|
5487
|
+
content,
|
|
5488
|
+
lookupMessages
|
|
5489
|
+
);
|
|
5490
|
+
if (requestUserInputResult) {
|
|
5491
|
+
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(RequestUserInputResultCard, { result: requestUserInputResult }) }, content.id ?? `request-user-input-result-${index}`);
|
|
5492
|
+
}
|
|
5493
|
+
if (isWidgetComponent2(content)) {
|
|
5494
|
+
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(WidgetMessage, { messageId, data: content.data }) }, content.id ?? `widget-${index}`);
|
|
3890
5495
|
}
|
|
3891
|
-
return /* @__PURE__ */
|
|
5496
|
+
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(ComponentBlock, { content }) }, content.id ?? `component-${index}`);
|
|
3892
5497
|
}
|
|
3893
5498
|
if (isMemoryContent(content)) {
|
|
3894
|
-
return /* @__PURE__ */
|
|
5499
|
+
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(MemoryBlock, { content }) }, content.id ?? `memory-${index}`);
|
|
5500
|
+
}
|
|
5501
|
+
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(UnknownBlock, { content }) }, content.id ?? `unknown-${index}`);
|
|
5502
|
+
}
|
|
5503
|
+
function renderContentUnit(unit, message, lookupMessages, hasFollowingItem) {
|
|
5504
|
+
if (unit.type === "item") {
|
|
5505
|
+
return renderContentItem(unit.item, unit.index, message, lookupMessages);
|
|
3895
5506
|
}
|
|
3896
|
-
return /* @__PURE__ */
|
|
5507
|
+
return /* @__PURE__ */ jsx25(
|
|
5508
|
+
"div",
|
|
5509
|
+
{
|
|
5510
|
+
children: /* @__PURE__ */ jsx25(ToolComponentGroup, { items: unit.items, hasFollowingItem })
|
|
5511
|
+
},
|
|
5512
|
+
`tool-group-${unit.startIndex}-${unit.items[0]?.id ?? "tool"}-${unit.items.length}`
|
|
5513
|
+
);
|
|
3897
5514
|
}
|
|
3898
|
-
function renderContent(
|
|
5515
|
+
function renderContent(message, lookupMessages) {
|
|
5516
|
+
const content = message.content;
|
|
3899
5517
|
if (typeof content === "string") {
|
|
3900
5518
|
if (!content.trim()) return null;
|
|
3901
|
-
return /* @__PURE__ */
|
|
5519
|
+
return /* @__PURE__ */ jsx25(MarkdownText, { children: content });
|
|
3902
5520
|
}
|
|
3903
5521
|
if (!Array.isArray(content) || content.length === 0) return null;
|
|
3904
|
-
|
|
5522
|
+
const renderUnits = buildToolComponentRenderUnits(content, {
|
|
5523
|
+
shouldGroupComponent: (item) => getRequestUserInputResultCardData(item, lookupMessages) === null
|
|
5524
|
+
});
|
|
5525
|
+
return /* @__PURE__ */ jsx25("div", { className: "space-y-3", children: renderUnits.map(
|
|
5526
|
+
(unit, index) => renderContentUnit(
|
|
5527
|
+
unit,
|
|
5528
|
+
message,
|
|
5529
|
+
lookupMessages,
|
|
5530
|
+
index < renderUnits.length - 1
|
|
5531
|
+
)
|
|
5532
|
+
) });
|
|
3905
5533
|
}
|
|
3906
5534
|
function AssistantStreamingIndicator({
|
|
3907
5535
|
status,
|
|
@@ -3913,23 +5541,24 @@ function AssistantStreamingIndicator({
|
|
|
3913
5541
|
thinking: t("message.thinking"),
|
|
3914
5542
|
answering: t("message.answering")
|
|
3915
5543
|
};
|
|
3916
|
-
return /* @__PURE__ */
|
|
3917
|
-
status === "loading" && /* @__PURE__ */
|
|
3918
|
-
status === "thinking" && /* @__PURE__ */
|
|
3919
|
-
/* @__PURE__ */
|
|
3920
|
-
/* @__PURE__ */
|
|
3921
|
-
/* @__PURE__ */
|
|
5544
|
+
return /* @__PURE__ */ jsxs15("div", { className: cn("flex items-center gap-2 text-xs text-muted-foreground", className), children: [
|
|
5545
|
+
status === "loading" && /* @__PURE__ */ jsx25(Loader23, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
5546
|
+
status === "thinking" && /* @__PURE__ */ jsxs15("div", { className: "flex items-end gap-1", "aria-hidden": "true", children: [
|
|
5547
|
+
/* @__PURE__ */ jsx25("span", { className: "h-1.5 w-1.5 rounded-full bg-current animate-bounce [animation-delay:-0.3s]" }),
|
|
5548
|
+
/* @__PURE__ */ jsx25("span", { className: "h-1.5 w-1.5 rounded-full bg-current animate-bounce [animation-delay:-0.15s]" }),
|
|
5549
|
+
/* @__PURE__ */ jsx25("span", { className: "h-1.5 w-1.5 rounded-full bg-current animate-bounce" })
|
|
3922
5550
|
] }),
|
|
3923
|
-
status === "answering" && /* @__PURE__ */
|
|
3924
|
-
/* @__PURE__ */
|
|
3925
|
-
/* @__PURE__ */
|
|
3926
|
-
/* @__PURE__ */
|
|
5551
|
+
status === "answering" && /* @__PURE__ */ jsxs15("div", { className: "flex items-end gap-1", "aria-hidden": "true", children: [
|
|
5552
|
+
/* @__PURE__ */ jsx25("span", { className: "h-2 w-0.5 rounded-full bg-current animate-pulse [animation-delay:-0.25s]" }),
|
|
5553
|
+
/* @__PURE__ */ jsx25("span", { className: "h-3 w-0.5 rounded-full bg-current animate-pulse [animation-delay:-0.1s]" }),
|
|
5554
|
+
/* @__PURE__ */ jsx25("span", { className: "h-2.5 w-0.5 rounded-full bg-current animate-pulse" })
|
|
3927
5555
|
] }),
|
|
3928
|
-
/* @__PURE__ */
|
|
5556
|
+
/* @__PURE__ */ jsx25("span", { children: labelMap[status] })
|
|
3929
5557
|
] });
|
|
3930
5558
|
}
|
|
3931
5559
|
function AssistantMessage({
|
|
3932
5560
|
message,
|
|
5561
|
+
messages,
|
|
3933
5562
|
className,
|
|
3934
5563
|
isStreaming = false,
|
|
3935
5564
|
streamingStatus
|
|
@@ -3938,43 +5567,44 @@ function AssistantMessage({
|
|
|
3938
5567
|
const hasContent = hasRenderableMessageContent(message.content);
|
|
3939
5568
|
const hasReasoning = hasRenderableReasoning(message.reasoning);
|
|
3940
5569
|
const resolvedStreamingStatus = streamingStatus ?? getAssistantStreamingStatus(message, isStreaming);
|
|
3941
|
-
const
|
|
3942
|
-
const
|
|
5570
|
+
const lookupMessages = messages?.length ? messages : [message];
|
|
5571
|
+
const answerNode = renderContent(message, lookupMessages);
|
|
5572
|
+
const reasoningNode = hasReasoning ? /* @__PURE__ */ jsx25(ReasoningBlock, { reasoning: message.reasoning ?? [] }) : null;
|
|
3943
5573
|
if (!hasRenderableAssistantMessage(message) && !resolvedStreamingStatus) return null;
|
|
3944
5574
|
const streamingClass = isStreaming ? "streaming-active" : "";
|
|
3945
5575
|
if (!hasRenderableAssistantMessage(message) && resolvedStreamingStatus) {
|
|
3946
|
-
return /* @__PURE__ */
|
|
5576
|
+
return /* @__PURE__ */ jsx25("div", { className: cn("space-y-3", streamingClass, className), children: /* @__PURE__ */ jsx25(AssistantStreamingIndicator, { status: resolvedStreamingStatus }) });
|
|
3947
5577
|
}
|
|
3948
5578
|
if (hasContent && hasReasoning) {
|
|
3949
|
-
return /* @__PURE__ */
|
|
3950
|
-
/* @__PURE__ */
|
|
5579
|
+
return /* @__PURE__ */ jsxs15("div", { className: cn("space-y-3", streamingClass, className), children: [
|
|
5580
|
+
/* @__PURE__ */ jsxs15(
|
|
3951
5581
|
Tabs,
|
|
3952
5582
|
{
|
|
3953
5583
|
defaultValue: message.status === "reasoning" ? "reasoning" : "answer",
|
|
3954
5584
|
className: "w-full",
|
|
3955
5585
|
children: [
|
|
3956
|
-
/* @__PURE__ */
|
|
3957
|
-
/* @__PURE__ */
|
|
3958
|
-
/* @__PURE__ */
|
|
5586
|
+
/* @__PURE__ */ jsxs15(TabsList, { className: "", children: [
|
|
5587
|
+
/* @__PURE__ */ jsx25(TabsTrigger, { value: "answer", children: t("message.answer") }),
|
|
5588
|
+
/* @__PURE__ */ jsx25(TabsTrigger, { value: "reasoning", children: t("message.reasoning") })
|
|
3959
5589
|
] }),
|
|
3960
|
-
/* @__PURE__ */
|
|
3961
|
-
/* @__PURE__ */
|
|
5590
|
+
/* @__PURE__ */ jsx25(TabsContent, { value: "answer", className: "space-y-3", children: answerNode }),
|
|
5591
|
+
/* @__PURE__ */ jsx25(TabsContent, { value: "reasoning", className: "space-y-3", children: reasoningNode })
|
|
3962
5592
|
]
|
|
3963
5593
|
}
|
|
3964
5594
|
),
|
|
3965
|
-
resolvedStreamingStatus ? /* @__PURE__ */
|
|
5595
|
+
resolvedStreamingStatus ? /* @__PURE__ */ jsx25(AssistantStreamingIndicator, { status: resolvedStreamingStatus }) : null
|
|
3966
5596
|
] });
|
|
3967
5597
|
}
|
|
3968
|
-
return /* @__PURE__ */
|
|
5598
|
+
return /* @__PURE__ */ jsxs15("div", { className: cn("space-y-3", streamingClass, className), children: [
|
|
3969
5599
|
hasReasoning ? reasoningNode : answerNode,
|
|
3970
|
-
resolvedStreamingStatus ? /* @__PURE__ */
|
|
5600
|
+
resolvedStreamingStatus ? /* @__PURE__ */ jsx25(AssistantStreamingIndicator, { status: resolvedStreamingStatus }) : null
|
|
3971
5601
|
] });
|
|
3972
5602
|
}
|
|
3973
5603
|
|
|
3974
5604
|
// src/components/thread/MessageActions.tsx
|
|
3975
|
-
import * as
|
|
3976
|
-
import { Check, Copy, RefreshCw } from "lucide-react";
|
|
3977
|
-
import { jsx as
|
|
5605
|
+
import * as React20 from "react";
|
|
5606
|
+
import { Check as Check3, Copy as Copy2, RefreshCw } from "lucide-react";
|
|
5607
|
+
import { jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3978
5608
|
function MessageActions({
|
|
3979
5609
|
content,
|
|
3980
5610
|
isAssistant = false,
|
|
@@ -3983,7 +5613,7 @@ function MessageActions({
|
|
|
3983
5613
|
className
|
|
3984
5614
|
}) {
|
|
3985
5615
|
const { t } = useChatkitTranslation();
|
|
3986
|
-
const [copied, setCopied] =
|
|
5616
|
+
const [copied, setCopied] = React20.useState(false);
|
|
3987
5617
|
const handleCopy = async () => {
|
|
3988
5618
|
try {
|
|
3989
5619
|
await navigator.clipboard.writeText(content);
|
|
@@ -3996,7 +5626,7 @@ function MessageActions({
|
|
|
3996
5626
|
if (isStreaming) {
|
|
3997
5627
|
return null;
|
|
3998
5628
|
}
|
|
3999
|
-
return /* @__PURE__ */
|
|
5629
|
+
return /* @__PURE__ */ jsxs16(
|
|
4000
5630
|
"div",
|
|
4001
5631
|
{
|
|
4002
5632
|
className: cn(
|
|
@@ -4004,7 +5634,7 @@ function MessageActions({
|
|
|
4004
5634
|
className
|
|
4005
5635
|
),
|
|
4006
5636
|
children: [
|
|
4007
|
-
/* @__PURE__ */
|
|
5637
|
+
/* @__PURE__ */ jsx26(
|
|
4008
5638
|
"button",
|
|
4009
5639
|
{
|
|
4010
5640
|
type: "button",
|
|
@@ -4014,17 +5644,17 @@ function MessageActions({
|
|
|
4014
5644
|
copied && "text-green-500"
|
|
4015
5645
|
),
|
|
4016
5646
|
title: copied ? t("messageActions.copied") : t("messageActions.copy"),
|
|
4017
|
-
children: copied ? /* @__PURE__ */
|
|
5647
|
+
children: copied ? /* @__PURE__ */ jsx26(Check3, { size: 14 }) : /* @__PURE__ */ jsx26(Copy2, { size: 14 })
|
|
4018
5648
|
}
|
|
4019
5649
|
),
|
|
4020
|
-
isAssistant && onRetry && /* @__PURE__ */
|
|
5650
|
+
isAssistant && onRetry && /* @__PURE__ */ jsx26(
|
|
4021
5651
|
"button",
|
|
4022
5652
|
{
|
|
4023
5653
|
type: "button",
|
|
4024
5654
|
onClick: onRetry,
|
|
4025
5655
|
className: "p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",
|
|
4026
5656
|
title: t("messageActions.regenerate"),
|
|
4027
|
-
children: /* @__PURE__ */
|
|
5657
|
+
children: /* @__PURE__ */ jsx26(RefreshCw, { size: 14 })
|
|
4028
5658
|
}
|
|
4029
5659
|
)
|
|
4030
5660
|
]
|
|
@@ -4045,18 +5675,18 @@ import {
|
|
|
4045
5675
|
Sparkles as Sparkles2,
|
|
4046
5676
|
Zap
|
|
4047
5677
|
} from "lucide-react";
|
|
4048
|
-
import { jsx as
|
|
5678
|
+
import { jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
4049
5679
|
function getIconComponent2(icon) {
|
|
4050
5680
|
const iconMap = {
|
|
4051
|
-
"circle-question": /* @__PURE__ */
|
|
4052
|
-
"lightbulb": /* @__PURE__ */
|
|
4053
|
-
"sparkle": /* @__PURE__ */
|
|
4054
|
-
"write": /* @__PURE__ */
|
|
4055
|
-
"search": /* @__PURE__ */
|
|
4056
|
-
"globe": /* @__PURE__ */
|
|
4057
|
-
"book-open": /* @__PURE__ */
|
|
4058
|
-
"compass": /* @__PURE__ */
|
|
4059
|
-
"bolt": /* @__PURE__ */
|
|
5681
|
+
"circle-question": /* @__PURE__ */ jsx27(HelpCircle, { size: 20 }),
|
|
5682
|
+
"lightbulb": /* @__PURE__ */ jsx27(Lightbulb2, { size: 20 }),
|
|
5683
|
+
"sparkle": /* @__PURE__ */ jsx27(Sparkles2, { size: 20 }),
|
|
5684
|
+
"write": /* @__PURE__ */ jsx27(Pencil2, { size: 20 }),
|
|
5685
|
+
"search": /* @__PURE__ */ jsx27(Search2, { size: 20 }),
|
|
5686
|
+
"globe": /* @__PURE__ */ jsx27(Globe2, { size: 20 }),
|
|
5687
|
+
"book-open": /* @__PURE__ */ jsx27(BookOpen, { size: 20 }),
|
|
5688
|
+
"compass": /* @__PURE__ */ jsx27(Compass, { size: 20 }),
|
|
5689
|
+
"bolt": /* @__PURE__ */ jsx27(Zap, { size: 20 })
|
|
4060
5690
|
};
|
|
4061
5691
|
return icon ? iconMap[icon] || iconMap["sparkle"] : iconMap["sparkle"];
|
|
4062
5692
|
}
|
|
@@ -4064,9 +5694,9 @@ function StartScreen({ startScreen, onPromptClick, className }) {
|
|
|
4064
5694
|
const { t } = useChatkitTranslation();
|
|
4065
5695
|
const greeting = startScreen?.greeting ?? t("startScreen.greeting");
|
|
4066
5696
|
const prompts = startScreen?.prompts ?? [];
|
|
4067
|
-
return /* @__PURE__ */
|
|
4068
|
-
/* @__PURE__ */
|
|
4069
|
-
prompts.length > 0 && /* @__PURE__ */
|
|
5697
|
+
return /* @__PURE__ */ jsxs17("div", { className: cn("flex flex-col items-center justify-center py-12 px-4", className), children: [
|
|
5698
|
+
/* @__PURE__ */ jsx27("div", { className: "mb-8 text-center", children: /* @__PURE__ */ jsx27("h2", { className: "text-2xl font-semibold text-foreground mb-2", children: greeting }) }),
|
|
5699
|
+
prompts.length > 0 && /* @__PURE__ */ jsx27("div", { className: "w-full max-w-2xl", children: /* @__PURE__ */ jsx27("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: prompts.map((item, index) => /* @__PURE__ */ jsxs17(
|
|
4070
5700
|
"button",
|
|
4071
5701
|
{
|
|
4072
5702
|
type: "button",
|
|
@@ -4077,8 +5707,8 @@ function StartScreen({ startScreen, onPromptClick, className }) {
|
|
|
4077
5707
|
"focus:outline-none focus:ring-2 focus:ring-primary/20"
|
|
4078
5708
|
),
|
|
4079
5709
|
children: [
|
|
4080
|
-
/* @__PURE__ */
|
|
4081
|
-
/* @__PURE__ */
|
|
5710
|
+
/* @__PURE__ */ jsx27("span", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary", children: getIconComponent2(item.icon) }),
|
|
5711
|
+
/* @__PURE__ */ jsx27("span", { className: "text-sm font-medium text-foreground", children: item.label })
|
|
4082
5712
|
]
|
|
4083
5713
|
},
|
|
4084
5714
|
`prompt-${index}`
|
|
@@ -4090,10 +5720,10 @@ function StartScreen({ startScreen, onPromptClick, className }) {
|
|
|
4090
5720
|
import "react";
|
|
4091
5721
|
|
|
4092
5722
|
// src/components/ui/avatar.tsx
|
|
4093
|
-
import * as
|
|
5723
|
+
import * as React22 from "react";
|
|
4094
5724
|
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
4095
|
-
import { jsx as
|
|
4096
|
-
var Avatar =
|
|
5725
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
5726
|
+
var Avatar = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx28(
|
|
4097
5727
|
AvatarPrimitive.Root,
|
|
4098
5728
|
{
|
|
4099
5729
|
ref,
|
|
@@ -4105,7 +5735,7 @@ var Avatar = React19.forwardRef(({ className, ...props }, ref) => /* @__PURE__ *
|
|
|
4105
5735
|
}
|
|
4106
5736
|
));
|
|
4107
5737
|
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
4108
|
-
var AvatarImage =
|
|
5738
|
+
var AvatarImage = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx28(
|
|
4109
5739
|
AvatarPrimitive.Image,
|
|
4110
5740
|
{
|
|
4111
5741
|
ref,
|
|
@@ -4114,7 +5744,7 @@ var AvatarImage = React19.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
4114
5744
|
}
|
|
4115
5745
|
));
|
|
4116
5746
|
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
4117
|
-
var AvatarFallback =
|
|
5747
|
+
var AvatarFallback = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx28(
|
|
4118
5748
|
AvatarPrimitive.Fallback,
|
|
4119
5749
|
{
|
|
4120
5750
|
ref,
|
|
@@ -4128,7 +5758,7 @@ var AvatarFallback = React19.forwardRef(({ className, ...props }, ref) => /* @__
|
|
|
4128
5758
|
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
4129
5759
|
|
|
4130
5760
|
// src/components/ui/chatkit-avatar.tsx
|
|
4131
|
-
import { jsx as
|
|
5761
|
+
import { jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4132
5762
|
function asRecord(value) {
|
|
4133
5763
|
return value && typeof value === "object" ? value : null;
|
|
4134
5764
|
}
|
|
@@ -4201,21 +5831,21 @@ function ChatkitAvatar({
|
|
|
4201
5831
|
const fallbackStyle = {
|
|
4202
5832
|
...avatar?.background ? { background: avatar.background } : {}
|
|
4203
5833
|
};
|
|
4204
|
-
return /* @__PURE__ */
|
|
4205
|
-
avatar?.url ? /* @__PURE__ */
|
|
4206
|
-
/* @__PURE__ */
|
|
5834
|
+
return /* @__PURE__ */ jsxs18(Avatar, { className: cn(roundedClass, className), style, ...props, children: [
|
|
5835
|
+
avatar?.url ? /* @__PURE__ */ jsx29(AvatarImage, { className: imageClassName, src: avatar.url, alt: label }) : null,
|
|
5836
|
+
/* @__PURE__ */ jsx29(
|
|
4207
5837
|
AvatarFallback,
|
|
4208
5838
|
{
|
|
4209
5839
|
className: cn(roundedClass, "text-sm font-medium text-foreground", fallbackClassName),
|
|
4210
5840
|
style: fallbackStyle,
|
|
4211
|
-
children: emojiCharacter ? /* @__PURE__ */
|
|
5841
|
+
children: emojiCharacter ? /* @__PURE__ */ jsx29("span", { className: "text-[1.1em] leading-none", style: emojiStyle, children: emojiCharacter }) : fallbackText
|
|
4212
5842
|
}
|
|
4213
5843
|
)
|
|
4214
5844
|
] });
|
|
4215
5845
|
}
|
|
4216
5846
|
|
|
4217
5847
|
// src/hooks/useThreads.ts
|
|
4218
|
-
import * as
|
|
5848
|
+
import * as React24 from "react";
|
|
4219
5849
|
var DEFAULT_LIMIT = 50;
|
|
4220
5850
|
var getThreadTitle = (threadRecord) => {
|
|
4221
5851
|
const title = threadRecord.title?.trim();
|
|
@@ -4253,16 +5883,16 @@ function useThreads(limit = DEFAULT_LIMIT) {
|
|
|
4253
5883
|
isReady,
|
|
4254
5884
|
isLoading: isStreamLoading
|
|
4255
5885
|
} = useStreamContext();
|
|
4256
|
-
const [threadRecords, setThreadRecords] =
|
|
4257
|
-
const [isLoading, setIsLoading] =
|
|
4258
|
-
const [error, setError] =
|
|
4259
|
-
const upsertThreadRecord =
|
|
5886
|
+
const [threadRecords, setThreadRecords] = React24.useState([]);
|
|
5887
|
+
const [isLoading, setIsLoading] = React24.useState(false);
|
|
5888
|
+
const [error, setError] = React24.useState(null);
|
|
5889
|
+
const upsertThreadRecord = React24.useCallback((threadRecord) => {
|
|
4260
5890
|
setThreadRecords((prev) => {
|
|
4261
5891
|
const next = prev.filter((item) => item.id !== threadRecord.id);
|
|
4262
5892
|
return sortThreadRecords([threadRecord, ...next]);
|
|
4263
5893
|
});
|
|
4264
5894
|
}, []);
|
|
4265
|
-
const refreshThreads =
|
|
5895
|
+
const refreshThreads = React24.useCallback(async () => {
|
|
4266
5896
|
setIsLoading(true);
|
|
4267
5897
|
setError(null);
|
|
4268
5898
|
try {
|
|
@@ -4278,7 +5908,7 @@ function useThreads(limit = DEFAULT_LIMIT) {
|
|
|
4278
5908
|
setIsLoading(false);
|
|
4279
5909
|
}
|
|
4280
5910
|
}, [client, limit, assistantId]);
|
|
4281
|
-
const createThread =
|
|
5911
|
+
const createThread = React24.useCallback(
|
|
4282
5912
|
async (input) => {
|
|
4283
5913
|
setError(null);
|
|
4284
5914
|
const payload = {};
|
|
@@ -4292,7 +5922,7 @@ function useThreads(limit = DEFAULT_LIMIT) {
|
|
|
4292
5922
|
},
|
|
4293
5923
|
[client, upsertThreadRecord]
|
|
4294
5924
|
);
|
|
4295
|
-
const updateThread =
|
|
5925
|
+
const updateThread = React24.useCallback(
|
|
4296
5926
|
async (recordId, payload) => {
|
|
4297
5927
|
setError(null);
|
|
4298
5928
|
const updated = await client.conversations.update(recordId, payload);
|
|
@@ -4301,7 +5931,7 @@ function useThreads(limit = DEFAULT_LIMIT) {
|
|
|
4301
5931
|
},
|
|
4302
5932
|
[client, upsertThreadRecord]
|
|
4303
5933
|
);
|
|
4304
|
-
const deleteThread =
|
|
5934
|
+
const deleteThread = React24.useCallback(
|
|
4305
5935
|
async (recordId) => {
|
|
4306
5936
|
setError(null);
|
|
4307
5937
|
await client.conversations.delete(recordId);
|
|
@@ -4309,11 +5939,11 @@ function useThreads(limit = DEFAULT_LIMIT) {
|
|
|
4309
5939
|
},
|
|
4310
5940
|
[client]
|
|
4311
5941
|
);
|
|
4312
|
-
|
|
5942
|
+
React24.useEffect(() => {
|
|
4313
5943
|
if (!isReady) return;
|
|
4314
5944
|
void refreshThreads();
|
|
4315
5945
|
}, [refreshThreads, isReady]);
|
|
4316
|
-
|
|
5946
|
+
React24.useEffect(() => {
|
|
4317
5947
|
if (!threadId || !isStreamLoading) return;
|
|
4318
5948
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4319
5949
|
const busyStatus = "busy";
|
|
@@ -4334,7 +5964,7 @@ function useThreads(limit = DEFAULT_LIMIT) {
|
|
|
4334
5964
|
return changed ? sortThreadRecords(next) : prev;
|
|
4335
5965
|
});
|
|
4336
5966
|
}, [threadId, isStreamLoading]);
|
|
4337
|
-
|
|
5967
|
+
React24.useEffect(() => {
|
|
4338
5968
|
if (!isReady || !threadId || isStreamLoading) return;
|
|
4339
5969
|
let cancelled = false;
|
|
4340
5970
|
void client.conversations.search({ where: { threadId }, limit: 1 }).then((result) => {
|
|
@@ -4348,7 +5978,7 @@ function useThreads(limit = DEFAULT_LIMIT) {
|
|
|
4348
5978
|
cancelled = true;
|
|
4349
5979
|
};
|
|
4350
5980
|
}, [client, threadId, upsertThreadRecord, isReady, isStreamLoading]);
|
|
4351
|
-
const threads =
|
|
5981
|
+
const threads = React24.useMemo(
|
|
4352
5982
|
() => threadRecords.map((threadRecord) => toThreadItem(threadRecord)),
|
|
4353
5983
|
[threadRecords]
|
|
4354
5984
|
);
|
|
@@ -4365,10 +5995,10 @@ function useThreads(limit = DEFAULT_LIMIT) {
|
|
|
4365
5995
|
}
|
|
4366
5996
|
|
|
4367
5997
|
// src/components/thread/context-usage-indicator.tsx
|
|
4368
|
-
import * as
|
|
5998
|
+
import * as React25 from "react";
|
|
4369
5999
|
|
|
4370
6000
|
// src/components/ui/progress-circle.tsx
|
|
4371
|
-
import { jsx as
|
|
6001
|
+
import { jsx as jsx30, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4372
6002
|
function clamp2(input, a, b) {
|
|
4373
6003
|
return Math.max(Math.min(input, Math.max(a, b)), Math.min(a, b));
|
|
4374
6004
|
}
|
|
@@ -4391,7 +6021,7 @@ var ProgressCircle = ({ value, className, ...restSvgProps }) => {
|
|
|
4391
6021
|
return (
|
|
4392
6022
|
// biome-ignore lint/a11y/useFocusableInteractive: false positive (progress + progressbar are not focusable interactives)
|
|
4393
6023
|
// biome-ignore lint/nursery/useAriaPropsSupportedByRole: biome rule at odds with mdn docs (presumed nursary bug with rule)
|
|
4394
|
-
/* @__PURE__ */
|
|
6024
|
+
/* @__PURE__ */ jsxs19(
|
|
4395
6025
|
"svg",
|
|
4396
6026
|
{
|
|
4397
6027
|
role: "progressbar",
|
|
@@ -4402,8 +6032,8 @@ var ProgressCircle = ({ value, className, ...restSvgProps }) => {
|
|
|
4402
6032
|
"aria-valuemax": 100,
|
|
4403
6033
|
...restSvgProps,
|
|
4404
6034
|
children: [
|
|
4405
|
-
/* @__PURE__ */
|
|
4406
|
-
/* @__PURE__ */
|
|
6035
|
+
/* @__PURE__ */ jsx30("circle", { ...commonParams, className: "stroke-current/25" }),
|
|
6036
|
+
/* @__PURE__ */ jsx30(
|
|
4407
6037
|
"circle",
|
|
4408
6038
|
{
|
|
4409
6039
|
...commonParams,
|
|
@@ -4422,7 +6052,7 @@ var ProgressCircle = ({ value, className, ...restSvgProps }) => {
|
|
|
4422
6052
|
};
|
|
4423
6053
|
|
|
4424
6054
|
// src/components/thread/context-usage-indicator.tsx
|
|
4425
|
-
import { jsx as
|
|
6055
|
+
import { jsx as jsx31, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
4426
6056
|
var kNumberFormatter = new Intl.NumberFormat("en-US", {
|
|
4427
6057
|
minimumFractionDigits: 0,
|
|
4428
6058
|
maximumFractionDigits: 1
|
|
@@ -4455,20 +6085,20 @@ function ContextUsageIndicator({
|
|
|
4455
6085
|
}) {
|
|
4456
6086
|
const { t } = useChatkitTranslation();
|
|
4457
6087
|
const stream = useStreamContext();
|
|
4458
|
-
const [maxContextSize, setMaxContextSize] =
|
|
4459
|
-
const [usedContextSize, setUsedContextSize] =
|
|
4460
|
-
const [assistantAgentKey, setAssistantAgentKey] =
|
|
4461
|
-
const latestRealtimeUsageRef =
|
|
6088
|
+
const [maxContextSize, setMaxContextSize] = React25.useState(null);
|
|
6089
|
+
const [usedContextSize, setUsedContextSize] = React25.useState(null);
|
|
6090
|
+
const [assistantAgentKey, setAssistantAgentKey] = React25.useState(null);
|
|
6091
|
+
const latestRealtimeUsageRef = React25.useRef({
|
|
4462
6092
|
threadId: null,
|
|
4463
6093
|
agentKey: null,
|
|
4464
6094
|
usedTokens: null
|
|
4465
6095
|
});
|
|
4466
|
-
const realtimeUsage =
|
|
6096
|
+
const realtimeUsage = React25.useMemo(
|
|
4467
6097
|
() => getThreadContextUsage(stream.contextUsageByAgentKey, assistantAgentKey),
|
|
4468
6098
|
[assistantAgentKey, stream.contextUsageByAgentKey]
|
|
4469
6099
|
);
|
|
4470
6100
|
const realtimeUsedContextSize = getThreadContextUsageTotalTokens(realtimeUsage);
|
|
4471
|
-
|
|
6101
|
+
React25.useEffect(() => {
|
|
4472
6102
|
if (!stream.client || !stream.assistantId) {
|
|
4473
6103
|
setMaxContextSize(null);
|
|
4474
6104
|
setAssistantAgentKey(null);
|
|
@@ -4488,18 +6118,18 @@ function ContextUsageIndicator({
|
|
|
4488
6118
|
cancelled = true;
|
|
4489
6119
|
};
|
|
4490
6120
|
}, [stream.client, stream.assistantId]);
|
|
4491
|
-
|
|
6121
|
+
React25.useEffect(() => {
|
|
4492
6122
|
latestRealtimeUsageRef.current = {
|
|
4493
6123
|
threadId: stream.threadId ?? null,
|
|
4494
6124
|
agentKey: assistantAgentKey,
|
|
4495
6125
|
usedTokens: realtimeUsedContextSize
|
|
4496
6126
|
};
|
|
4497
6127
|
}, [assistantAgentKey, realtimeUsedContextSize, stream.threadId]);
|
|
4498
|
-
|
|
6128
|
+
React25.useEffect(() => {
|
|
4499
6129
|
if (realtimeUsedContextSize == null) return;
|
|
4500
6130
|
setUsedContextSize(realtimeUsedContextSize);
|
|
4501
6131
|
}, [realtimeUsedContextSize]);
|
|
4502
|
-
|
|
6132
|
+
React25.useEffect(() => {
|
|
4503
6133
|
if (!stream.client) {
|
|
4504
6134
|
setUsedContextSize(null);
|
|
4505
6135
|
return;
|
|
@@ -4564,8 +6194,8 @@ function ContextUsageIndicator({
|
|
|
4564
6194
|
});
|
|
4565
6195
|
const usageLabelWithSuffix = usageLabel.endsWith(":") ? usageLabel : `${usageLabel}:`;
|
|
4566
6196
|
const progressClassName = percent >= 90 ? "text-destructive" : percent >= 75 ? "text-amber-500" : "text-primary dark:text-zinc-300";
|
|
4567
|
-
return /* @__PURE__ */
|
|
4568
|
-
/* @__PURE__ */
|
|
6197
|
+
return /* @__PURE__ */ jsxs20(Tooltip, { children: [
|
|
6198
|
+
/* @__PURE__ */ jsx31(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx31(
|
|
4569
6199
|
"button",
|
|
4570
6200
|
{
|
|
4571
6201
|
type: "button",
|
|
@@ -4574,19 +6204,19 @@ function ContextUsageIndicator({
|
|
|
4574
6204
|
className
|
|
4575
6205
|
),
|
|
4576
6206
|
"aria-label": `${usageLabelWithSuffix} ${usageFullLabel}. ${usageTokensLabel}`,
|
|
4577
|
-
children: /* @__PURE__ */
|
|
6207
|
+
children: /* @__PURE__ */ jsx31(ProgressCircle, { value: percent, className: cn("size-3.5", progressClassName) })
|
|
4578
6208
|
}
|
|
4579
6209
|
) }),
|
|
4580
|
-
/* @__PURE__ */
|
|
4581
|
-
/* @__PURE__ */
|
|
4582
|
-
/* @__PURE__ */
|
|
4583
|
-
/* @__PURE__ */
|
|
6210
|
+
/* @__PURE__ */ jsxs20(TooltipContent, { side: "top", sideOffset: 6, className: "space-y-0.5 px-3 py-2 text-center", children: [
|
|
6211
|
+
/* @__PURE__ */ jsx31("div", { className: "text-primary-foreground/70", children: usageLabelWithSuffix }),
|
|
6212
|
+
/* @__PURE__ */ jsx31("div", { className: "font-medium text-primary-foreground/80", children: usageFullLabel }),
|
|
6213
|
+
/* @__PURE__ */ jsx31("div", { className: "text-sm font-semibold", children: usageTokensLabel })
|
|
4584
6214
|
] })
|
|
4585
6215
|
] });
|
|
4586
6216
|
}
|
|
4587
6217
|
|
|
4588
6218
|
// src/components/chat.tsx
|
|
4589
|
-
import { Fragment as Fragment4, jsx as
|
|
6219
|
+
import { Fragment as Fragment4, jsx as jsx32, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4590
6220
|
var defaultApiUrl2 = import.meta.env.VITE_XPERTAI_API_URL;
|
|
4591
6221
|
var COMPOSER_INPUT_MAX_HEIGHT = 128;
|
|
4592
6222
|
var LONG_TEXT_REFERENCE_THRESHOLD = 5e3;
|
|
@@ -4678,7 +6308,7 @@ function ReferenceChip({
|
|
|
4678
6308
|
const metaLine = getReferenceMetaLine(reference);
|
|
4679
6309
|
const isComposer = variant === "composer";
|
|
4680
6310
|
const Icon = reference.type === "quote" ? Quote : reference.type === "image" ? ImageIcon : FileText2;
|
|
4681
|
-
return /* @__PURE__ */
|
|
6311
|
+
return /* @__PURE__ */ jsxs21(
|
|
4682
6312
|
"div",
|
|
4683
6313
|
{
|
|
4684
6314
|
className: cn(
|
|
@@ -4687,7 +6317,7 @@ function ReferenceChip({
|
|
|
4687
6317
|
),
|
|
4688
6318
|
title: getReferenceTitle(reference),
|
|
4689
6319
|
children: [
|
|
4690
|
-
/* @__PURE__ */
|
|
6320
|
+
/* @__PURE__ */ jsx32(
|
|
4691
6321
|
Icon,
|
|
4692
6322
|
{
|
|
4693
6323
|
size: isComposer ? 14 : 12,
|
|
@@ -4697,8 +6327,8 @@ function ReferenceChip({
|
|
|
4697
6327
|
)
|
|
4698
6328
|
}
|
|
4699
6329
|
),
|
|
4700
|
-
/* @__PURE__ */
|
|
4701
|
-
/* @__PURE__ */
|
|
6330
|
+
/* @__PURE__ */ jsxs21("div", { className: "min-w-0 flex-1", children: [
|
|
6331
|
+
/* @__PURE__ */ jsx32(
|
|
4702
6332
|
"div",
|
|
4703
6333
|
{
|
|
4704
6334
|
className: cn(
|
|
@@ -4708,7 +6338,7 @@ function ReferenceChip({
|
|
|
4708
6338
|
children: getReferenceLabel(reference)
|
|
4709
6339
|
}
|
|
4710
6340
|
),
|
|
4711
|
-
metaLine && /* @__PURE__ */
|
|
6341
|
+
metaLine && /* @__PURE__ */ jsx32(
|
|
4712
6342
|
"div",
|
|
4713
6343
|
{
|
|
4714
6344
|
className: cn(
|
|
@@ -4719,7 +6349,7 @@ function ReferenceChip({
|
|
|
4719
6349
|
}
|
|
4720
6350
|
)
|
|
4721
6351
|
] }),
|
|
4722
|
-
onRemove && removeLabel && /* @__PURE__ */
|
|
6352
|
+
onRemove && removeLabel && /* @__PURE__ */ jsx32(
|
|
4723
6353
|
"button",
|
|
4724
6354
|
{
|
|
4725
6355
|
type: "button",
|
|
@@ -4730,7 +6360,7 @@ function ReferenceChip({
|
|
|
4730
6360
|
),
|
|
4731
6361
|
title: removeLabel,
|
|
4732
6362
|
"aria-label": removeLabel,
|
|
4733
|
-
children: /* @__PURE__ */
|
|
6363
|
+
children: /* @__PURE__ */ jsx32(X3, { size: 12 })
|
|
4734
6364
|
}
|
|
4735
6365
|
)
|
|
4736
6366
|
]
|
|
@@ -4754,20 +6384,20 @@ function Chat({
|
|
|
4754
6384
|
const { setStream } = useStreamManager();
|
|
4755
6385
|
const stream = useStreamContext();
|
|
4756
6386
|
const { theme } = useTheme();
|
|
4757
|
-
const [isHistoryLoading, setIsHistoryLoading] =
|
|
4758
|
-
const [historyError, setHistoryError] =
|
|
4759
|
-
const [assistantName, setAssistantName] =
|
|
4760
|
-
const [assistantAvatar, setAssistantAvatar] =
|
|
6387
|
+
const [isHistoryLoading, setIsHistoryLoading] = React26.useState(false);
|
|
6388
|
+
const [historyError, setHistoryError] = React26.useState(null);
|
|
6389
|
+
const [assistantName, setAssistantName] = React26.useState(null);
|
|
6390
|
+
const [assistantAvatar, setAssistantAvatar] = React26.useState(null);
|
|
4761
6391
|
const LOADING_DOTS_MIN_DURATION = 800;
|
|
4762
6392
|
const STREAMING_STATUS_REFRESH_MS = 250;
|
|
4763
|
-
const [showLoadingDots, setShowLoadingDots] =
|
|
4764
|
-
const [streamingNow, setStreamingNow] =
|
|
4765
|
-
const loadingStartTimeRef =
|
|
4766
|
-
const lastStreamOutputAtRef =
|
|
4767
|
-
|
|
6393
|
+
const [showLoadingDots, setShowLoadingDots] = React26.useState(false);
|
|
6394
|
+
const [streamingNow, setStreamingNow] = React26.useState(() => Date.now());
|
|
6395
|
+
const loadingStartTimeRef = React26.useRef(null);
|
|
6396
|
+
const lastStreamOutputAtRef = React26.useRef(null);
|
|
6397
|
+
React26.useEffect(() => {
|
|
4768
6398
|
setStream(stream);
|
|
4769
6399
|
}, [setStream, stream]);
|
|
4770
|
-
|
|
6400
|
+
React26.useEffect(() => {
|
|
4771
6401
|
if (stream.isLoading) {
|
|
4772
6402
|
if (!loadingStartTimeRef.current) {
|
|
4773
6403
|
loadingStartTimeRef.current = Date.now();
|
|
@@ -4790,7 +6420,7 @@ function Chat({
|
|
|
4790
6420
|
}
|
|
4791
6421
|
}
|
|
4792
6422
|
}, [stream.isLoading]);
|
|
4793
|
-
|
|
6423
|
+
React26.useEffect(() => {
|
|
4794
6424
|
if (!stream.isLoading) {
|
|
4795
6425
|
lastStreamOutputAtRef.current = null;
|
|
4796
6426
|
setStreamingNow(Date.now());
|
|
@@ -4800,7 +6430,7 @@ function Chat({
|
|
|
4800
6430
|
lastStreamOutputAtRef.current = now;
|
|
4801
6431
|
setStreamingNow(now);
|
|
4802
6432
|
}, [stream.messages, stream.isLoading]);
|
|
4803
|
-
|
|
6433
|
+
React26.useEffect(() => {
|
|
4804
6434
|
if (!stream.isLoading) {
|
|
4805
6435
|
return;
|
|
4806
6436
|
}
|
|
@@ -4809,53 +6439,55 @@ function Chat({
|
|
|
4809
6439
|
}, STREAMING_STATUS_REFRESH_MS);
|
|
4810
6440
|
return () => window.clearInterval(timer);
|
|
4811
6441
|
}, [stream.isLoading]);
|
|
4812
|
-
const [draft, setDraft] =
|
|
4813
|
-
const [selectedTool, setSelectedTool] =
|
|
6442
|
+
const [draft, setDraft] = React26.useState("");
|
|
6443
|
+
const [selectedTool, setSelectedTool] = React26.useState(
|
|
4814
6444
|
null
|
|
4815
6445
|
);
|
|
4816
|
-
const [
|
|
4817
|
-
const [
|
|
4818
|
-
const [
|
|
4819
|
-
const [
|
|
4820
|
-
const [
|
|
4821
|
-
const [
|
|
6446
|
+
const [planModeEnabled, setPlanModeEnabled] = React26.useState(false);
|
|
6447
|
+
const [attachments, setAttachments] = React26.useState([]);
|
|
6448
|
+
const [references, setReferences] = React26.useState([]);
|
|
6449
|
+
const [isUploadingReferenceImages, setIsUploadingReferenceImages] = React26.useState(false);
|
|
6450
|
+
const [quoteSelection, setQuoteSelection] = React26.useState(null);
|
|
6451
|
+
const [isAtBottom, setIsAtBottom] = React26.useState(true);
|
|
6452
|
+
const [hasUpdatesBelow, setHasUpdatesBelow] = React26.useState(false);
|
|
4822
6453
|
const {
|
|
4823
6454
|
threads,
|
|
4824
6455
|
deleteThread,
|
|
4825
6456
|
refreshThreads,
|
|
4826
6457
|
isLoading: isThreadsLoading
|
|
4827
6458
|
} = useThreads();
|
|
4828
|
-
const viewportRef =
|
|
4829
|
-
const fileInputRef =
|
|
4830
|
-
const composerInputRef =
|
|
4831
|
-
const shouldAutoScrollRef =
|
|
4832
|
-
const forceFollowRef =
|
|
4833
|
-
const previousMessageCountRef =
|
|
4834
|
-
const previousScrollTopRef =
|
|
4835
|
-
const autoScrollFrameRef =
|
|
4836
|
-
const isPointerDownRef =
|
|
4837
|
-
const lastTouchYRef =
|
|
6459
|
+
const viewportRef = React26.useRef(null);
|
|
6460
|
+
const fileInputRef = React26.useRef(null);
|
|
6461
|
+
const composerInputRef = React26.useRef(null);
|
|
6462
|
+
const shouldAutoScrollRef = React26.useRef(true);
|
|
6463
|
+
const forceFollowRef = React26.useRef(false);
|
|
6464
|
+
const previousMessageCountRef = React26.useRef(0);
|
|
6465
|
+
const previousScrollTopRef = React26.useRef(0);
|
|
6466
|
+
const autoScrollFrameRef = React26.useRef(null);
|
|
6467
|
+
const isPointerDownRef = React26.useRef(false);
|
|
6468
|
+
const lastTouchYRef = React26.useRef(null);
|
|
4838
6469
|
const resolvedTitle = title ?? t("chat.title");
|
|
4839
6470
|
const resolvedPlaceholder = placeholder ?? t("chat.placeholder");
|
|
4840
6471
|
const inputPlaceholder = selectedTool?.placeholderOverride ?? composer?.placeholder ?? resolvedPlaceholder;
|
|
4841
|
-
const messages =
|
|
6472
|
+
const messages = React26.useMemo(
|
|
4842
6473
|
() => stream.messages ?? [],
|
|
4843
6474
|
[stream.messages]
|
|
4844
6475
|
);
|
|
4845
6476
|
const trimmedDraft = draft.trim();
|
|
4846
6477
|
const hasReferences = references.length > 0;
|
|
4847
|
-
const pendingFollowUps =
|
|
6478
|
+
const pendingFollowUps = React26.useMemo(
|
|
4848
6479
|
() => [...stream.pendingFollowUps ?? []].sort(
|
|
4849
6480
|
(a, b) => a.createdAt - b.createdAt
|
|
4850
6481
|
),
|
|
4851
6482
|
[stream.pendingFollowUps]
|
|
4852
6483
|
);
|
|
4853
6484
|
const hasPendingFollowUps = pendingFollowUps.length > 0;
|
|
4854
|
-
const
|
|
6485
|
+
const hasPendingRequestUserInput = Boolean(stream.pendingRequestUserInput);
|
|
6486
|
+
const clearQuoteSelection = React26.useCallback(() => {
|
|
4855
6487
|
setQuoteSelection(null);
|
|
4856
6488
|
}, []);
|
|
4857
6489
|
useParentMessenger({
|
|
4858
|
-
onSetComposerValue:
|
|
6490
|
+
onSetComposerValue: React26.useCallback(
|
|
4859
6491
|
(payload) => {
|
|
4860
6492
|
if (!payload) {
|
|
4861
6493
|
return;
|
|
@@ -4878,11 +6510,11 @@ function Chat({
|
|
|
4878
6510
|
},
|
|
4879
6511
|
[composer?.tools]
|
|
4880
6512
|
),
|
|
4881
|
-
onFocusComposer:
|
|
6513
|
+
onFocusComposer: React26.useCallback(() => {
|
|
4882
6514
|
composerInputRef.current?.focus();
|
|
4883
6515
|
}, [])
|
|
4884
6516
|
});
|
|
4885
|
-
const syncQuoteSelection =
|
|
6517
|
+
const syncQuoteSelection = React26.useCallback(() => {
|
|
4886
6518
|
if (typeof window === "undefined") {
|
|
4887
6519
|
clearQuoteSelection();
|
|
4888
6520
|
return;
|
|
@@ -4927,23 +6559,23 @@ function Chat({
|
|
|
4927
6559
|
left
|
|
4928
6560
|
});
|
|
4929
6561
|
}, [clearQuoteSelection]);
|
|
4930
|
-
const cancelPendingAutoScroll =
|
|
6562
|
+
const cancelPendingAutoScroll = React26.useCallback(() => {
|
|
4931
6563
|
if (autoScrollFrameRef.current !== null) {
|
|
4932
6564
|
cancelAnimationFrame(autoScrollFrameRef.current);
|
|
4933
6565
|
autoScrollFrameRef.current = null;
|
|
4934
6566
|
}
|
|
4935
6567
|
}, []);
|
|
4936
|
-
const disableAutoFollow =
|
|
6568
|
+
const disableAutoFollow = React26.useCallback(() => {
|
|
4937
6569
|
forceFollowRef.current = false;
|
|
4938
6570
|
shouldAutoScrollRef.current = false;
|
|
4939
6571
|
cancelPendingAutoScroll();
|
|
4940
6572
|
}, [cancelPendingAutoScroll]);
|
|
4941
|
-
const enableAutoFollow =
|
|
6573
|
+
const enableAutoFollow = React26.useCallback(() => {
|
|
4942
6574
|
forceFollowRef.current = true;
|
|
4943
6575
|
shouldAutoScrollRef.current = true;
|
|
4944
6576
|
setHasUpdatesBelow(false);
|
|
4945
6577
|
}, []);
|
|
4946
|
-
const scrollToBottom =
|
|
6578
|
+
const scrollToBottom = React26.useCallback(
|
|
4947
6579
|
(smooth = false, force = false) => {
|
|
4948
6580
|
if (force) {
|
|
4949
6581
|
enableAutoFollow();
|
|
@@ -4965,7 +6597,7 @@ function Chat({
|
|
|
4965
6597
|
},
|
|
4966
6598
|
[cancelPendingAutoScroll, enableAutoFollow]
|
|
4967
6599
|
);
|
|
4968
|
-
|
|
6600
|
+
React26.useEffect(() => {
|
|
4969
6601
|
const viewport = viewportRef.current;
|
|
4970
6602
|
if (!viewport) return;
|
|
4971
6603
|
previousScrollTopRef.current = viewport.scrollTop;
|
|
@@ -5046,14 +6678,14 @@ function Chat({
|
|
|
5046
6678
|
window.removeEventListener("pointercancel", stopPointerTracking);
|
|
5047
6679
|
};
|
|
5048
6680
|
}, [cancelPendingAutoScroll, disableAutoFollow]);
|
|
5049
|
-
|
|
6681
|
+
React26.useEffect(() => {
|
|
5050
6682
|
shouldAutoScrollRef.current = true;
|
|
5051
6683
|
forceFollowRef.current = false;
|
|
5052
6684
|
previousScrollTopRef.current = 0;
|
|
5053
6685
|
setIsAtBottom(true);
|
|
5054
6686
|
setHasUpdatesBelow(false);
|
|
5055
6687
|
}, [stream.threadId]);
|
|
5056
|
-
|
|
6688
|
+
React26.useEffect(() => {
|
|
5057
6689
|
const messageCountChanged = messages.length !== previousMessageCountRef.current;
|
|
5058
6690
|
previousMessageCountRef.current = messages.length;
|
|
5059
6691
|
if (!shouldAutoScrollRef.current) {
|
|
@@ -5072,7 +6704,7 @@ function Chat({
|
|
|
5072
6704
|
clientSecret: effectiveClientSecret
|
|
5073
6705
|
});
|
|
5074
6706
|
const missingConfig = Boolean(missingConfigKind);
|
|
5075
|
-
const missingConfigShortMessage =
|
|
6707
|
+
const missingConfigShortMessage = React26.useMemo(() => {
|
|
5076
6708
|
switch (missingConfigKind) {
|
|
5077
6709
|
case "apiUrl":
|
|
5078
6710
|
return t("chat.missingApiUrlShort");
|
|
@@ -5084,7 +6716,7 @@ function Chat({
|
|
|
5084
6716
|
return t("chat.missingConfigShort");
|
|
5085
6717
|
}
|
|
5086
6718
|
}, [missingConfigKind, t]);
|
|
5087
|
-
const missingConfigDetailMessage =
|
|
6719
|
+
const missingConfigDetailMessage = React26.useMemo(() => {
|
|
5088
6720
|
switch (missingConfigKind) {
|
|
5089
6721
|
case "apiUrl":
|
|
5090
6722
|
return t("chat.missingApiUrlDetail");
|
|
@@ -5098,8 +6730,8 @@ function Chat({
|
|
|
5098
6730
|
}, [missingConfigKind, t]);
|
|
5099
6731
|
const showMissingConfig = !isClientSecretInitializing && missingConfig;
|
|
5100
6732
|
const hasUploadingFiles = attachments.some((a) => a.status === "uploading");
|
|
5101
|
-
const isSendDisabled = !trimmedDraft && !hasReferences || missingConfig || isHistoryLoading || hasUploadingFiles || isUploadingReferenceImages;
|
|
5102
|
-
const resizeComposerInput =
|
|
6733
|
+
const isSendDisabled = !trimmedDraft && !hasReferences || hasPendingRequestUserInput || missingConfig || isHistoryLoading || hasUploadingFiles || isUploadingReferenceImages;
|
|
6734
|
+
const resizeComposerInput = React26.useCallback(() => {
|
|
5103
6735
|
const textarea = composerInputRef.current;
|
|
5104
6736
|
if (!textarea) {
|
|
5105
6737
|
return;
|
|
@@ -5112,16 +6744,16 @@ function Chat({
|
|
|
5112
6744
|
textarea.style.height = `${nextHeight}px`;
|
|
5113
6745
|
textarea.style.overflowY = textarea.scrollHeight > COMPOSER_INPUT_MAX_HEIGHT ? "auto" : "hidden";
|
|
5114
6746
|
}, []);
|
|
5115
|
-
|
|
6747
|
+
React26.useEffect(() => {
|
|
5116
6748
|
resizeComposerInput();
|
|
5117
6749
|
}, [draft, resizeComposerInput]);
|
|
5118
|
-
|
|
6750
|
+
React26.useEffect(() => {
|
|
5119
6751
|
document.addEventListener("selectionchange", syncQuoteSelection);
|
|
5120
6752
|
return () => {
|
|
5121
6753
|
document.removeEventListener("selectionchange", syncQuoteSelection);
|
|
5122
6754
|
};
|
|
5123
6755
|
}, [syncQuoteSelection]);
|
|
5124
|
-
|
|
6756
|
+
React26.useEffect(() => {
|
|
5125
6757
|
const viewport = viewportRef.current;
|
|
5126
6758
|
if (!viewport) {
|
|
5127
6759
|
return;
|
|
@@ -5138,14 +6770,14 @@ function Chat({
|
|
|
5138
6770
|
window.removeEventListener("resize", handleViewportScroll);
|
|
5139
6771
|
};
|
|
5140
6772
|
}, [clearQuoteSelection]);
|
|
5141
|
-
|
|
6773
|
+
React26.useEffect(() => {
|
|
5142
6774
|
clearQuoteSelection();
|
|
5143
6775
|
}, [messages.length, stream.threadId, clearQuoteSelection]);
|
|
5144
|
-
|
|
6776
|
+
React26.useEffect(() => {
|
|
5145
6777
|
if (missingConfig) return;
|
|
5146
6778
|
void refreshThreads();
|
|
5147
6779
|
}, [missingConfig, refreshThreads]);
|
|
5148
|
-
|
|
6780
|
+
React26.useEffect(() => {
|
|
5149
6781
|
if (missingConfig || !stream.client || !stream.assistantId) {
|
|
5150
6782
|
setAssistantName(null);
|
|
5151
6783
|
setAssistantAvatar(null);
|
|
@@ -5176,7 +6808,7 @@ function Chat({
|
|
|
5176
6808
|
mimetype: a.storageFile?.mimetype ?? a.file.type,
|
|
5177
6809
|
size: a.storageFile?.size ?? a.file.size
|
|
5178
6810
|
}));
|
|
5179
|
-
const submitDraft =
|
|
6811
|
+
const submitDraft = React26.useCallback(
|
|
5180
6812
|
(followUpOverride) => {
|
|
5181
6813
|
if (isSendDisabled) return;
|
|
5182
6814
|
const filesToSend = uploadedFiles.length > 0 ? [...uploadedFiles] : void 0;
|
|
@@ -5206,6 +6838,9 @@ function Chat({
|
|
|
5206
6838
|
if (filesToSend) {
|
|
5207
6839
|
inputPayload.files = filesToSend;
|
|
5208
6840
|
}
|
|
6841
|
+
if (planModeEnabled) {
|
|
6842
|
+
inputPayload.planMode = true;
|
|
6843
|
+
}
|
|
5209
6844
|
const requestOptions = buildInjectedRequestOptions({
|
|
5210
6845
|
defaults: options?.request,
|
|
5211
6846
|
humanInput: inputPayload
|
|
@@ -5240,6 +6875,7 @@ function Chat({
|
|
|
5240
6875
|
references,
|
|
5241
6876
|
scrollToBottom,
|
|
5242
6877
|
selectedTool,
|
|
6878
|
+
planModeEnabled,
|
|
5243
6879
|
stream,
|
|
5244
6880
|
trimmedDraft,
|
|
5245
6881
|
uploadedFiles,
|
|
@@ -5250,7 +6886,7 @@ function Chat({
|
|
|
5250
6886
|
event.preventDefault();
|
|
5251
6887
|
submitDraft();
|
|
5252
6888
|
};
|
|
5253
|
-
const handleEditPendingFollowUp =
|
|
6889
|
+
const handleEditPendingFollowUp = React26.useCallback(
|
|
5254
6890
|
(id) => {
|
|
5255
6891
|
const item = pendingFollowUps.find(
|
|
5256
6892
|
(entry) => entry.id === id && entry.mode === "queue"
|
|
@@ -5277,7 +6913,7 @@ function Chat({
|
|
|
5277
6913
|
},
|
|
5278
6914
|
[pendingFollowUps, stream]
|
|
5279
6915
|
);
|
|
5280
|
-
const handleQuoteSelection =
|
|
6916
|
+
const handleQuoteSelection = React26.useCallback(() => {
|
|
5281
6917
|
if (!quoteSelection) {
|
|
5282
6918
|
return;
|
|
5283
6919
|
}
|
|
@@ -5293,7 +6929,7 @@ function Chat({
|
|
|
5293
6929
|
const handleAttachmentClick = () => {
|
|
5294
6930
|
fileInputRef.current?.click();
|
|
5295
6931
|
};
|
|
5296
|
-
const uploadContextFile =
|
|
6932
|
+
const uploadContextFile = React26.useCallback(
|
|
5297
6933
|
(file) => stream.client.contexts.uploadFile(file),
|
|
5298
6934
|
[stream.client]
|
|
5299
6935
|
);
|
|
@@ -5319,7 +6955,7 @@ function Chat({
|
|
|
5319
6955
|
}
|
|
5320
6956
|
submitDraft();
|
|
5321
6957
|
};
|
|
5322
|
-
const handleComposerPaste =
|
|
6958
|
+
const handleComposerPaste = React26.useCallback(
|
|
5323
6959
|
(event) => {
|
|
5324
6960
|
const clipboardData = event.clipboardData;
|
|
5325
6961
|
if (!clipboardData) {
|
|
@@ -5398,18 +7034,18 @@ function Chat({
|
|
|
5398
7034
|
uploadContextFile
|
|
5399
7035
|
]
|
|
5400
7036
|
);
|
|
5401
|
-
const alternateFollowUpShortcutLabel =
|
|
7037
|
+
const alternateFollowUpShortcutLabel = React26.useMemo(() => {
|
|
5402
7038
|
if (typeof navigator === "undefined") {
|
|
5403
7039
|
return "\u2318Enter";
|
|
5404
7040
|
}
|
|
5405
7041
|
const platform = navigator.platform || navigator.userAgent;
|
|
5406
7042
|
return /Mac|iPhone|iPad|iPod/i.test(platform) ? "\u2318Enter" : "Ctrl+Enter";
|
|
5407
7043
|
}, []);
|
|
5408
|
-
const followUpShortcutLabels =
|
|
7044
|
+
const followUpShortcutLabels = React26.useMemo(
|
|
5409
7045
|
() => getComposerFollowUpShortcutLabels(alternateFollowUpShortcutLabel),
|
|
5410
7046
|
[alternateFollowUpShortcutLabel]
|
|
5411
7047
|
);
|
|
5412
|
-
const uploadFile =
|
|
7048
|
+
const uploadFile = React26.useCallback(
|
|
5413
7049
|
async (localId, file) => {
|
|
5414
7050
|
try {
|
|
5415
7051
|
const result = await uploadContextFile(file);
|
|
@@ -5432,7 +7068,7 @@ function Chat({
|
|
|
5432
7068
|
},
|
|
5433
7069
|
[uploadContextFile]
|
|
5434
7070
|
);
|
|
5435
|
-
const handleRetryUpload =
|
|
7071
|
+
const handleRetryUpload = React26.useCallback(
|
|
5436
7072
|
(localId) => {
|
|
5437
7073
|
const attachment = attachments.find((a) => a.localId === localId);
|
|
5438
7074
|
if (!attachment || attachment.status !== "error") return;
|
|
@@ -5503,10 +7139,23 @@ function Chat({
|
|
|
5503
7139
|
content: prompt
|
|
5504
7140
|
};
|
|
5505
7141
|
const nextFollowUpMode = stream.isLoading ? stream.followUpBehavior : void 0;
|
|
7142
|
+
const inputPayload = {
|
|
7143
|
+
input: prompt,
|
|
7144
|
+
...planModeEnabled ? { planMode: true } : {}
|
|
7145
|
+
};
|
|
7146
|
+
const requestOptions = buildInjectedRequestOptions({
|
|
7147
|
+
defaults: options?.request,
|
|
7148
|
+
humanInput: inputPayload
|
|
7149
|
+
});
|
|
5506
7150
|
stream.submit(
|
|
5507
|
-
{
|
|
7151
|
+
{
|
|
7152
|
+
input: inputPayload,
|
|
7153
|
+
...requestOptions.state ? { state: requestOptions.state } : {}
|
|
7154
|
+
},
|
|
5508
7155
|
{
|
|
5509
7156
|
...nextFollowUpMode ? { followUpMode: nextFollowUpMode } : {},
|
|
7157
|
+
...requestOptions.context ? { context: requestOptions.context } : {},
|
|
7158
|
+
...requestOptions.config ? { config: requestOptions.config } : {},
|
|
5510
7159
|
...!nextFollowUpMode ? {
|
|
5511
7160
|
optimisticValues: (prev) => {
|
|
5512
7161
|
const prevMessages = prev?.messages ?? [];
|
|
@@ -5517,7 +7166,7 @@ function Chat({
|
|
|
5517
7166
|
);
|
|
5518
7167
|
scrollToBottom(true, true);
|
|
5519
7168
|
};
|
|
5520
|
-
const loadConversationMessages =
|
|
7169
|
+
const loadConversationMessages = React26.useCallback(
|
|
5521
7170
|
async (recordId) => {
|
|
5522
7171
|
if (missingConfig) {
|
|
5523
7172
|
setHistoryError(missingConfigShortMessage);
|
|
@@ -5603,18 +7252,18 @@ function Chat({
|
|
|
5603
7252
|
}
|
|
5604
7253
|
};
|
|
5605
7254
|
const acceptMimes = composer?.attachments?.accept ? Object.entries(composer.attachments.accept).map(([mime, exts]) => [mime, ...exts.map((e) => `.${e}`)].join(",")).join(",") : void 0;
|
|
5606
|
-
const currentThread =
|
|
7255
|
+
const currentThread = React26.useMemo(
|
|
5607
7256
|
() => threads.find((item) => item.id === stream.threadId),
|
|
5608
7257
|
[threads, stream.threadId]
|
|
5609
7258
|
);
|
|
5610
7259
|
const errorMessage = stream.error instanceof Error ? stream.error.message : void 0;
|
|
5611
|
-
const threadErrorMessage =
|
|
7260
|
+
const threadErrorMessage = React26.useMemo(() => {
|
|
5612
7261
|
if (currentThread?.status !== "error") return void 0;
|
|
5613
7262
|
const message = currentThread.error?.trim();
|
|
5614
7263
|
return message || t("thread.errorToast");
|
|
5615
7264
|
}, [currentThread, t]);
|
|
5616
7265
|
const assistantTitle = assistantName || resolvedTitle;
|
|
5617
|
-
return /* @__PURE__ */
|
|
7266
|
+
return /* @__PURE__ */ jsxs21(
|
|
5618
7267
|
"div",
|
|
5619
7268
|
{
|
|
5620
7269
|
ref: viewportRef,
|
|
@@ -5623,10 +7272,10 @@ function Chat({
|
|
|
5623
7272
|
className
|
|
5624
7273
|
),
|
|
5625
7274
|
children: [
|
|
5626
|
-
/* @__PURE__ */
|
|
5627
|
-
/* @__PURE__ */
|
|
5628
|
-
/* @__PURE__ */
|
|
5629
|
-
/* @__PURE__ */
|
|
7275
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center justify-between border-b p-2 sticky top-0 z-10 bg-background", children: [
|
|
7276
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-3 overflow-hidden", children: [
|
|
7277
|
+
/* @__PURE__ */ jsxs21("div", { className: "relative shrink-0", children: [
|
|
7278
|
+
/* @__PURE__ */ jsx32(
|
|
5630
7279
|
ChatkitAvatar,
|
|
5631
7280
|
{
|
|
5632
7281
|
avatar: assistantAvatar,
|
|
@@ -5634,10 +7283,10 @@ function Chat({
|
|
|
5634
7283
|
label: assistantTitle
|
|
5635
7284
|
}
|
|
5636
7285
|
),
|
|
5637
|
-
/* @__PURE__ */
|
|
7286
|
+
/* @__PURE__ */ jsx32("span", { className: "absolute bottom-0 right-0 h-2.5 w-2.5 rounded-full border-2 border-background bg-green-500" })
|
|
5638
7287
|
] }),
|
|
5639
|
-
/* @__PURE__ */
|
|
5640
|
-
/* @__PURE__ */
|
|
7288
|
+
/* @__PURE__ */ jsxs21("div", { className: "truncate", children: [
|
|
7289
|
+
/* @__PURE__ */ jsx32(
|
|
5641
7290
|
"h2",
|
|
5642
7291
|
{
|
|
5643
7292
|
className: "text-lg font-semibold truncate",
|
|
@@ -5645,27 +7294,30 @@ function Chat({
|
|
|
5645
7294
|
children: assistantTitle
|
|
5646
7295
|
}
|
|
5647
7296
|
),
|
|
5648
|
-
/* @__PURE__ */
|
|
7297
|
+
/* @__PURE__ */ jsx32("p", { className: "text-xs text-muted-foreground", children: t("chat.statusOnline") })
|
|
5649
7298
|
] })
|
|
5650
7299
|
] }),
|
|
5651
|
-
history?.enabled !== false && /* @__PURE__ */
|
|
5652
|
-
/* @__PURE__ */
|
|
5653
|
-
"
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
7300
|
+
history?.enabled !== false && /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-1", children: [
|
|
7301
|
+
/* @__PURE__ */ jsxs21(Tooltip, { children: [
|
|
7302
|
+
/* @__PURE__ */ jsx32(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx32("span", { className: "inline-flex h-8 w-8", children: /* @__PURE__ */ jsx32(
|
|
7303
|
+
"button",
|
|
7304
|
+
{
|
|
7305
|
+
type: "button",
|
|
7306
|
+
onClick: handleNewThread,
|
|
7307
|
+
disabled: missingConfig || isHistoryLoading,
|
|
7308
|
+
className: cn(
|
|
7309
|
+
"flex h-8 w-8 cursor-pointer items-center justify-center rounded-md",
|
|
7310
|
+
"text-muted-foreground hover:text-foreground hover:bg-muted",
|
|
7311
|
+
"transition-colors duration-150",
|
|
7312
|
+
"disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed"
|
|
7313
|
+
),
|
|
7314
|
+
"aria-label": t("history.newThread"),
|
|
7315
|
+
children: /* @__PURE__ */ jsx32(Pencil3, { size: 16 })
|
|
7316
|
+
}
|
|
7317
|
+
) }) }),
|
|
7318
|
+
/* @__PURE__ */ jsx32(TooltipContent, { side: "bottom", children: t("history.newThread") })
|
|
7319
|
+
] }),
|
|
7320
|
+
/* @__PURE__ */ jsx32(
|
|
5669
7321
|
HistorySidebar,
|
|
5670
7322
|
{
|
|
5671
7323
|
threads,
|
|
@@ -5679,18 +7331,18 @@ function Chat({
|
|
|
5679
7331
|
)
|
|
5680
7332
|
] })
|
|
5681
7333
|
] }),
|
|
5682
|
-
/* @__PURE__ */
|
|
5683
|
-
errorMessage && /* @__PURE__ */
|
|
5684
|
-
historyError && /* @__PURE__ */
|
|
5685
|
-
showMissingConfig && /* @__PURE__ */
|
|
5686
|
-
isHistoryLoading && /* @__PURE__ */
|
|
5687
|
-
messages.length === 0 ? /* @__PURE__ */
|
|
7334
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex-1 p-4", children: [
|
|
7335
|
+
errorMessage && /* @__PURE__ */ jsx32("div", { className: "mb-4 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive", children: errorMessage }),
|
|
7336
|
+
historyError && /* @__PURE__ */ jsx32("div", { className: "mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900", children: historyError }),
|
|
7337
|
+
showMissingConfig && /* @__PURE__ */ jsx32("div", { className: "mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900", children: missingConfigDetailMessage }),
|
|
7338
|
+
isHistoryLoading && /* @__PURE__ */ jsx32("div", { className: "mb-4 rounded-lg border border-muted px-3 py-2 text-sm text-muted-foreground", children: t("chat.loadingThread") }),
|
|
7339
|
+
messages.length === 0 ? /* @__PURE__ */ jsx32(
|
|
5688
7340
|
StartScreen,
|
|
5689
7341
|
{
|
|
5690
7342
|
startScreen,
|
|
5691
7343
|
onPromptClick: handlePromptClick
|
|
5692
7344
|
}
|
|
5693
|
-
) : /* @__PURE__ */
|
|
7345
|
+
) : /* @__PURE__ */ jsxs21("div", { className: "space-y-4", children: [
|
|
5694
7346
|
messages.map((message, index) => {
|
|
5695
7347
|
const messageType = String(message.type);
|
|
5696
7348
|
const isAssistantMessage = messageType === "assistant" || messageType === "ai";
|
|
@@ -5717,7 +7369,7 @@ function Chat({
|
|
|
5717
7369
|
if (!isAssistantMessage && !hasPlainRenderableContent && !hasHumanAttachments && humanReferences.length === 0) {
|
|
5718
7370
|
return null;
|
|
5719
7371
|
}
|
|
5720
|
-
return /* @__PURE__ */
|
|
7372
|
+
return /* @__PURE__ */ jsx32(
|
|
5721
7373
|
"div",
|
|
5722
7374
|
{
|
|
5723
7375
|
className: cn(
|
|
@@ -5725,8 +7377,8 @@ function Chat({
|
|
|
5725
7377
|
message.type === "human" ? "justify-end" : "justify-start -ml-1"
|
|
5726
7378
|
// AI messages: slightly closer to left
|
|
5727
7379
|
),
|
|
5728
|
-
children: /* @__PURE__ */
|
|
5729
|
-
/* @__PURE__ */
|
|
7380
|
+
children: /* @__PURE__ */ jsxs21("div", { className: "flex flex-col px-3 overflow-hidden", children: [
|
|
7381
|
+
/* @__PURE__ */ jsx32(
|
|
5730
7382
|
"div",
|
|
5731
7383
|
{
|
|
5732
7384
|
...canQuoteMessage ? {
|
|
@@ -5738,18 +7390,24 @@ function Chat({
|
|
|
5738
7390
|
message.type === "human" ? "bg-primary text-primary-foreground px-4 py-2.5" : message.type === "system" ? "bg-muted text-muted-foreground text-xs px-4 py-2.5" : "py-1 text-chat-foreground"
|
|
5739
7391
|
// AI messages: use chat-specific foreground color
|
|
5740
7392
|
),
|
|
5741
|
-
children: isAssistantMessage ? /* @__PURE__ */
|
|
7393
|
+
children: isAssistantMessage ? /* @__PURE__ */ jsx32(
|
|
5742
7394
|
AssistantMessage,
|
|
5743
7395
|
{
|
|
5744
7396
|
message: {
|
|
5745
7397
|
...message,
|
|
5746
7398
|
type: "assistant"
|
|
5747
7399
|
},
|
|
7400
|
+
messages: messages.slice(0, index + 1).map(
|
|
7401
|
+
(item) => ({
|
|
7402
|
+
...item,
|
|
7403
|
+
type: String(item.type) === "ai" ? "assistant" : item.type
|
|
7404
|
+
})
|
|
7405
|
+
),
|
|
5748
7406
|
isStreaming: isStreamingMessage,
|
|
5749
7407
|
streamingStatus
|
|
5750
7408
|
}
|
|
5751
|
-
) : /* @__PURE__ */
|
|
5752
|
-
message.type === "human" && humanReferences.length > 0 && /* @__PURE__ */
|
|
7409
|
+
) : /* @__PURE__ */ jsxs21(Fragment4, { children: [
|
|
7410
|
+
message.type === "human" && humanReferences.length > 0 && /* @__PURE__ */ jsx32("div", { className: "mb-2 flex flex-wrap gap-1.5", children: humanReferences.map((reference) => /* @__PURE__ */ jsx32(
|
|
5753
7411
|
ReferenceChip,
|
|
5754
7412
|
{
|
|
5755
7413
|
reference,
|
|
@@ -5757,29 +7415,29 @@ function Chat({
|
|
|
5757
7415
|
},
|
|
5758
7416
|
getReferenceKey(reference)
|
|
5759
7417
|
)) }),
|
|
5760
|
-
message.type === "human" && humanAttachments.length > 0 && /* @__PURE__ */
|
|
7418
|
+
message.type === "human" && humanAttachments.length > 0 && /* @__PURE__ */ jsx32("div", { className: "flex flex-wrap gap-1.5 mb-2", children: humanAttachments.map((file, fileIndex) => /* @__PURE__ */ jsxs21(
|
|
5761
7419
|
"div",
|
|
5762
7420
|
{
|
|
5763
7421
|
className: "flex items-center gap-1.5 rounded-md bg-primary-foreground/20 px-2 py-1 text-xs",
|
|
5764
7422
|
children: [
|
|
5765
|
-
/* @__PURE__ */
|
|
5766
|
-
/* @__PURE__ */
|
|
7423
|
+
/* @__PURE__ */ jsx32(FileText2, { size: 12 }),
|
|
7424
|
+
/* @__PURE__ */ jsx32("span", { className: "max-w-[100px] truncate", children: file.originalName })
|
|
5767
7425
|
]
|
|
5768
7426
|
},
|
|
5769
7427
|
fileIndex
|
|
5770
7428
|
)) }),
|
|
5771
|
-
Array.isArray(message.content) ? message.content.map((part, partIndex) => /* @__PURE__ */
|
|
7429
|
+
Array.isArray(message.content) ? message.content.map((part, partIndex) => /* @__PURE__ */ jsx32(
|
|
5772
7430
|
"p",
|
|
5773
7431
|
{
|
|
5774
7432
|
className: "wrap-break-word text-sm leading-relaxed",
|
|
5775
7433
|
children: formatMessageContent(part)
|
|
5776
7434
|
},
|
|
5777
7435
|
`${part.type}-${partIndex}`
|
|
5778
|
-
)) : /* @__PURE__ */
|
|
7436
|
+
)) : /* @__PURE__ */ jsx32("span", { className: "wrap-break-word text-sm leading-relaxed", children: formatMessageContent(message.content) })
|
|
5779
7437
|
] })
|
|
5780
7438
|
}
|
|
5781
7439
|
),
|
|
5782
|
-
/* @__PURE__ */
|
|
7440
|
+
/* @__PURE__ */ jsx32(
|
|
5783
7441
|
MessageActions,
|
|
5784
7442
|
{
|
|
5785
7443
|
content: messageContent,
|
|
@@ -5815,7 +7473,7 @@ function Chat({
|
|
|
5815
7473
|
stream.isLoading,
|
|
5816
7474
|
{ now: streamingNow }
|
|
5817
7475
|
);
|
|
5818
|
-
return /* @__PURE__ */
|
|
7476
|
+
return /* @__PURE__ */ jsx32("div", { className: "flex justify-start gap-3 -ml-2", children: /* @__PURE__ */ jsx32("div", { className: "max-w-full rounded-2xl py-2.5", children: /* @__PURE__ */ jsx32(
|
|
5819
7477
|
AssistantStreamingIndicator,
|
|
5820
7478
|
{
|
|
5821
7479
|
status: fallbackStreamingStatus ?? "loading"
|
|
@@ -5824,7 +7482,7 @@ function Chat({
|
|
|
5824
7482
|
})()
|
|
5825
7483
|
] })
|
|
5826
7484
|
] }),
|
|
5827
|
-
!isAtBottom && messages.length > 0 && /* @__PURE__ */
|
|
7485
|
+
!isAtBottom && messages.length > 0 && /* @__PURE__ */ jsx32("div", { className: "sticky bottom-20 z-20 flex justify-center px-4 pointer-events-none", children: /* @__PURE__ */ jsx32(
|
|
5828
7486
|
Button,
|
|
5829
7487
|
{
|
|
5830
7488
|
type: "button",
|
|
@@ -5837,10 +7495,10 @@ function Chat({
|
|
|
5837
7495
|
onClick: () => scrollToBottom(true, true),
|
|
5838
7496
|
"aria-label": t("chat.scrollToBottom"),
|
|
5839
7497
|
title: t("chat.scrollToBottom"),
|
|
5840
|
-
children: /* @__PURE__ */
|
|
7498
|
+
children: /* @__PURE__ */ jsx32(ArrowDown2, { size: 16 })
|
|
5841
7499
|
}
|
|
5842
7500
|
) }),
|
|
5843
|
-
quoteSelection && /* @__PURE__ */
|
|
7501
|
+
quoteSelection && /* @__PURE__ */ jsx32(
|
|
5844
7502
|
"div",
|
|
5845
7503
|
{
|
|
5846
7504
|
className: "pointer-events-none fixed z-50",
|
|
@@ -5849,7 +7507,7 @@ function Chat({
|
|
|
5849
7507
|
left: `${quoteSelection.left}px`,
|
|
5850
7508
|
transform: "translateX(-50%)"
|
|
5851
7509
|
},
|
|
5852
|
-
children: /* @__PURE__ */
|
|
7510
|
+
children: /* @__PURE__ */ jsxs21(
|
|
5853
7511
|
Button,
|
|
5854
7512
|
{
|
|
5855
7513
|
type: "button",
|
|
@@ -5861,16 +7519,16 @@ function Chat({
|
|
|
5861
7519
|
"aria-label": t("composer.quoteSelection"),
|
|
5862
7520
|
title: t("composer.quoteSelection"),
|
|
5863
7521
|
children: [
|
|
5864
|
-
/* @__PURE__ */
|
|
7522
|
+
/* @__PURE__ */ jsx32(Quote, { size: 14 }),
|
|
5865
7523
|
t("composer.quoteSelection")
|
|
5866
7524
|
]
|
|
5867
7525
|
}
|
|
5868
7526
|
)
|
|
5869
7527
|
}
|
|
5870
7528
|
),
|
|
5871
|
-
/* @__PURE__ */
|
|
5872
|
-
threadErrorMessage && /* @__PURE__ */
|
|
5873
|
-
/* @__PURE__ */
|
|
7529
|
+
/* @__PURE__ */ jsxs21("div", { className: "p-2 sticky bottom-0 z-10 bg-background", children: [
|
|
7530
|
+
threadErrorMessage && /* @__PURE__ */ jsx32("div", { className: "mb-3 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive overflow-auto", children: threadErrorMessage }),
|
|
7531
|
+
/* @__PURE__ */ jsx32(
|
|
5874
7532
|
"input",
|
|
5875
7533
|
{
|
|
5876
7534
|
ref: fileInputRef,
|
|
@@ -5881,7 +7539,7 @@ function Chat({
|
|
|
5881
7539
|
className: "hidden"
|
|
5882
7540
|
}
|
|
5883
7541
|
),
|
|
5884
|
-
attachments.length > 0 && /* @__PURE__ */
|
|
7542
|
+
attachments.length > 0 && /* @__PURE__ */ jsx32("div", { className: "mb-3 flex flex-wrap gap-2", children: attachments.map((item) => /* @__PURE__ */ jsxs21(
|
|
5885
7543
|
"div",
|
|
5886
7544
|
{
|
|
5887
7545
|
className: cn(
|
|
@@ -5889,16 +7547,16 @@ function Chat({
|
|
|
5889
7547
|
item.status === "error" ? "bg-destructive/10 border border-destructive/30" : "bg-muted"
|
|
5890
7548
|
),
|
|
5891
7549
|
children: [
|
|
5892
|
-
item.status === "uploading" && /* @__PURE__ */
|
|
5893
|
-
|
|
7550
|
+
item.status === "uploading" && /* @__PURE__ */ jsx32(
|
|
7551
|
+
Loader24,
|
|
5894
7552
|
{
|
|
5895
7553
|
size: 14,
|
|
5896
7554
|
className: "animate-spin text-muted-foreground"
|
|
5897
7555
|
}
|
|
5898
7556
|
),
|
|
5899
|
-
item.status === "success" && /* @__PURE__ */
|
|
5900
|
-
item.status === "error" && /* @__PURE__ */
|
|
5901
|
-
/* @__PURE__ */
|
|
7557
|
+
item.status === "success" && /* @__PURE__ */ jsx32(FileText2, { size: 14, className: "text-muted-foreground" }),
|
|
7558
|
+
item.status === "error" && /* @__PURE__ */ jsx32(FileText2, { size: 14, className: "text-destructive" }),
|
|
7559
|
+
/* @__PURE__ */ jsx32(
|
|
5902
7560
|
"span",
|
|
5903
7561
|
{
|
|
5904
7562
|
className: cn(
|
|
@@ -5908,17 +7566,17 @@ function Chat({
|
|
|
5908
7566
|
children: item.file.name
|
|
5909
7567
|
}
|
|
5910
7568
|
),
|
|
5911
|
-
item.status === "error" && /* @__PURE__ */
|
|
7569
|
+
item.status === "error" && /* @__PURE__ */ jsx32(
|
|
5912
7570
|
"button",
|
|
5913
7571
|
{
|
|
5914
7572
|
type: "button",
|
|
5915
7573
|
onClick: () => handleRetryUpload(item.localId),
|
|
5916
7574
|
className: "ml-1 rounded-full p-0.5 text-destructive hover:bg-destructive/20",
|
|
5917
7575
|
title: t("chat.retryUpload"),
|
|
5918
|
-
children: /* @__PURE__ */
|
|
7576
|
+
children: /* @__PURE__ */ jsx32(RefreshCw2, { size: 12 })
|
|
5919
7577
|
}
|
|
5920
7578
|
),
|
|
5921
|
-
/* @__PURE__ */
|
|
7579
|
+
/* @__PURE__ */ jsx32(
|
|
5922
7580
|
"button",
|
|
5923
7581
|
{
|
|
5924
7582
|
type: "button",
|
|
@@ -5927,14 +7585,14 @@ function Chat({
|
|
|
5927
7585
|
"ml-1 rounded-full p-0.5",
|
|
5928
7586
|
item.status === "error" ? "text-destructive hover:bg-destructive/20" : "hover:bg-muted-foreground/20"
|
|
5929
7587
|
),
|
|
5930
|
-
children: /* @__PURE__ */
|
|
7588
|
+
children: /* @__PURE__ */ jsx32(X3, { size: 12 })
|
|
5931
7589
|
}
|
|
5932
7590
|
)
|
|
5933
7591
|
]
|
|
5934
7592
|
},
|
|
5935
7593
|
item.localId
|
|
5936
7594
|
)) }),
|
|
5937
|
-
references.length > 0 && /* @__PURE__ */
|
|
7595
|
+
references.length > 0 && /* @__PURE__ */ jsx32("div", { className: "mb-3 flex flex-wrap gap-2", children: references.map((reference) => /* @__PURE__ */ jsx32(
|
|
5938
7596
|
ReferenceChip,
|
|
5939
7597
|
{
|
|
5940
7598
|
reference,
|
|
@@ -5948,19 +7606,19 @@ function Chat({
|
|
|
5948
7606
|
},
|
|
5949
7607
|
getReferenceKey(reference)
|
|
5950
7608
|
)) }),
|
|
5951
|
-
selectedTool && /* @__PURE__ */
|
|
5952
|
-
/* @__PURE__ */
|
|
5953
|
-
/* @__PURE__ */
|
|
7609
|
+
selectedTool && /* @__PURE__ */ jsxs21("div", { className: "mb-2 flex items-center gap-2", children: [
|
|
7610
|
+
/* @__PURE__ */ jsx32("span", { className: "rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary", children: selectedTool.shortLabel ?? selectedTool.label }),
|
|
7611
|
+
/* @__PURE__ */ jsx32(
|
|
5954
7612
|
"button",
|
|
5955
7613
|
{
|
|
5956
7614
|
type: "button",
|
|
5957
7615
|
onClick: () => setSelectedTool(null),
|
|
5958
7616
|
className: "rounded-full p-0.5 text-muted-foreground hover:bg-muted",
|
|
5959
|
-
children: /* @__PURE__ */
|
|
7617
|
+
children: /* @__PURE__ */ jsx32(X3, { size: 12 })
|
|
5960
7618
|
}
|
|
5961
7619
|
)
|
|
5962
7620
|
] }),
|
|
5963
|
-
/* @__PURE__ */
|
|
7621
|
+
/* @__PURE__ */ jsx32(
|
|
5964
7622
|
PendingTodos,
|
|
5965
7623
|
{
|
|
5966
7624
|
snapshot: stream.todos,
|
|
@@ -5968,7 +7626,7 @@ function Chat({
|
|
|
5968
7626
|
className: hasPendingFollowUps ? "mb-2" : void 0
|
|
5969
7627
|
}
|
|
5970
7628
|
),
|
|
5971
|
-
/* @__PURE__ */
|
|
7629
|
+
/* @__PURE__ */ jsx32(
|
|
5972
7630
|
PendingFollowUps,
|
|
5973
7631
|
{
|
|
5974
7632
|
items: pendingFollowUps,
|
|
@@ -5983,7 +7641,16 @@ function Chat({
|
|
|
5983
7641
|
attachToComposer: true
|
|
5984
7642
|
}
|
|
5985
7643
|
),
|
|
5986
|
-
/* @__PURE__ */
|
|
7644
|
+
/* @__PURE__ */ jsx32(
|
|
7645
|
+
RequestUserInputPanel,
|
|
7646
|
+
{
|
|
7647
|
+
request: stream.pendingRequestUserInput,
|
|
7648
|
+
onSubmit: stream.submitRequestUserInput,
|
|
7649
|
+
onDismiss: stream.stop,
|
|
7650
|
+
attachToComposer: true
|
|
7651
|
+
}
|
|
7652
|
+
),
|
|
7653
|
+
/* @__PURE__ */ jsx32("form", { className: "flex items-end", onSubmit: handleSubmit, children: /* @__PURE__ */ jsxs21(
|
|
5987
7654
|
"div",
|
|
5988
7655
|
{
|
|
5989
7656
|
className: cn(
|
|
@@ -5995,17 +7662,19 @@ function Chat({
|
|
|
5995
7662
|
getRoundedClass(theme.radius)
|
|
5996
7663
|
),
|
|
5997
7664
|
children: [
|
|
5998
|
-
/* @__PURE__ */
|
|
7665
|
+
/* @__PURE__ */ jsx32(
|
|
5999
7666
|
ComposerMenu,
|
|
6000
7667
|
{
|
|
6001
7668
|
composer,
|
|
6002
7669
|
onAttachmentClick: handleAttachmentClick,
|
|
6003
7670
|
onToolSelect: handleToolSelect,
|
|
6004
7671
|
selectedTool,
|
|
6005
|
-
|
|
7672
|
+
planModeEnabled,
|
|
7673
|
+
onPlanModeChange: setPlanModeEnabled,
|
|
7674
|
+
disabled: missingConfig || isHistoryLoading || hasPendingRequestUserInput
|
|
6006
7675
|
}
|
|
6007
7676
|
),
|
|
6008
|
-
/* @__PURE__ */
|
|
7677
|
+
/* @__PURE__ */ jsx32(
|
|
6009
7678
|
"textarea",
|
|
6010
7679
|
{
|
|
6011
7680
|
ref: composerInputRef,
|
|
@@ -6015,7 +7684,7 @@ function Chat({
|
|
|
6015
7684
|
onKeyDown: handleComposerKeyDown,
|
|
6016
7685
|
rows: 1,
|
|
6017
7686
|
placeholder: inputPlaceholder,
|
|
6018
|
-
disabled: missingConfig || isHistoryLoading,
|
|
7687
|
+
disabled: missingConfig || isHistoryLoading || hasPendingRequestUserInput,
|
|
6019
7688
|
className: cn(
|
|
6020
7689
|
"min-h-8 max-h-32 flex-1 resize-none bg-transparent py-1 pr-2 text-sm leading-5 text-foreground outline-none",
|
|
6021
7690
|
"placeholder:text-muted-foreground",
|
|
@@ -6023,12 +7692,12 @@ function Chat({
|
|
|
6023
7692
|
)
|
|
6024
7693
|
}
|
|
6025
7694
|
),
|
|
6026
|
-
/* @__PURE__ */
|
|
7695
|
+
/* @__PURE__ */ jsx32(
|
|
6027
7696
|
SendButton,
|
|
6028
7697
|
{
|
|
6029
7698
|
disabled: isSendDisabled,
|
|
6030
7699
|
isLoading: stream.isLoading,
|
|
6031
|
-
showStop: stream.isLoading && !trimmedDraft,
|
|
7700
|
+
showStop: stream.isLoading && (!trimmedDraft || hasPendingRequestUserInput),
|
|
6032
7701
|
onStop: () => stream.stop(),
|
|
6033
7702
|
stopLabel: t("chat.stop"),
|
|
6034
7703
|
sendLabel: t("chat.send"),
|
|
@@ -6047,7 +7716,7 @@ function Chat({
|
|
|
6047
7716
|
]
|
|
6048
7717
|
}
|
|
6049
7718
|
) }),
|
|
6050
|
-
disclaimer?.text && /* @__PURE__ */
|
|
7719
|
+
disclaimer?.text && /* @__PURE__ */ jsx32(
|
|
6051
7720
|
"p",
|
|
6052
7721
|
{
|
|
6053
7722
|
className: cn(
|
|
@@ -6057,9 +7726,9 @@ function Chat({
|
|
|
6057
7726
|
children: disclaimer.text
|
|
6058
7727
|
}
|
|
6059
7728
|
),
|
|
6060
|
-
/* @__PURE__ */
|
|
6061
|
-
/* @__PURE__ */
|
|
6062
|
-
/* @__PURE__ */
|
|
7729
|
+
/* @__PURE__ */ jsxs21("div", { className: "mt-2 flex items-center justify-center gap-2 text-xs text-muted-foreground", children: [
|
|
7730
|
+
/* @__PURE__ */ jsx32("span", { children: t("chat.poweredBy") }),
|
|
7731
|
+
/* @__PURE__ */ jsx32(ContextUsageIndicator, { className: "absolute right-4" })
|
|
6063
7732
|
] })
|
|
6064
7733
|
] })
|
|
6065
7734
|
]
|
|
@@ -6068,11 +7737,11 @@ function Chat({
|
|
|
6068
7737
|
}
|
|
6069
7738
|
|
|
6070
7739
|
// src/components/ui/input.tsx
|
|
6071
|
-
import * as
|
|
6072
|
-
import { jsx as
|
|
6073
|
-
var Input =
|
|
7740
|
+
import * as React27 from "react";
|
|
7741
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
7742
|
+
var Input = React27.forwardRef(
|
|
6074
7743
|
({ className, type, ...props }, ref) => {
|
|
6075
|
-
return /* @__PURE__ */
|
|
7744
|
+
return /* @__PURE__ */ jsx33(
|
|
6076
7745
|
"input",
|
|
6077
7746
|
{
|
|
6078
7747
|
ref,
|
|
@@ -6089,10 +7758,10 @@ var Input = React24.forwardRef(
|
|
|
6089
7758
|
Input.displayName = "Input";
|
|
6090
7759
|
|
|
6091
7760
|
// src/components/ui/separator.tsx
|
|
6092
|
-
import * as
|
|
6093
|
-
import { jsx as
|
|
6094
|
-
var Separator =
|
|
6095
|
-
({ className, orientation = "horizontal", ...props }, ref) => /* @__PURE__ */
|
|
7761
|
+
import * as React28 from "react";
|
|
7762
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
7763
|
+
var Separator = React28.forwardRef(
|
|
7764
|
+
({ className, orientation = "horizontal", ...props }, ref) => /* @__PURE__ */ jsx34(
|
|
6096
7765
|
"div",
|
|
6097
7766
|
{
|
|
6098
7767
|
ref,
|