From 3a37269f3f4b1f81c316a341b9dd2c5040ecf033 Mon Sep 17 00:00:00 2001 From: chengyongru <61816729+chengyongru@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:41:12 +0800 Subject: [PATCH] refactor(webui): unify code and diff highlighting (#6412) * refactor(webui): unify code and diff highlighting Replace Prism with shared Highlights tokens and Pierre read-only diffs, retaining rare grammars through lazy Shiki and preserving source, copy, preview and diff controls. Restore single-session Composer ownership inside the conversation column while retaining the shared multi-pane footer. Keep the measured large-diff scroll regression explicit during review. * fix(webui): contain highlighting errors and retain diff selections Refs NAN-343 * test(webui): align pane fixtures after main rebase * chore(webui): update highlighting dependencies Keep grammar fallback coverage on a language that still requires Shiki, and align reading-size assertions with main. --- THIRD_PARTY_NOTICES.md | 613 ++++++++++++++++++ webui/browser/code-highlighting-fixture.tsx | 35 + webui/browser/code-highlighting.spec.ts | 127 ++++ webui/browser/code-wrapping.spec.ts | 4 +- webui/browser/file-diff-fixture.tsx | 53 ++ webui/browser/file-diff.spec.ts | 225 +++++++ webui/browser/fixture.tsx | 8 +- webui/browser/theme-toggle-fixture.tsx | 13 +- webui/browser/theme-toggle.spec.ts | 4 +- webui/browser/typography-fixture.tsx | 10 +- webui/bun.lock | 131 ++-- webui/package-lock.json | 511 ++++++++------- webui/package.json | 5 +- webui/src/components/CodeBlock.tsx | 142 ++-- webui/src/components/CodeTokens.tsx | 14 + webui/src/components/HighlightedCode.tsx | 33 + webui/src/components/ViewportCodeRows.tsx | 39 +- webui/src/components/WrappedCodeRows.tsx | 23 - .../src/components/thread/ThreadViewport.tsx | 4 + .../thread/activity/DiffSyntaxHighlight.tsx | 197 ++---- .../thread/activity/DiffViewportContext.ts | 6 + .../thread/activity/FileEditRow.tsx | 105 +-- .../thread/activity/PierreFileDiff.tsx | 159 +++++ .../thread/activity/diff-render-window.ts | 50 ++ .../thread/activity/diff-selection.ts | 40 ++ .../components/workbench/PaneWorkbench.tsx | 5 +- webui/src/globals.css | 59 +- webui/src/lib/code-highlight-cache.ts | 44 ++ webui/src/lib/code-highlighter-grammars.ts | 22 + webui/src/lib/code-highlighter.ts | 45 ++ webui/src/lib/code-theme.ts | 38 ++ webui/src/lib/code-tokens.ts | 19 + .../src/tests/agent-activity-cluster.test.tsx | 6 + webui/src/tests/app-layout.test.tsx | 12 + webui/src/tests/code-block.test.tsx | 59 +- webui/src/tests/code-highlighter.test.tsx | 58 ++ ...diff-syntax-highlight.integration.test.tsx | 161 ----- .../src/tests/diff-syntax-highlight.test.tsx | 153 ++--- webui/src/tests/pane-workbench.test.tsx | 24 +- webui/src/tests/thread-messages.test.tsx | 6 + webui/src/tests/viewport-code-rows.test.tsx | 9 +- webui/src/tests/vite-config.test.ts | 24 +- .../react-syntax-highlighter-subpaths.d.ts | 22 - webui/vite.config.ts | 16 +- 44 files changed, 2261 insertions(+), 1072 deletions(-) create mode 100644 webui/browser/code-highlighting-fixture.tsx create mode 100644 webui/browser/code-highlighting.spec.ts create mode 100644 webui/browser/file-diff-fixture.tsx create mode 100644 webui/browser/file-diff.spec.ts create mode 100644 webui/src/components/CodeTokens.tsx create mode 100644 webui/src/components/HighlightedCode.tsx delete mode 100644 webui/src/components/WrappedCodeRows.tsx create mode 100644 webui/src/components/thread/activity/DiffViewportContext.ts create mode 100644 webui/src/components/thread/activity/PierreFileDiff.tsx create mode 100644 webui/src/components/thread/activity/diff-render-window.ts create mode 100644 webui/src/components/thread/activity/diff-selection.ts create mode 100644 webui/src/lib/code-highlight-cache.ts create mode 100644 webui/src/lib/code-highlighter-grammars.ts create mode 100644 webui/src/lib/code-highlighter.ts create mode 100644 webui/src/lib/code-theme.ts create mode 100644 webui/src/lib/code-tokens.ts create mode 100644 webui/src/tests/code-highlighter.test.tsx delete mode 100644 webui/src/tests/diff-syntax-highlight.integration.test.tsx delete mode 100644 webui/src/types/react-syntax-highlighter-subpaths.d.ts diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index b547006aa..4a88141f8 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -239,3 +239,616 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` + +--- + +## Pierre Diffs and Highlights — code highlighting and read-only diffs (Apache-2.0 and MIT dependencies) + +- **Source**: https://github.com/pierrecomputer/pierre +- **Components**: `@pierre/diffs` 1.6.4, `@pierre/highlights` 0.4.0, `@pierre/theme` 2.0.0, and `@pierre/theming` 1.0.2; Shiki 4.6.0 and the dependencies identified below. +- **Bundled**: `nanobot/web/dist/assets/*.{js,wasm}` + +The following license texts and upstream notices are retained from the distributed packages. + +### `@pierre/diffs 1.6.4`, `@pierre/highlights 0.4.0`, `@pierre/theme 2.0.0`, `@pierre/theming 1.0.2` + +```text +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, and + distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by the + copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all other + entities that control, are controlled by, or are under common control with + that entity. For the purposes of this definition, "control" means (i) the + power, direct or indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (ii) ownership of fifty percent + (50%) or more of the outstanding shares, or (iii) beneficial ownership of + such entity. + + "You" (or "Your") shall mean an individual or Legal Entity exercising + permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation source, and + configuration files. + + "Object" form shall mean any form resulting from mechanical transformation + or translation of a Source form, including but not limited to compiled + object code, generated documentation, and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or Object form, + made available under the License, as indicated by a copyright notice that is + included in or attached to the work (an example is provided in the Appendix + below). + + "Derivative Works" shall mean any work, whether in Source or Object form, + that is based on (or derived from) the Work and for which the editorial + revisions, annotations, elaborations, or other modifications represent, as a + whole, an original work of authorship. For the purposes of this License, + Derivative Works shall not include works that remain separable from, or + merely link (or bind by name) to the interfaces of, the Work and Derivative + Works thereof. + + "Contribution" shall mean any work of authorship, including the original + version of the Work and any modifications or additions to that Work or + Derivative Works thereof, that is intentionally submitted to Licensor for + inclusion in the Work by the copyright owner or by an individual or Legal + Entity authorized to submit on behalf of the copyright owner. For the + purposes of this definition, "submitted" means any form of electronic, + verbal, or written communication sent to the Licensor or its + representatives, including but not limited to communication on electronic + mailing lists, source code control systems, and issue tracking systems that + are managed by, or on behalf of, the Licensor for the purpose of discussing + and improving the Work, but excluding communication that is conspicuously + marked or otherwise designated in writing by the copyright owner as "Not a + Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity on + behalf of whom a Contribution has been received by Licensor and subsequently + incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this + License, each Contributor hereby grants to You a perpetual, worldwide, + non-exclusive, no-charge, royalty-free, irrevocable copyright license to + reproduce, prepare Derivative Works of, publicly display, publicly perform, + sublicense, and distribute the Work and such Derivative Works in Source or + Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this + License, each Contributor hereby grants to You a perpetual, worldwide, + non-exclusive, no-charge, royalty-free, irrevocable (except as stated in + this section) patent license to make, have made, use, offer to sell, sell, + import, and otherwise transfer the Work, where such license applies only to + those patent claims licensable by such Contributor that are necessarily + infringed by their Contribution(s) alone or by combination of their + Contribution(s) with the Work to which such Contribution(s) was submitted. + If You institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work or a + Contribution incorporated within the Work constitutes direct or contributory + patent infringement, then any patent licenses granted to You under this + License for that Work shall terminate as of the date such litigation is + filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or + Derivative Works thereof in any medium, with or without modifications, and + in Source or Object form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a + copy of this License; and + + (b) You must cause any modified files to carry prominent notices stating + that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You + distribute, all copyright, patent, trademark, and attribution notices from + the Source form of the Work, excluding those notices that do not pertain to + any part of the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable copy + of the attribution notices contained within such NOTICE file, excluding + those notices that do not pertain to any part of the Derivative Works, in at + least one of the following places: within a NOTICE text file distributed as + part of the Derivative Works; within the Source form or documentation, if + provided along with the Derivative Works; or, within a display generated by + the Derivative Works, if and wherever such third-party notices normally + appear. The contents of the NOTICE file are for informational purposes only + and do not modify the License. You may add Your own attribution notices + within Derivative Works that You distribute, alongside or as an addendum to + the NOTICE text from the Work, provided that such additional attribution + notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may + provide additional or different license terms and conditions for use, + reproduction, or distribution of Your modifications, or for any such + Derivative Works as a whole, provided Your use, reproduction, and + distribution of the Work otherwise complies with the conditions stated in + this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any + Contribution intentionally submitted for inclusion in the Work by You to the + Licensor shall be under the terms and conditions of this License, without + any additional terms or conditions. Notwithstanding the above, nothing + herein shall supersede or modify the terms of any separate license agreement + you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, + trademarks, service marks, or product names of the Licensor, except as + required for reasonable and customary use in describing the origin of the + Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in + writing, Licensor provides the Work (and each Contributor provides its + Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied, including, without limitation, any + warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or + FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining + the appropriateness of using or redistributing the Work and assume any risks + associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in + tort (including negligence), contract, or otherwise, unless required by + applicable law (such as deliberate and grossly negligent acts) or agreed to + in writing, shall any Contributor be liable to You for damages, including + any direct, indirect, special, incidental, or consequential damages of any + character arising as a result of this License or out of the use or inability + to use the Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all other + commercial damages or losses), even if such Contributor has been advised of + the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or + Derivative Works thereof, You may choose to offer, and charge a fee for, + acceptance of support, warranty, indemnity, or other liability obligations + and/or rights consistent with this License. However, in accepting such + obligations, You may act only on Your own behalf and on Your sole + responsibility, not on behalf of any other Contributor, and only if You + agree to indemnify, defend, and hold each Contributor harmless for any + liability incurred by, or claims asserted against, such Contributor by + reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright 2025 Pierre Computer Company + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. +``` + +### `@shikijs/core 4.6.0`, `@shikijs/engine-javascript 4.6.0`, `@shikijs/engine-oniguruma 4.6.0`, `@shikijs/langs 4.6.0`, `@shikijs/primitive 4.6.0`, `@shikijs/themes 4.6.0`, `@shikijs/types 4.6.0`, `shiki 4.6.0` + +```text +MIT License + +Copyright (c) 2021 Pine Wu +Copyright (c) 2023 Anthony Fu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +### `@shikijs/vscode-textmate 10.1.0` + +```text +The MIT License (MIT) + +Copyright (c) Microsoft Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +### `hast-util-to-html 9.0.5` and `9.0.6` + +```text +(The MIT License) + +Copyright (c) Titus Wormer + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +``` + +### `lru_map 0.4.1` + +```text +MIT license + +Copyright (c) 2010-2016 Rasmus Andersson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +``` + +### `oniguruma-parser 0.12.2` + +```text +MIT License + +Copyright (c) 2025-2026 Steven Levithan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +### `oniguruma-to-es 4.3.6` + +```text +MIT License + +Copyright (c) 2024-2026 Steven Levithan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +### `regex 6.1.0`, `regex-recursion 6.0.2` + +```text +MIT License + +Copyright (c) 2025 Steven Levithan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +### `regex-utilities 2.3.0` + +```text +MIT License + +Copyright (c) 2024 Steven Levithan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +### Upstream NOTICE: `@pierre/highlights` + +````text +# Bundled theme licenses + +Community themes are pruned copies of pinned Zed theme files or conversions of +the pinned Shiki TextMate files listed below. Theme names and appearances are +normalized to Shiki's catalog. + +## Sources + +Terminal palettes use the same pinned sources as the themes below. Exceptions: + +- Horizon's original repository is unavailable. Its palette comes from the + [Zed Horizon 0.0.1 archive](https://api.zed.dev/extensions/horizon/0.0.1/download). +- Andromeeda's two null black entries and both Horizon themes' four null black + and white entries use their inherited + [Zed defaults at `ce48461`](https://github.com/zed-industries/zed/blob/ce48461eaadd16c65c31f835511ab96bd3b6e746/crates/theme/src/default_colors.rs). +- LaserWave leaves ten terminal colors undefined; Slack Dark leaves all 16 + undefined. These entries use the dark palette in + [VS Code at `3623f17`](https://github.com/microsoft/vscode/blob/3623f170559712f7ee16f59dfbd87c885b6a2b31/src/vs/workbench/contrib/terminal/common/terminalColorRegistry.ts). +- Pierre's palettes come from + [its Zed theme](https://github.com/pierrecomputer/pierre/blob/861ce3c61e1cfeaf283d83e95a3767479e75bfee/packages/theme/zed/themes/pierre.json). + The vibrant variants preserve the Display P3 values in + [Pierre Dark Vibrant](https://github.com/pierrecomputer/pierre/blob/861ce3c61e1cfeaf283d83e95a3767479e75bfee/packages/theme/themes/pierre-dark-vibrant.json) + and + [Pierre Light Vibrant](https://github.com/pierrecomputer/pierre/blob/861ce3c61e1cfeaf283d83e95a3767479e75bfee/packages/theme/themes/pierre-light-vibrant.json). + +Dracula's `ffffffff` bright white value is normalized to `#ffffffff`. + +The Zed version is the extension version published in the +[Zed registry](https://github.com/zed-industries/extensions) at +`ab756766c27fca3de3d275149f6937105f464dec`. "Built in" means the theme ships +with Zed itself. GitHub-only sources have no marketplace version. + +| Highlights themes | Pinned source | Zed version | +| -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | +| `andromeeda` | [ChocolateNao/andromeda-zed `23f6768`](https://github.com/ChocolateNao/andromeda-zed/blob/23f67684252059f46b508ae71964ad6085df552a/themes/andromeda.json) | `andromeda` 0.1.2 | +| `aurora-x` | [iamrajjoshi/aurora `83477d4`](https://github.com/iamrajjoshi/aurora/blob/83477d4b4abc4aeca9465d9b1b56409e2cd6da97/themes/aurora.json) | `aurora-theme` 0.0.1 | +| `ayu-dark`, `ayu-light`, `ayu-mirage` | [Zed Ayu `ce48461`](https://github.com/zed-industries/zed/blob/ce48461eaadd16c65c31f835511ab96bd3b6e746/assets/themes/ayu/ayu.json) | Built in | +| `catppuccin-*` | [catppuccin/zed `b54cb81`](https://github.com/catppuccin/zed/blob/b54cb81708d06912d50e6bb9fd2fd2103b9dda25/themes/catppuccin-mauve.json) | `catppuccin` 0.2.25 | +| `dark-plus`, `light-plus`, `monokai`, `red`, `solarized-*` | [alanisme/vscode-themes-for-zed `ea65e4d`](https://github.com/alanisme/vscode-themes-for-zed/tree/ea65e4df055035888b6bd0b0c68c6986c3ce4699/themes) | `vscode-classic-themes` 0.4.1 | +| `dracula` | [dracula/zed `92f4605`](https://github.com/dracula/zed/blob/92f46057151693648bd3acac1e0c138696f34433/themes/dracula.json) | `dracula` 1.1.2 | +| `everforest-dark`, `everforest-light` | [albertsko/zed-everforest `1f1c84e`](https://github.com/albertsko/zed-everforest/blob/1f1c84e081f6dcaaac7105812032086608ca7a44/themes/everforest-regular.json) | `everforest` 0.2.0 | +| `github-dark`, `github-light` | [meocoder31099/Github-Classic-Theme-Zed `751146a`](https://github.com/meocoder31099/Github-Classic-Theme-Zed/blob/751146a4387066dd4e2fb7ee4ff91ab089d7c7dd/themes/github-classic.json) | `github-classic` 0.0.3 | +| `github-dark-default` | [MordFustang21/zed-github-dark `dbbd661`](https://github.com/MordFustang21/zed-github-dark/blob/dbbd66167753686ff3ff627208e15f7e27a9b1f9/themes/dark-default.json) | `github-dark-default` 1.0.10 | +| `github-dark-dimmed`, `github-light-default`, and both `github-*-high-contrast` themes | [PyaeSoneAungRgn/github-zed-theme `89ae5f9`](https://github.com/PyaeSoneAungRgn/github-zed-theme/blob/89ae5f92ca0bc5b96b721b69e41db83aa482cfd6/themes/github_theme.json) | `github-theme` 0.1.8 | +| `gruvbox-*` | [Zed Gruvbox `ce48461`](https://github.com/zed-industries/zed/blob/ce48461eaadd16c65c31f835511ab96bd3b6e746/assets/themes/gruvbox/gruvbox.json) | Built in | +| `horizon`, `horizon-bright` | [ayn2op/zed-horizon `b3cf502`](https://github.com/ayn2op/zed-horizon/blob/b3cf5022a583455f2e815c4c58996ce6dc3082f5/themes/horizon.json) | `horizon` 0.0.1 | +| `houston` | [rudolfjs/houston-zed `2830d5c`](https://github.com/rudolfjs/houston-zed/blob/2830d5c55d80b2c2bce44b184f2370f814509f1f/themes/houston.json) | GitHub only; manifest 0.2.0 | +| `kanagawa-*` | [ethangilmore/zed-kanagawa `45b4295`](https://github.com/ethangilmore/zed-kanagawa/blob/45b4295e708a5720d75514013a20a00917d50cc5/themes/Kanagawa.json) | `kanagawa-themes` 0.1.2 | +| `material-theme*` | [Codextor/zed-material-theme `e4145b6`](https://github.com/Codextor/zed-material-theme/blob/e4145b69351b773ba8c9c8b0c44e7d89faacbfee/themes/material-theme.json) | `material-theme` 0.0.1 | +| `min-dark`, `min-light` | [phibr0/zed-min-theme `0efe9ac`](https://github.com/phibr0/zed-min-theme/blob/0efe9ac439bd27ceb19d6506ed4986d9f348e216/themes/min-theme.json) | `min-theme` 0.2.2 | +| `night-owl`, `night-owl-light` | [elGusto/night-owlz `29b5fed`](https://github.com/elGusto/night-owlz/blob/29b5fedfee923b2598d97520962215d26d51d67d/themes/NightOwl.json) | `night-owlz` 0.0.5 | +| `nord` | [mikasius/zed-nord-theme `d0b459c`](https://github.com/mikasius/zed-nord-theme/blob/d0b459c49797aec598622bed992537e4a83688da/themes/nord.json) | `nord` 0.1.7 | +| `one-dark-pro` | [hadez8877/one-dark-pro-enhanced `0411a00`](https://github.com/hadez8877/one-dark-pro-enhanced/blob/0411a00f702b609746a29c49e2796d6993e9f461/themes/oneDark-Pro.json) | `one-dark-pro-enhanced` 0.0.12 | +| `one-light` | [Stelath/zed-atom-one-theme `ed0513f`](https://github.com/Stelath/zed-atom-one-theme/blob/ed0513f0655ec72ffcfd33e87e31fb0a06c28948/themes/one-light.json) | `atom-one-theme` 0.1.0 | +| `plastic` | [ibnuh/zed-plastic-theme `98c34dc`](https://github.com/ibnuh/zed-plastic-theme/blob/98c34dc4b59c65d64a9410aa25e4f66be0918cf8/themes/plastic.json) | `plastic-theme` 1.0.0 | +| `rose-pine*` | [rose-pine/zed `2c7b4ee`](https://github.com/rose-pine/zed/tree/2c7b4ee61c78334f8f1e9960d1d9e44d447ee9ef/themes) | `rose-pine-theme` 1.5.0 | +| `snazzy-light` | [seyhajin/zed-snazzy-light `1d54608`](https://github.com/seyhajin/zed-snazzy-light/blob/1d54608af795053e47d4151612c56b49aff6ed9b/themes/snazzy-light.json) | `snazzy-light` 0.1.0 | +| `synthwave-84` | [hydepwns/synthwave84-zed `332a002`](https://github.com/hydepwns/synthwave84-zed/blob/332a002eb64bece661585607fd59d3f9b4250acf/themes/synthwave84.json) | `synthwave84` 0.2.0 | +| `tokyo-night` | [ssaunderss/zed-tokyo-night `6d731d0`](https://github.com/ssaunderss/zed-tokyo-night/blob/6d731d0724a6fa487f9031cbb4f8db0b80769568/themes/tokyo-night.json) | `tokyo-night` 0.8.0 | +| `vesper` | [bdsqqq/vesper-zed `4ae700c`](https://github.com/bdsqqq/vesper-zed/blob/4ae700c4a2a279c722bdd6c63409a701b4a3236e/themes/vesper-dark.json) | `vesper` 0.0.2 | +| `vitesse-black`, `vitesse-dark`, `vitesse-light` | [colinlienard/zed-vitesse-theme-refined `a2b193e`](https://github.com/colinlienard/zed-vitesse-theme-refined/blob/a2b193ec9e5d36a05de4385b127c94597b025b46/themes/vitesse-theme-refined.json) | `vitesse-theme-refined` 0.5.0 | + +No suitable licensed Zed port was available for `dracula-soft`, `laserwave`, +`poimandres`, `slack-dark`, or `slack-ochin`. Those files use the corresponding +sources from +[`tm-themes@1.12.10`](https://github.com/shikijs/textmate-grammars-themes/blob/950dad95387e73a8b2ae36aed2ef19b8a4419f10/packages/tm-themes/index.js), +converted with +[Zed's scope mapping](https://github.com/zed-industries/zed/blob/ce48461eaadd16c65c31f835511ab96bd3b6e746/crates/theme_importer/src/vscode/syntax.rs). + +Missing syntax captures in the other community ports are supplemented from their +corresponding TextMate themes at the same `tm-themes@1.12.10` pin. Existing Zed +palette choices are retained. Pierre and the Aurora substitute use colors from +their own palettes for missing captures. + +The Zed registry's `aurora-theme` is an MIT-licensed substitute, not an Aurora X +port. The original Aurora X source is GPL-3.0-only; bundling it would require +GPL-3.0 distribution terms, contrary to this package's Apache-2.0-only policy. + +## MIT themes + +Copyright notices retained from the sources: + +- Andromeda: Copyright (c) 2017 ; Zed port Copyright (c) + 2025 Andrey L. +- Aurora: Copyright (c) 2026 Raj Joshi +- Ayu: Copyright (c) 2016 Ike Ku +- Catppuccin: Copyright (c) 2021 Catppuccin +- Dracula: Copyright (c) 2016 Dracula Theme; Zed port Copyright (c) 2023 Dracula + Theme +- Everforest: Copyright (c) 2020 sainnhe; Zed port Copyright (c) 2025 Albert + Skonieczny +- GitHub Classic: Copyright (c) 2020 Primer; Zed port Copyright (c) 2021 + Catppuccin +- GitHub Theme: Copyright (c) 2020 Primer; Zed port Copyright (c) 2025 Pyae Sone + Aung +- Gruvbox: the original palette is by Pavel Pertsev. Zed's theme-local MIT + license contains the unfilled line `Copyright (c) ` +- Horizon: Copyright (c) 2018 Jonathan Olaleye; Zed port Copyright (c) 2024 + Ayyan +- Houston: Copyright (c) 2022 The Astro Technology Company; Copyright (c) 2026 + github.com/rudolfjs +- Kanagawa: Copyright (c) 2021 Tommaso Laurenzi; Zed port Copyright (c) 2024 + Ethan Gilmore +- LaserWave: Copyright (c) 2019 Jared Jones +- Min: Copyright (c) 2018-2021 Miguel Solorio; Zed port Copyright (c) 2024 + Phillip +- Night Owl: Copyright (c) 2018 Sarah Drasner +- Nord: Copyright (c) 2016-present Sven Greb + (https://www.svengreb.de); Zed port Copyright (c) 2025 Sergei Metlenkin +- One Dark Pro: Copyright (c) 2013-2022 Binaryify; Zed port Copyright (c) 2025 + /devs/hadez +- One Light: Copyright (c) 2015 Mahmoud Ali; Zed port Copyright (c) 2026 Alex +- Plastic: Copyright (c) 2017-present, Will Stone; Zed port Copyright (c) 2026 + Ibnuh +- Poimandres: Copyright (c) 2023 drcmda +- Rosé Pine: Copyright (c) Rosé Pine +- Slack: Copyright (c) 2017 Felipe Mendes +- Snazzy Light: Copyright (c) 2020 Florian Reuschel; Zed port Copyright (c) 2026 + Christophe TES +- Synthwave84: Copyright (c) 2019 Robb Owen; Zed port Copyright (c) 2025 DROO +- TextMate theme collection: Copyright (c) 2021 Pine Wu; Copyright (c) 2023 + Anthony Fu +- Tokyo Night: Copyright (c) 2018-present Enkia; Zed port Copyright (c) 2024 + Austin Saunders +- Vesper: Copyright (c) 2023 Rauno Freiberg; Zed port Copyright (c) 2024 Igor + Bedesqui +- Vitesse: Copyright (c) 2020 Primer; Copyright (c) 2021 Anthony Fu; Zed port + Copyright (c) 2024 Colin Lienard +- VS Code Classics: Copyright (c) 2015 - present Microsoft Corporation; Zed port + Copyright (c) 2026 alanisme + +```text +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +``` + +## Apache-2.0 themes + +`github-dark-default` and the Material themes are Apache-2.0. The Material +themes retain Copyright 2017 Mattia Astorino. `github-dark-default` also derives +from the MIT-licensed GitHub/Primer theme credited above. Highlights extracts +individual themes and prunes unused Zed style properties. The full Apache-2.0 +text is included in the package's [`LICENSE.md`](./LICENSE.md). +```` + +### Upstream NOTICE: `@pierre/theme` + +```text +This theme was built on top of +[GitHub's Visual Studio Code Theme](https://github.com/primer/github-vscode-theme), +reusing its technique and build tooling, which we have since iterated on for +more specific language tokens. + +`@pierre/theme` is licensed under Apache-2.0 (see `LICENSE`). The original MIT +license for `primer/github-vscode-theme` is included below for attribution. + +Original license for `primer/github-vscode-theme`: + +``` +MIT License + +Copyright (c) 2020 Primer + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +``` +``` diff --git a/webui/browser/code-highlighting-fixture.tsx b/webui/browser/code-highlighting-fixture.tsx new file mode 100644 index 000000000..b97dc6cf3 --- /dev/null +++ b/webui/browser/code-highlighting-fixture.tsx @@ -0,0 +1,35 @@ +import { useState } from "react"; + +import { CodeBlock } from "@/components/CodeBlock"; +import { MarkdownText } from "@/components/MarkdownText"; +import { ThemeProvider, useTheme } from "@/hooks/useTheme"; + +const preview = "\n" + Array.from({ length: 520 }, (_, index) => `

Line ${index} 😀 ${"wide-source ".repeat(12)}

`).join("\n"); +const source = 'export const result = 中文 😀;\n'; +const markdown = `Before code.\n\n\`\`\`tsx\n${source}\`\`\`\n\nAfter code.`; + +export function CodeHighlightingFixture() { + const { theme, toggle } = useTheme(); + const [streaming, setStreaming] = useState(false); + const [changed, setChanged] = useState(false); + const [wrap, setWrap] = useState(false); + const [showLarge, setShowLarge] = useState(false); + return
+ + + + + + + {showLarge ?
`const value${index} = ${index};`).join("\n")} showLineNumbers />
: null} +
{streaming ? markdown.slice(0, markdown.indexOf("中文")) : markdown}
+
+
+
+
alert("not executable")'} />
+
'} />
+
+ +
+
; +} diff --git a/webui/browser/code-highlighting.spec.ts b/webui/browser/code-highlighting.spec.ts new file mode 100644 index 000000000..77cf5f9a7 --- /dev/null +++ b/webui/browser/code-highlighting.spec.ts @@ -0,0 +1,127 @@ +import { expect, test } from "@playwright/test"; + +const sourceText = (section: import("@playwright/test").Locator) => section.locator("[data-code-text], [data-highlighted]").allTextContents().then(lines => lines.join("")); + +for (const dark of [false, true]) { + for (const narrow of [false, true]) { + test(`shared highlighting retains code and preview behavior: ${dark ? "dark" : "light"}, ${narrow ? "narrow" : "desktop"}`, async ({ page }) => { + const errors: string[] = []; + page.on("pageerror", error => errors.push(error.message)); + await page.setViewportSize({ width: narrow ? 390 : 1280, height: 900 }); + await page.addInitScript(theme => { + localStorage.setItem("nanobot.locale", "en"); + localStorage.setItem("nanobot-webui.theme", theme); + }, dark ? "dark" : "light"); + await page.goto("/browser/fixture.html?case=code-highlighting"); + const code = page.getByRole("region", { name: "TypeScript", exact: true }); + await expect(code.getByTestId("highlighted-code")).toBeVisible(); + const expected = 'export const result = 中文 😀;\n'; + expect(await sourceText(code)).toBe(expected); + for (const variable of ["keyword", "string", "property"]) { + await expect.poll(async () => code.locator("[data-code-token]").evaluateAll((nodes, category) => { + const probe = document.createElement("span"); + probe.style.color = `var(--code-${category})`; + document.body.append(probe); + const color = getComputedStyle(probe).color; + probe.remove(); + return nodes.some(node => getComputedStyle(node).color === color); + }, variable)).toBe(true); + } + const ini = page.getByRole("region", { name: "INI", exact: true }); + await expect(ini.getByTestId("highlighted-code")).toContainText("host=localhost"); + await expect(ini.locator('[data-code-token][style*="--code-comment"]')).toHaveText("; comment"); + expect(await sourceText(ini)).toBe("; comment\n[server]\nhost=localhost\n"); + const hjson = page.getByRole("region", { name: "HJSON", exact: true }); + await expect(hjson.getByTestId("highlighted-code")).toContainText("host: localhost"); + expect(await sourceText(hjson)).toBe("# comment\n{ host: localhost }\n"); + await expect(page.getByRole("region", { name: "Unknown", exact: true }).getByTestId("highlighted-code")).toHaveText(''); + await expect(page.getByRole("region", { name: "ANSI", exact: true }).getByTestId("ansi-code")).toHaveText('PASS '); + expect(await page.locator("main script, main img").count()).toBe(0); + for (const size of ["small", "standard", "large"]) { + await page.evaluate(size => { document.documentElement.dataset.readingTextSize = size; }, size); + const expectedBody = size === "small" ? 15 : size === "large" ? 18 : 16; + await expect(code.getByTestId("highlighted-code")).toHaveCSS("font-size", `${expectedBody * 0.875}px`); + expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true); + } + await page.getByRole("button", { name: "Toggle theme", exact: true }).click(); + await expect(page.locator("html")).toHaveClass(dark ? "" : "dark"); + expect(await sourceText(code)).toBe(expected); + await page.getByRole("button", { name: "Change source", exact: true }).click(); + await expect(code.locator("[data-code-text]").first()).toHaveText(expected.replace("result", "updated").trimEnd()); + const markdown = page.getByRole("region", { name: "Markdown", exact: true }); + await page.getByRole("button", { name: "Start streaming", exact: true }).click(); + await expect(markdown.getByTestId("plain-code-fallback")).toContainText("export const result"); + await page.getByRole("button", { name: "Finish streaming", exact: true }).click(); + await expect(markdown.getByTestId("highlighted-code")).toContainText("中文 😀"); + const preview = page.getByRole("region", { name: "File preview", exact: true }); + await expect(preview.getByTestId("viewport-code-rows")).toBeVisible(); + const original = await sourceText(preview); + expect(original).toContain("Line 519 😀"); + expect(await page.evaluate(() => "find" in window && typeof window.find === "function" && window.find("Line 519 😀"))).toBe(true); + await page.evaluate(() => { document.getSelection()?.removeAllRanges(); document.dispatchEvent(new Event("selectionchange")); }); + const scroller = preview.locator("[data-file-preview-scroll]"); + await scroller.scrollIntoViewIfNeeded(); + await scroller.evaluate(node => { node.scrollTop = node.scrollHeight; node.scrollLeft = 120; }); + await expect(preview.locator('[data-code-chunk="15"] [data-highlighted]')).toHaveAttribute("data-highlighted", "true"); + expect(await sourceText(preview)).toBe(original); + expect(await scroller.evaluate(node => node.scrollLeft)).toBeGreaterThan(0); + const line = preview.locator('[data-highlighted="true"]').last(); + await line.evaluate(node => { + const range = document.createRange(); range.selectNodeContents(node); + const selection = document.getSelection()!; selection.removeAllRanges(); selection.addRange(range); + }); + const selected = await page.evaluate(() => document.getSelection()?.toString()); + await scroller.evaluate(node => { node.scrollTop = 0; }); + await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))); + expect(await page.evaluate(() => document.getSelection()?.toString())).toBe(selected); + await page.evaluate(() => { document.getSelection()?.removeAllRanges(); document.dispatchEvent(new Event("selectionchange")); }); + await expect(preview.locator('[data-code-chunk="0"] [data-highlighted]')).toHaveAttribute("data-highlighted", "true"); + const beforeWidth = await scroller.evaluate(node => node.scrollWidth); + await page.getByRole("button", { name: "Toggle wrapping", exact: true }).click(); + await expect(preview.getByTestId("highlighted-code")).toHaveCSS("white-space", "pre-wrap"); + expect(await scroller.evaluate(node => node.scrollWidth)).toBeLessThan(beforeWidth); + expect(errors).toEqual([]); + }); + } +} + +test("large numbered code remains complete and copies original source", async ({ page, context }) => { + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en")); + await page.goto("/browser/fixture.html?case=code-highlighting"); + await page.getByRole("button", { name: "Show large code", exact: true }).click(); + const section = page.getByRole("region", { name: "Large code", exact: true }); + await expect(section.getByTestId("highlighted-code")).toBeAttached(); + const expected = Array.from({ length: 1200 }, (_, index) => `const value${index} = ${index};`).join("\n"); + expect(await sourceText(section)).toBe(expected); + await expect(section.getByTestId("highlighted-code").locator("span[aria-hidden]").last()).toHaveText("1200"); + await section.getByRole("button", { name: "Copy code", exact: true }).click(); + const clipboardText = process.platform === "win32" ? expected.replace(/\n/g, "\r\n") : expected; + await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe(clipboardText); +}); + + +test("a real grammar request failure keeps complete source, controls and the application", async ({ page, context }) => { + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en")); + const failed: string[] = []; + const warning = page.waitForEvent("console", message => message.type() === "warning" && message.text().startsWith("Code highlighting failed.")); + await page.route(/\/hjson-[^/]*\.js(?:\?|$)/, async route => { + failed.push(route.request().url()); + await route.abort("failed"); + }); + await page.goto("/browser/fixture.html?case=code-highlighting"); + await warning; + expect(failed).toHaveLength(1); + const hjson = page.getByRole("region", { name: "HJSON", exact: true }); + const source = "# comment\n{ host: localhost }\n"; + await expect(hjson.getByTestId("plain-code-fallback")).toHaveText(source); + expect(await hjson.getByTestId("plain-code-fallback").textContent()).toBe(source); + await hjson.getByRole("button", { name: "Copy code", exact: true }).click(); + await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())) + .toBe(process.platform === "win32" ? source.replace(/\n/g, "\r\n") : source); + await page.getByRole("button", { name: "Change source", exact: true }).click(); + await expect(page.getByRole("region", { name: "TypeScript", exact: true }).getByTestId("highlighted-code")).toContainText("export const updated"); + await page.getByRole("button", { name: "Toggle theme", exact: true }).click(); + expect(await hjson.getByTestId("plain-code-fallback").textContent()).toBe(source); +}); diff --git a/webui/browser/code-wrapping.spec.ts b/webui/browser/code-wrapping.spec.ts index 6be56d66d..c2484e5ba 100644 --- a/webui/browser/code-wrapping.spec.ts +++ b/webui/browser/code-wrapping.spec.ts @@ -10,8 +10,8 @@ test("numbered Markdown code keeps mixed text flowing after stream completion", await expect(block.getByTestId("plain-code-fallback")).toBeVisible(); await page.getByRole("button", { name: "Complete message" }).click(); const pre = block.locator("pre"); - await expect(pre.locator(".token").first()).toBeVisible(); - await expect(pre.locator(".linenumber")).toHaveText(source.split("\n").map((_, index) => String(index + 1))); + await expect(pre.locator("[data-code-token]").first()).toBeVisible(); + await expect(pre.locator("code > span > span[aria-hidden]")).toHaveText(source.split("\n").map((_, index) => String(index + 1))); for (const width of [1280, 390]) { await page.setViewportSize({ width, height: 900 }); diff --git a/webui/browser/file-diff-fixture.tsx b/webui/browser/file-diff-fixture.tsx new file mode 100644 index 000000000..1ec9edd6f --- /dev/null +++ b/webui/browser/file-diff-fixture.tsx @@ -0,0 +1,53 @@ +import { useMemo, useRef, useState } from "react"; +import { DiffViewportContext } from "@/components/thread/activity/DiffViewportContext"; +import { FileEditGroup, type FileEditSummary } from "@/components/thread/activity/FileEditRow"; +import { ThemeProvider, useTheme } from "@/hooks/useTheme"; +import { setAppLanguage } from "@/i18n"; + +const patch = (name: string, lines: string[], oldCount: number, newCount: number) => + [`--- a/${name}`, `+++ b/${name}`, `@@ -${oldCount ? 1 : 0},${oldCount} +1,${newCount} @@`, ...lines, ""].join("\n"); +const markdown = ["## 发布安排", "", "| 日期 | 角色 | 方向 |", "| --- | --- | --- |", "| 7/22 | trust / core | data-driven |"]; +const longLines = Array.from({ length: 600 }, (_, index) => `export const item${index + 1} = "第 ${index + 1} 行 — readable code";`); +const samples: Array<[string, string]> = [ + ["Status.tsx", patch("Status.tsx", [ + ' import { useMemo } from "react";', " export function StatusBadge() {", + '- return old;', '+ return ready;', " }", + ], 4, 4)], + ["table.md", patch("table.md", markdown.map(line => `+${line}`), 0, markdown.length)], + ["callbacks.tsx", patch("callbacks.tsx", ['+ save(new Event("ok"))}>ready'], 0, 1)], + ["page.html", patch("page.html", ['+'], 0, 1)], + ["config.ini", patch("config.ini", [" ; comment", " [server]", "-host=old-server", "+host=localhost"], 3, 3)], + ["bun.lock", patch("bun.lock", ["+unknown-language contents remain readable"], 0, 1)], + ["separated.ts", ["--- a/separated.ts", "+++ b/separated.ts", "@@ -1,3 +1,3 @@", " function first() {", "- return oldFirst;", "+ return newFirst;", " }", "@@ -25,3 +25,3 @@", " function second() {", "- return oldSecond;", "+ return newSecond;", " }", ""].join("\n")], + ["long.ts", patch("long.ts", longLines.map(line => `+${line}`), 0, longLines.length)], + ["worker.ts", patch("worker.ts", longLines.map(line => `+${line} // ${"worker source ".repeat(10)}`), 0, longLines.length)], + ["long-separated.ts", ["--- a/long-separated.ts", "+++ b/long-separated.ts", ...[0, 1, 2].flatMap(index => [`@@ -${index * 500},0 +${index * 500 + 1},200 @@`, ...longLines.slice(index * 200, (index + 1) * 200).map(line => `+${line}`)]), ""].join("\n")], + ["truncated.ts", patch("truncated.ts", ["+export const truncated = true;"], 0, 1)], +]; + +export function FileDiffFixture() { + const { theme, toggle } = useTheme(); + const [opened, setOpened] = useState(""); + const [changed, setChanged] = useState(false); + const scroller = useRef(null); + const content = useRef(null); + const viewport = useMemo(() => ({ scroller, content }), []); + return +
+
+ + + + {samples.map(([path, text]) => { + const edit: FileEditSummary = { + key: path, path, absolute_path: `/fixture/${path}`, added: 1, deleted: 1, + approximate: false, binary: false, status: "done", pending: false, + diff: { format: "unified", text: changed && path === "Status.tsx" ? text.replace(">ready<", ">updated<") : text, truncated: path === "truncated.ts" }, + }; + return
+ +
; + })} + {opened} +
; +} diff --git a/webui/browser/file-diff.spec.ts b/webui/browser/file-diff.spec.ts new file mode 100644 index 000000000..de044ccc1 --- /dev/null +++ b/webui/browser/file-diff.spec.ts @@ -0,0 +1,225 @@ +import { expect, test, type Locator } from "@playwright/test"; + +async function expectKeywordColor(rows: Locator) { + await expect.poll(async () => rows.locator("span").evaluateAll(nodes => { + const probe = document.createElement("span"); + probe.style.color = "var(--code-keyword)"; + document.body.append(probe); + const expected = getComputedStyle(probe).color; + probe.remove(); + return nodes.some(node => node.textContent?.trim() === "export" && getComputedStyle(node).color === expected); + })).toBe(true); +} + +async function expectTokenColor(section: Locator, text: string, variable: string) { + await expect.poll(async () => section.locator("[data-line] span").evaluateAll((nodes, target) => { + const probe = document.createElement("span"); + probe.style.color = `var(${target.variable})`; + document.body.append(probe); + const expected = getComputedStyle(probe).color; + probe.remove(); + return nodes.some(node => node.textContent?.trim() === target.text && getComputedStyle(node).color === expected); + }, { text, variable })).toBe(true); +} + +for (const dark of [false, true]) { + for (const narrow of [false, true]) { + test(`read-only diffs preserve source, colors and reading sizes: ${dark ? "dark" : "light"}, ${narrow ? "narrow" : "desktop"}`, async ({ page }) => { + const errors: string[] = []; + page.on("pageerror", error => errors.push(error.message)); + await page.setViewportSize({ width: narrow ? 390 : 1280, height: 900 }); + await page.addInitScript(theme => { + localStorage.setItem("nanobot.locale", "en"); + localStorage.setItem("nanobot-webui.theme", theme); + }, dark ? "dark" : "light"); + await page.goto("/browser/fixture.html?case=file-diff"); + const tsx = page.getByRole("region", { name: "Status.tsx", exact: true }); + const rows = tsx.locator("[data-code] [data-line]"); + await expect(rows).toHaveCount(5); + await expect(rows.nth(2)).toHaveText(' return old;'); + await expect(rows.nth(3)).toHaveText(' return ready;'); + await expect(tsx.locator("[data-line][data-line-type=change-addition] [data-diff-span]")).not.toHaveCount(0); + await expectKeywordColor(rows); + for (const [size, body] of [["small", 15], ["standard", 16], ["large", 18]] as const) { + await page.evaluate(value => { document.documentElement.dataset.readingTextSize = value; }, size); + await expect(rows.first()).toHaveCSS("font-size", `${body * 0.75}px`); + await expect.poll(async () => rows.first().evaluate(node => parseFloat(getComputedStyle(node).lineHeight))) + .toBeCloseTo(body * 0.75 * 1.6); + expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true); + } + const callbacks = page.getByRole("region", { name: "callbacks.tsx", exact: true }); + for (const [text, variable] of [["\"yes\"", "--code-string"], ["new", "--code-keyword"], ["save", "--code-function"], ["=>", "--code-function"], ["className", "--code-property"], ["span", "--code-property"]]) { + await expectTokenColor(callbacks, text, variable); + } + const config = page.getByRole("region", { name: "config.ini", exact: true }); + await expect(config.locator("[data-code] [data-line]")).toHaveCount(4); + await expectTokenColor(config, "; comment", "--code-comment"); + await expect(config.locator("[data-code] [data-line]").last()).toHaveText("host=localhost"); + const markdown = page.getByRole("region", { name: "table.md", exact: true }); + await expect(markdown.locator("[data-code] [data-line]")).toHaveCount(5); + expect((await markdown.locator("[data-code] [data-line]").allTextContents()).map(line => line.replace(/\n$/, ""))).toEqual([ + "## 发布安排", "", "| 日期 | 角色 | 方向 |", "| --- | --- | --- |", "| 7/22 | trust / core | data-driven |", + ]); + await expect(page.getByRole("region", { name: "page.html", exact: true }).locator("[data-code] [data-line]")) + .toHaveText(''); + await expect(page.getByRole("region", { name: "bun.lock", exact: true }).locator("[data-code] [data-line]")) + .toHaveText("unknown-language contents remain readable"); + const separated = page.getByRole("region", { name: "separated.ts", exact: true }); + await expect(separated.getByTestId("file-edit-diff-hunk-gap")).toHaveText(/21 unchanged lines hidden/); + expect(await separated.getByTestId("file-edit-diff-hunk-gap").evaluate(node => node.closest("[data-separator]")!.getBoundingClientRect().height)).toBe(26); + await expect(separated.locator("[data-code] [data-line]")).toHaveCount(8); + await expect(separated.locator("[data-column-number]").last()).toContainText("27"); + await page.getByRole("button", { name: "Toggle theme" }).click(); + await expect(page.locator("html")).toHaveClass(dark ? "" : "dark"); + await expect(rows).toHaveCount(5); + await expectKeywordColor(rows); + for (const [text, variable] of [["\"yes\"", "--code-string"], ["new", "--code-keyword"], ["save", "--code-function"], ["=>", "--code-function"], ["className", "--code-property"], ["span", "--code-property"]]) { + await expectTokenColor(callbacks, text, variable); + } + expect(errors).toEqual([]); + }); + } +} + +test("large diffs retain bounded expansion, release and truncated-file actions", async ({ page }) => { + const errors: string[] = []; + page.on("pageerror", error => errors.push(error.message)); + await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en")); + await page.goto("/browser/fixture.html?case=file-diff"); + const long = page.getByRole("region", { name: "long.ts", exact: true }); + const toggle = long.getByTestId("file-edit-diff-toggle"); + await expect(toggle).toHaveAttribute("aria-expanded", "false"); + await expect(long.locator("diffs-container")).toHaveCount(0); + await toggle.click(); + await expect(long.locator("[data-code] [data-line]")).toHaveCount(160); + await expect(long.locator("[data-code] [data-line]").last()).toHaveText('export const item160 = "第 160 行 — readable code";'); + await long.getByTestId("file-edit-diff-expand-lines").click(); + const scroller = page.getByTestId("diff-fixture-scroller"); + const seen = new Set(); + const height = await scroller.evaluate(node => node.scrollHeight); + for (let top = 0; top <= height + 700; top += 700) { + await scroller.evaluate((node, offset) => { node.scrollTop = offset; }, top); + await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))); + const rows = await long.locator("[data-code] [data-line]").evaluateAll(nodes => nodes.map(node => ({ number: Number(node.getAttribute("data-line")), text: node.textContent?.replace(/\n$/, "") }))); + expect(rows.length).toBeLessThan(200); + for (const row of rows) { + expect(row.text).toBe(`export const item${row.number} = "第 ${row.number} 行 — readable code";`); + seen.add(row.number); + } + expect(await scroller.evaluate(node => node.scrollHeight)).toBe(height); + } + expect([...seen].sort((a, b) => a - b)).toEqual(Array.from({ length: 600 }, (_, i) => i + 1)); + await expect(long.locator("[data-code] [data-line]").last()).toHaveText('export const item600 = "第 600 行 — readable code";'); + await long.getByTestId("file-edit-diff-collapse-lines").click(); + await expect(long.locator("[data-code] [data-line]")).toHaveCount(160); + await toggle.click(); + await expect(long.getByTestId("file-edit-diff")).toHaveCount(0); + await toggle.click(); + await expect(long.locator("[data-code] [data-line]")).toHaveCount(160); + const truncated = page.getByRole("region", { name: "truncated.ts", exact: true }); + await truncated.getByTestId("file-edit-diff-toggle").click(); + await expect(truncated.getByTestId("file-edit-diff-truncated")).toContainText("Diff truncated"); + await truncated.getByTestId("file-edit-diff-open-file").click(); + await expect(page.getByRole("status", { name: "Opened file" })).toHaveText("/fixture/truncated.ts"); + expect(errors).toEqual([]); +}); + +for (const file of ["worker.ts", "long-separated.ts"]) { + test(`windowed ${file} retains every source line and coordinate`, async ({ page }) => { + const errors: string[] = []; + page.on("pageerror", error => errors.push(error.message)); + await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en")); + await page.goto("/browser/fixture.html?case=file-diff"); + const section = page.getByRole("region", { name: file, exact: true }); + await section.getByTestId("file-edit-diff-toggle").click(); + await expect(section.locator("[data-code] [data-line]")).toHaveCount(160); + await expectKeywordColor(section.locator("[data-code] [data-line]")); + await section.getByTestId("file-edit-diff-expand-lines").click(); + const scroller = page.getByTestId("diff-fixture-scroller"); + const seen = new Set(); + const height = await scroller.evaluate(node => node.scrollHeight); + for (let top = 0; top <= height + 700; top += 700) { + await scroller.evaluate((node, offset) => { node.scrollTop = offset; }, top); + await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))); + const rows = await section.locator("[data-code] [data-line]").evaluateAll(nodes => nodes.map(node => ({ number: Number(node.getAttribute("data-line")), text: node.textContent?.replace(/\n$/, ""), kind: node.getAttribute("data-line-type") }))); + expect(rows.length).toBeLessThan(200); + for (const row of rows) { + const index = file === "long-separated.ts" ? Math.floor((row.number - 1) / 500) * 200 + (row.number - 1) % 500 + 1 : row.number; + expect(row.text).toBe(`export const item${index} = "第 ${index} 行 — readable code";${file === "worker.ts" ? ` // ${"worker source ".repeat(10)}` : ""}`); + expect(row.kind).toBe("change-addition"); + seen.add(index); + } + expect(await scroller.evaluate(node => node.scrollHeight)).toBe(height); + } + expect([...seen].sort((a, b) => a - b)).toEqual(Array.from({ length: 600 }, (_, i) => i + 1)); + expect(errors).toEqual([]); + }); +} + +test("a changed source replaces cached syntax without stale text", async ({ page }) => { + await page.goto("/browser/fixture.html?case=file-diff"); + const section = page.getByRole("region", { name: "Status.tsx", exact: true }); + await expect(section.locator("[data-code] [data-line]").nth(3)).toHaveText(' return ready;'); + await page.getByRole("button", { name: "Change source" }).click(); + await expect(section.locator("[data-code] [data-line]").nth(3)).toHaveText(' return updated;'); + await expectKeywordColor(section.locator("[data-code] [data-line]")); + const gap = page.getByRole("region", { name: "separated.ts", exact: true }).getByTestId("file-edit-diff-hunk-gap"); + await page.getByRole("button", { name: "Chinese", exact: true }).click(); + await expect(gap).toContainText("21"); + await expect(gap).toHaveText("… 已隐藏 21 行未修改内容"); +}); + + +for (const [file, renderedIndex, sourceLine, reverse] of [["long.ts", 58, 59, false], ["long-separated.ts", 249, 550, true]] as const) { + test(`native selection survives moving diff windows and releases pinned rows: ${file}`, async ({ page, context }) => { + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + await page.setViewportSize({ width: 1280, height: 700 }); + await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en")); + await page.goto("/browser/fixture.html?case=file-diff"); + const section = page.getByRole("region", { name: file, exact: true }); + await section.getByTestId("file-edit-diff-toggle").click(); + await expectKeywordColor(section.locator("[data-code] [data-line]")); + await section.getByTestId("file-edit-diff-expand-lines").click(); + const scroller = page.getByTestId("diff-fixture-scroller"); + const height = await scroller.evaluate(node => node.scrollHeight); + await section.getByTestId("syntax-highlighted-diff-hunk").evaluate((node, index) => { + const scroller = document.querySelector('[data-testid="diff-fixture-scroller"]')!; + const lineHeight = parseFloat(getComputedStyle(node).lineHeight) + 2; + scroller.scrollTop += node.getBoundingClientRect().top - scroller.getBoundingClientRect().top + index * lineHeight - 200; + }, renderedIndex); + const line = section.locator(`[data-code] [data-line="${sourceLine}"]`); + await expect(line).toBeVisible(); + // Settle the scheduled window update before beginning a physical drag. + await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))); + const box = await line.evaluate(node => { + const text = document.createTreeWalker(node, NodeFilter.SHOW_TEXT).nextNode()!; + const range = document.createRange(); + range.setStart(text, 0); + range.setEnd(text, 1); + const bounds = range.getBoundingClientRect(); + return { x: bounds.x, y: bounds.y, height: bounds.height }; + }); + const left = box.x + 1; + const right = left + 200; + await page.mouse.move(reverse ? right : left, box.y + box.height / 2); + await page.mouse.down(); + await page.mouse.move(reverse ? left : right, box.y + box.height / 2, { steps: 8 }); + await page.mouse.up(); + const selected = await page.evaluate(() => document.getSelection()!.toString()); + expect(selected).toContain("export const"); + const first = Number(await section.locator("[data-code] [data-line]").first().getAttribute("data-line")); + await scroller.evaluate(node => { node.scrollTop += 3200; }); + await expect.poll(() => section.locator("[data-code] [data-line]").count()).toBeGreaterThan(200); + expect(await page.evaluate(() => document.getSelection()!.toString())).toBe(selected); + await page.keyboard.press("ControlOrMeta+C"); + await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe(selected); + await expect(line).toBeAttached(); + expect(await scroller.evaluate(node => node.scrollHeight)).toBe(height); + const last = section.locator("[data-code] [data-line]").last(); + expect(Number(await last.getAttribute("data-line"))).toBeGreaterThan(sourceLine + 100); + await page.evaluate(() => document.getSelection()!.removeAllRanges()); + await expect.poll(() => section.locator("[data-code] [data-line]").count()).toBeLessThan(200); + expect(Number(await section.locator("[data-code] [data-line]").first().getAttribute("data-line"))).toBeGreaterThan(first); + await expect(line).toHaveCount(0); + }); +} diff --git a/webui/browser/fixture.tsx b/webui/browser/fixture.tsx index 52ff08947..871071e47 100644 --- a/webui/browser/fixture.tsx +++ b/webui/browser/fixture.tsx @@ -36,6 +36,8 @@ import { ActivityLogosFixture } from "./activity-logos-fixture"; import { HistoryHydrationFixture } from "./history-hydration-fixture"; import { IdleCompactionFixture, installIdleCompactionApi } from "./idle-compaction-fixture"; import { FileEditPathFixture } from "./file-edit-path-fixture"; +import { FileDiffFixture } from "./file-diff-fixture"; +import { CodeHighlightingFixture } from "./code-highlighting-fixture"; import { QueuedGuidanceFixture } from "./queued-guidance-fixture"; import { WorkspaceAlignmentFixture } from "./workspace-alignment-fixture"; import { ComposerActionFixture } from "./composer-action-fixture"; @@ -148,7 +150,7 @@ function RailFixture() { panes={[{ key: "rail", title: "Rail conversation" }]} activePaneKey="rail" layout="columns" showLayoutControl={false} onActivatePane={() => {}} onAddPane={() => {}} onLayoutChange={() => {}} onPaneOrderChange={() => {}} renderPane={(_pane, context) => <> - {viewport(true, context.navigationFrame)} + {viewport(context.composerPortalTarget !== undefined, context.navigationFrame)} {context.composerPortalTarget && createPortal(composer, context.composerPortalTarget)} } /> : viewport(false)} @@ -242,6 +244,10 @@ createRoot(document.getElementById("root")!).render( ? : parameters.get("case") === "queued-guidance" ? + : parameters.get("case") === "code-highlighting" + ? + : parameters.get("case") === "file-diff" + ? : parameters.get("case") === "file-edit-path" ? : parameters.get("case") === "answer-order" diff --git a/webui/browser/theme-toggle-fixture.tsx b/webui/browser/theme-toggle-fixture.tsx index 149de612f..a3af1a07d 100644 --- a/webui/browser/theme-toggle-fixture.tsx +++ b/webui/browser/theme-toggle-fixture.tsx @@ -46,6 +46,9 @@ const noop = () => {}; function ThemeChatFixture({ theme, toggle }: { theme: "light" | "dark"; toggle: () => void }) { const [activeKey, setActiveKey] = useState(sessions[0].key); const composer = ; + const header = ; + const panes = [{ key: "theme", title: "Theme chat" }]; + if (new URLSearchParams(location.search).has("split")) panes.push({ key: "theme-secondary", title: "Secondary chat" }); return
-
- + {context.active && (context.headerPortalTarget + ? createPortal(header, context.headerPortalTarget) + : context.headerPortalTarget === undefined ? header : null)} + navigationFrame={context.navigationFrame} composer={context.composerPortalTarget === undefined ? composer : null} /> - {context.composerPortalTarget && createPortal(
{composer}
, context.composerPortalTarget)} + {context.active && context.composerPortalTarget && createPortal(
{composer}
, context.composerPortalTarget)}
} />
; diff --git a/webui/browser/theme-toggle.spec.ts b/webui/browser/theme-toggle.spec.ts index 8d6613a40..34101efeb 100644 --- a/webui/browser/theme-toggle.spec.ts +++ b/webui/browser/theme-toggle.spec.ts @@ -106,14 +106,14 @@ test("reduced motion keeps the canvas fade but switches the icon directly", asyn for (const width of [1440, 390]) { for (const initial of ["light", "dark"] as const) { - test(`reduced motion fades existing chat surfaces together from ${initial} at ${width}px`, async ({ page }) => { + test(`reduced motion fades shared-composer chat surfaces together from ${initial} at ${width}px`, async ({ page }) => { await page.emulateMedia({ reducedMotion: "reduce" }); await page.setViewportSize({ width, height: 844 }); await page.addInitScript((theme) => { localStorage.setItem("nanobot.locale", "en"); localStorage.setItem("nanobot-webui.theme", theme); }, initial); - await page.goto("/browser/fixture.html?case=theme-toggle&chat"); + await page.goto("/browser/fixture.html?case=theme-toggle&chat&split"); const input = page.getByRole("textbox"); await input.fill("Keep this draft while changing theme"); const inputBox = await input.boundingBox(); diff --git a/webui/browser/typography-fixture.tsx b/webui/browser/typography-fixture.tsx index f36f4cc46..795d1701b 100644 --- a/webui/browser/typography-fixture.tsx +++ b/webui/browser/typography-fixture.tsx @@ -3,7 +3,7 @@ import { useEffect, useState } from "react"; import { MessageBubble } from "@/components/MessageBubble"; import { AppearanceSettingsView } from "@/components/settings/overview/AppearanceSettingsView"; import { ThreadComposer } from "@/components/thread/ThreadComposer"; -import { DiffSyntaxHighlight } from "@/components/thread/activity/DiffSyntaxHighlight"; +import { FileEditGroup } from "@/components/thread/activity/FileEditRow"; import { ThemeProvider, useTheme } from "@/hooks/useTheme"; import { useReadingTypography } from "@/hooks/useReadingTypography"; import { readLocalPreferences, writeLocalPreferences } from "@/lib/local-preferences"; @@ -96,10 +96,10 @@ export function TypographyFixture() {
{[...previewMessages, ...sent].map((message) => )} -
+ { setSent((current) => [...current, { id: `sent-${current.length}`, role: "user", content: text, createdAt: 3 + current.length }]); }} /> diff --git a/webui/bun.lock b/webui/bun.lock index 2d75ce8cb..9641a465e 100644 --- a/webui/bun.lock +++ b/webui/bun.lock @@ -5,6 +5,8 @@ "": { "name": "nanobot-webui", "dependencies": { + "@pierre/diffs": "1.6.4", + "@pierre/highlights": "0.4.0", "@radix-ui/react-alert-dialog": "^1.1.4", "@radix-ui/react-dialog": "^1.1.4", "@radix-ui/react-dropdown-menu": "^2.1.4", @@ -28,7 +30,6 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-i18next": "^17.0.4", - "react-syntax-highlighter": "^15.6.1", "rehype-katex": "^7.0.1", "remark-breaks": "^4.0.0", "remark-cjk-friendly": "2.3.3", @@ -37,6 +38,7 @@ "remark-parse": "^11.0.0", "remend": "1.3.0", "saxes": "6.0.0", + "shiki": "4.6.0", "streamdown": "2.6.0", "tailwind-merge": "^2.6.0", "unified": "^11.0.5", @@ -55,7 +57,6 @@ "@types/qrcode": "^1.5.6", "@types/react": "^18.3.18", "@types/react-dom": "^18.3.5", - "@types/react-syntax-highlighter": "^15.5.13", "@vitejs/plugin-react": "^4.3.4", "@vitest/coverage-v8": "2.1.9", "autoprefixer": "^10.4.20", @@ -226,6 +227,14 @@ "@nodelib/fs.walk": ["@nodelib/fs.walk@1.2.8", "", { "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" } }, "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg=="], + "@pierre/diffs": ["@pierre/diffs@1.6.4", "", { "dependencies": { "@pierre/highlights": "0.4.0", "@pierre/theme": "2.0.0", "@pierre/theming": "1.0.2", "diff": "9.0.0", "hast-util-to-html": "9.0.5", "lru_map": "0.4.1", "shiki": "^3.0.0 || ^4.0.0" }, "peerDependencies": { "react": "^18.3.1 || ^19.0.0", "react-dom": "^18.3.1 || ^19.0.0" }, "optionalPeers": ["react", "react-dom"] }, "sha512-RsKoruCOp50qaDM3a7BQan5K77xMkGWT1NF01fiYP1PfT3v4CvIjwytNk5WjZG0BesBkMOP2UbrBIDigB1k0ug=="], + + "@pierre/highlights": ["@pierre/highlights@0.4.0", "", {}, "sha512-2a38H7ep3KweGi1fGQpJk+Krod2OMpDIXagKPlqBd1Y9P460T7zQmc66Wm2JAH1SpIG93wCyyhZVrkc5dnAJVQ=="], + + "@pierre/theme": ["@pierre/theme@2.0.0", "", {}, "sha512-yNDd9GYLQl1mEUJR8AneJ5e4ohLIHQd/wZLWr4fagt78vS2RwwZNW530vVgHqXFAyFVcFlRmGUD5ramXH46OXw=="], + + "@pierre/theming": ["@pierre/theming@1.0.2", "", { "peerDependencies": { "@pierre/theme": "^1.1.0 || ^2.0.0", "@shikijs/themes": "^3.0.0 || ^4.0.0", "react": "^18.3.1 || ^19.0.0", "react-dom": "^18.3.1 || ^19.0.0", "shiki": "^3.0.0 || ^4.0.0" }, "optionalPeers": ["@pierre/theme", "@shikijs/themes", "react", "react-dom", "shiki"] }, "sha512-RmXLLqtx31UGcR8kZyO5hGAQ1EXz6loT1Cu0BFAGsbnBboIxp2BlomkLfWyvdT4WZXnBGyu25onL1gKpFQuSUw=="], + "@pkgjs/parseargs": ["@pkgjs/parseargs@0.11.0", "", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="], "@playwright/test": ["@playwright/test@1.64.1", "", { "dependencies": { "playwright": "1.64.1" }, "bin": { "playwright": "cli.js" } }, "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg=="], @@ -350,6 +359,22 @@ "@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.60.1", "", { "os": "win32", "cpu": "x64" }, "sha512-lWMnixq/QzxyhTV6NjQJ4SFo1J6PvOX8vUx5Wb4bBPsEb+8xZ89Bz6kOXpfXj9ak9AHTQVQzlgzBEc1SyM27xQ=="], + "@shikijs/core": ["@shikijs/core@4.6.0", "", { "dependencies": { "@shikijs/primitive": "4.6.0", "@shikijs/types": "4.6.0", "@shikijs/vscode-textmate": "^10.1.0", "@types/hast": "^3.0.5", "hast-util-to-html": "^9.0.6" } }, "sha512-bfd4OKgvoyXYiYmMRuleA656P4V7M/Du9lcTl38Ngm6KszMj7bq4J1IGZwSYR4c95Tv5UQALtYNWUwaI9UT3xw=="], + + "@shikijs/engine-javascript": ["@shikijs/engine-javascript@4.6.0", "", { "dependencies": { "@shikijs/types": "4.6.0", "@shikijs/vscode-textmate": "^10.1.0", "oniguruma-to-es": "^4.3.6" } }, "sha512-K0oqxFoL+kEMdz89mHLFO15Tsbv3kFZ6WR1cXZKMvLSc+oqaM00A6pyga1qSeXB22dP0tTiSApRcGBaKWsEccg=="], + + "@shikijs/engine-oniguruma": ["@shikijs/engine-oniguruma@4.6.0", "", { "dependencies": { "@shikijs/types": "4.6.0", "@shikijs/vscode-textmate": "^10.1.0" } }, "sha512-aggd6Q7SuJOXNnsUbfG2XesxBJKBMAw/PDTUo9PyRjMaaJJ2dNrI+q0C+25ARXAK9yLHAlwxc9oRT2u68YKZ7w=="], + + "@shikijs/langs": ["@shikijs/langs@4.6.0", "", { "dependencies": { "@shikijs/types": "4.6.0" } }, "sha512-1yMEX3oCVV54LUq/ovfpRkDQoYDkcvjSWFFa/YLUDMiSoRzMi2uxLJYbv41ahT8Lu9lFMaa7hecd3Q39trqUyg=="], + + "@shikijs/primitive": ["@shikijs/primitive@4.6.0", "", { "dependencies": { "@shikijs/types": "4.6.0", "@shikijs/vscode-textmate": "^10.1.0", "@types/hast": "^3.0.5" } }, "sha512-c54+TQEo9ToqgfL/AU8FpjnV09+GA9Oa7M5ROkkXteZfp5XzpAJGXjjvZQFQioJOwm/w/6Z3lIzQstAkl8coag=="], + + "@shikijs/themes": ["@shikijs/themes@4.6.0", "", { "dependencies": { "@shikijs/types": "4.6.0" } }, "sha512-qHAVAs80RiGD+IRuH9G+JPDOEc9A/kHsng4EzCUCwB9bLzW6Z0y9WETh2YyCcADJBmfrIaJ1Jp7KBNP6FHkgtQ=="], + + "@shikijs/types": ["@shikijs/types@4.6.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.1.0", "@types/hast": "^3.0.5" } }, "sha512-+ENG1adsKt/X7cRYw1Nl7BEpBmPOjmQ7bR/eGmHuMlT8gtOFf3KEi5l31DJYyAWhW6Y6bjP1plU7FmaxWGENFw=="], + + "@shikijs/vscode-textmate": ["@shikijs/vscode-textmate@10.1.0", "", {}, "sha512-cVBuhDQjBZaNMTwBquYfPydrUP+E3hE6oYGasx8h6ZrODIM7/r+gxLDXdd66oszbrggZHEntdE6j+5gYIVyMWQ=="], + "@tailwindcss/typography": ["@tailwindcss/typography@0.5.19", "", { "dependencies": { "postcss-selector-parser": "6.0.10" }, "peerDependencies": { "tailwindcss": ">=3.0.0 || insiders || >=4.0.0-alpha.20 || >=4.0.0-beta.1" } }, "sha512-w31dd8HOx3k9vPtcQh5QHP9GwKcgbMp87j58qi6xgiBnFFtKEAgCWnDw4qUT8aHwkCp8bKvb/KGKWWHedP0AAg=="], "@testing-library/dom": ["@testing-library/dom@10.4.1", "", { "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", "@types/aria-query": "^5.0.1", "aria-query": "5.3.0", "dom-accessibility-api": "^0.5.9", "lz-string": "^1.5.0", "picocolors": "1.1.1", "pretty-format": "^27.0.2" } }, "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg=="], @@ -402,8 +427,6 @@ "@types/react-dom": ["@types/react-dom@18.3.7", "", { "peerDependencies": { "@types/react": "^18.0.0" } }, "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ=="], - "@types/react-syntax-highlighter": ["@types/react-syntax-highlighter@15.5.13", "", { "dependencies": { "@types/react": "*" } }, "sha512-uLGJ87j6Sz8UaBAooU0T6lWJ0dBmjZgN1PZTrj05TNql2/XpC6+4HhMT5syIdFUUt+FASfCeLLv4kBygNU+8qA=="], - "@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="], "@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.62.1", "", { "dependencies": { "@eslint-community/regexpp": "^4.12.2", "@typescript-eslint/scope-manager": "8.62.1", "@typescript-eslint/type-utils": "8.62.1", "@typescript-eslint/utils": "8.62.1", "@typescript-eslint/visitor-keys": "8.62.1", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.62.1", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } }, "sha512-4EQM77WgVNxj7OkL/5b/D/xZsw00G577+UriYTC7JF5opcF3T2AuoeY7ueLaZgSVjSgCS6yOAJB5bRGLPSJUzA=="], @@ -500,9 +523,9 @@ "character-entities-html4": ["character-entities-html4@2.1.0", "", {}, "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA=="], - "character-entities-legacy": ["character-entities-legacy@1.1.4", "", {}, "sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA=="], + "character-entities-legacy": ["character-entities-legacy@3.0.0", "", {}, "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ=="], - "character-reference-invalid": ["character-reference-invalid@1.1.4", "", {}, "sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg=="], + "character-reference-invalid": ["character-reference-invalid@2.0.1", "", {}, "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw=="], "check-error": ["check-error@2.1.3", "", {}, "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA=="], @@ -622,8 +645,6 @@ "fastq": ["fastq@1.20.1", "", { "dependencies": { "reusify": "^1.0.4" } }, "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw=="], - "fault": ["fault@1.0.4", "", { "dependencies": { "format": "^0.2.0" } }, "sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA=="], - "fdir": ["fdir@6.5.0", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="], "file-entry-cache": ["file-entry-cache@8.0.0", "", { "dependencies": { "flat-cache": "^4.0.0" } }, "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ=="], @@ -638,8 +659,6 @@ "foreground-child": ["foreground-child@3.3.1", "", { "dependencies": { "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" } }, "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw=="], - "format": ["format@0.2.2", "", {}, "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww=="], - "fraction.js": ["fraction.js@5.3.4", "", {}, "sha512-1X1NTtiJphryn/uLQz3whtY6jK3fTqoE3ohKs0tT+Ujr1W59oopxmoEh7Lu5p6vBaPbgoM0bzveAW4Qi5RyWDQ=="], "framer-motion": ["framer-motion@14.4.0", "https://registry.npmjs.org/framer-motion/-/framer-motion-14.4.0.tgz", { "dependencies": { "motion-dom": "14.4.0", "motion-utils": "14.1.1", "tslib": "^2.4.0" }, "peerDependencies": { "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" }, "optionalPeers": ["react", "react-dom"] }, "sha512-HtO1fxord2rnXYRyr1laG4uY7+OtgwDc9Szcg1wlMq/LF7BO3/S7a+KEo691U7pSi+i0ueRuRqaD1UaLEmZHuQ=="], @@ -678,12 +697,14 @@ "hast-util-is-element": ["hast-util-is-element@3.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g=="], - "hast-util-parse-selector": ["hast-util-parse-selector@2.2.5", "", {}, "sha512-7j6mrk/qqkSehsM92wQjdIgWM2/BW61u/53G6xmC8i1OmEdKLHbk419QKQUjz6LglWsfqoiHmyMRkP1BGjecNQ=="], + "hast-util-parse-selector": ["hast-util-parse-selector@4.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A=="], "hast-util-raw": ["hast-util-raw@9.1.0", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "@ungap/structured-clone": "^1.0.0", "hast-util-from-parse5": "^8.0.0", "hast-util-to-parse5": "^8.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "parse5": "^7.0.0", "unist-util-position": "^5.0.0", "unist-util-visit": "^5.0.0", "vfile": "^6.0.0", "web-namespaces": "^2.0.0", "zwitch": "^2.0.0" } }, "sha512-Y8/SBAHkZGoNkpzqqfCldijcuUKh7/su31kEBp67cFY09Wy0mTRgtsLYsiIxMJxlu0f6AA5SUTbDR8K0rxnbUw=="], "hast-util-sanitize": ["hast-util-sanitize@5.0.2", "", { "dependencies": { "@types/hast": "^3.0.0", "@ungap/structured-clone": "^1.0.0", "unist-util-position": "^5.0.0" } }, "sha512-3yTWghByc50aGS7JlGhk61SPenfE/p1oaFeNwkOOyrscaOkMGrcW9+Cy/QAIOBpZxP1yqDIzFMR0+Np0i0+usg=="], + "hast-util-to-html": ["hast-util-to-html@9.0.5", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "zwitch": "^2.0.4" } }, "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw=="], + "hast-util-to-jsx-runtime": ["hast-util-to-jsx-runtime@2.3.6", "", { "dependencies": { "@types/estree": "^1.0.0", "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "comma-separated-tokens": "^2.0.0", "devlop": "^1.0.0", "estree-util-is-identifier-name": "^3.0.0", "hast-util-whitespace": "^3.0.0", "mdast-util-mdx-expression": "^2.0.0", "mdast-util-mdx-jsx": "^3.0.0", "mdast-util-mdxjs-esm": "^2.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "style-to-js": "^1.0.0", "unist-util-position": "^5.0.0", "vfile-message": "^4.0.0" } }, "sha512-zl6s8LwNyo1P9uw+XJGvZtdFF1GdAkOg8ujOw+4Pyb76874fLps4ueHXDhXWdk6YHQ6OgUtinliG7RsYvCbbBg=="], "hast-util-to-parse5": ["hast-util-to-parse5@8.0.1", "", { "dependencies": { "@types/hast": "^3.0.0", "comma-separated-tokens": "^2.0.0", "devlop": "^1.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "web-namespaces": "^2.0.0", "zwitch": "^2.0.0" } }, "sha512-MlWT6Pjt4CG9lFCjiz4BH7l9wmrMkfkJYCxFwKQic8+RTZgWPuWxwAfjJElsXkex7DJjfSJsQIt931ilUgmwdA=="], @@ -692,16 +713,12 @@ "hast-util-whitespace": ["hast-util-whitespace@3.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw=="], - "hastscript": ["hastscript@6.0.0", "", { "dependencies": { "@types/hast": "^2.0.0", "comma-separated-tokens": "^1.0.0", "hast-util-parse-selector": "^2.0.0", "property-information": "^5.0.0", "space-separated-tokens": "^1.0.0" } }, "sha512-nDM6bvd7lIqDUiYEiu5Sl/+6ReP0BMk/2f4U/Rooccxkj0P5nm+acM5PrGJ/t5I8qPGiqZSE6hVAwZEdZIvP4w=="], + "hastscript": ["hastscript@9.0.1", "", { "dependencies": { "@types/hast": "^3.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-parse-selector": "^4.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0" } }, "sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w=="], "hermes-estree": ["hermes-estree@0.25.1", "", {}, "sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw=="], "hermes-parser": ["hermes-parser@0.25.1", "", { "dependencies": { "hermes-estree": "0.25.1" } }, "sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA=="], - "highlight.js": ["highlight.js@10.7.3", "", {}, "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A=="], - - "highlightjs-vue": ["highlightjs-vue@1.0.0", "", {}, "sha512-PDEfEF102G23vHmPhLyPboFCD+BkMGu+GuJe2d9/eH4FsCwvgBpnc9n0pGE+ffKdph38s6foEZiEjdgHdzp+IA=="], - "html-escaper": ["html-escaper@2.0.2", "", {}, "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg=="], "html-parse-stringify": ["html-parse-stringify@3.0.1", "", { "dependencies": { "void-elements": "3.1.0" } }, "sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg=="], @@ -720,15 +737,15 @@ "inline-style-parser": ["inline-style-parser@0.2.7", "", {}, "sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA=="], - "is-alphabetical": ["is-alphabetical@1.0.4", "", {}, "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg=="], + "is-alphabetical": ["is-alphabetical@2.0.1", "", {}, "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ=="], - "is-alphanumerical": ["is-alphanumerical@1.0.4", "", { "dependencies": { "is-alphabetical": "^1.0.0", "is-decimal": "^1.0.0" } }, "sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A=="], + "is-alphanumerical": ["is-alphanumerical@2.0.1", "", { "dependencies": { "is-alphabetical": "^2.0.0", "is-decimal": "^2.0.0" } }, "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw=="], "is-binary-path": ["is-binary-path@2.1.0", "", { "dependencies": { "binary-extensions": "^2.0.0" } }, "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw=="], "is-core-module": ["is-core-module@2.16.1", "", { "dependencies": { "hasown": "^2.0.2" } }, "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w=="], - "is-decimal": ["is-decimal@1.0.4", "", {}, "sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw=="], + "is-decimal": ["is-decimal@2.0.1", "", {}, "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A=="], "is-extglob": ["is-extglob@2.1.1", "", {}, "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ=="], @@ -736,7 +753,7 @@ "is-glob": ["is-glob@4.0.3", "", { "dependencies": { "is-extglob": "^2.1.1" } }, "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg=="], - "is-hexadecimal": ["is-hexadecimal@1.0.4", "", {}, "sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw=="], + "is-hexadecimal": ["is-hexadecimal@2.0.1", "", {}, "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg=="], "is-number": ["is-number@7.0.0", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="], @@ -786,10 +803,10 @@ "loupe": ["loupe@3.2.1", "", {}, "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ=="], - "lowlight": ["lowlight@1.20.0", "", { "dependencies": { "fault": "^1.0.0", "highlight.js": "~10.7.0" } }, "sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw=="], - "lru-cache": ["lru-cache@5.1.1", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="], + "lru_map": ["lru_map@0.4.1", "", {}, "sha512-I+lBvqMMFfqaV8CJCISjI3wbjmwVu/VyOoU7+qtu9d7ioW5klMgsTTiUOUp+DJvfTTzKXoPbyC6YfgkNcyPSOg=="], + "lucide-react": ["lucide-react@0.469.0", "", { "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-28vvUnnKQ/dBwiCQtwJw7QauYnE7yd2Cyp4tTTJpvglX4EMpbflcdBgrgToX2j71B3YvugK/NH3BGUk+E/p/Fw=="], "lz-string": ["lz-string@1.5.0", "", { "bin": { "lz-string": "bin/bin.js" } }, "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ=="], @@ -936,6 +953,10 @@ "object-hash": ["object-hash@3.0.0", "", {}, "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw=="], + "oniguruma-parser": ["oniguruma-parser@0.12.2", "", {}, "sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw=="], + + "oniguruma-to-es": ["oniguruma-to-es@4.3.6", "", { "dependencies": { "oniguruma-parser": "^0.12.2", "regex": "^6.1.0", "regex-recursion": "^6.0.2" } }, "sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA=="], + "optionator": ["optionator@0.9.4", "", { "dependencies": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", "word-wrap": "^1.2.5" } }, "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g=="], "p-limit": ["p-limit@3.1.0", "", { "dependencies": { "yocto-queue": "^0.1.0" } }, "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ=="], @@ -946,7 +967,7 @@ "package-json-from-dist": ["package-json-from-dist@1.0.1", "", {}, "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw=="], - "parse-entities": ["parse-entities@2.0.0", "", { "dependencies": { "character-entities": "^1.0.0", "character-entities-legacy": "^1.0.0", "character-reference-invalid": "^1.0.0", "is-alphanumerical": "^1.0.0", "is-decimal": "^1.0.0", "is-hexadecimal": "^1.0.0" } }, "sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ=="], + "parse-entities": ["parse-entities@4.0.2", "", { "dependencies": { "@types/unist": "^2.0.0", "character-entities-legacy": "^3.0.0", "character-reference-invalid": "^2.0.0", "decode-named-character-reference": "^1.0.0", "is-alphanumerical": "^2.0.0", "is-decimal": "^2.0.0", "is-hexadecimal": "^2.0.0" } }, "sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw=="], "parse5": ["parse5@7.3.0", "", { "dependencies": { "entities": "^6.0.0" } }, "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw=="], @@ -996,8 +1017,6 @@ "pretty-format": ["pretty-format@27.5.1", "", { "dependencies": { "ansi-regex": "^5.0.1", "ansi-styles": "^5.0.0", "react-is": "^17.0.1" } }, "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ=="], - "prismjs": ["prismjs@1.30.0", "", {}, "sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw=="], - "property-information": ["property-information@7.1.0", "", {}, "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ=="], "punycode": ["punycode@2.3.1", "", {}, "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="], @@ -1022,15 +1041,17 @@ "react-style-singleton": ["react-style-singleton@2.2.3", "", { "dependencies": { "get-nonce": "^1.0.0", "tslib": "^2.0.0" }, "peerDependencies": { "@types/react": "*", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ=="], - "react-syntax-highlighter": ["react-syntax-highlighter@15.6.6", "", { "dependencies": { "@babel/runtime": "^7.3.1", "highlight.js": "^10.4.1", "highlightjs-vue": "^1.0.0", "lowlight": "^1.17.0", "prismjs": "^1.30.0", "refractor": "^3.6.0" }, "peerDependencies": { "react": ">= 0.14.0" } }, "sha512-DgXrc+AZF47+HvAPEmn7Ua/1p10jNoVZVI/LoPiYdtY+OM+/nG5yefLHKJwdKqY1adMuHFbeyBaG9j64ML7vTw=="], - "read-cache": ["read-cache@1.0.0", "", { "dependencies": { "pify": "^2.3.0" } }, "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA=="], "readdirp": ["readdirp@3.6.0", "", { "dependencies": { "picomatch": "^2.2.1" } }, "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA=="], "redent": ["redent@3.0.0", "", { "dependencies": { "indent-string": "^4.0.0", "strip-indent": "^3.0.0" } }, "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg=="], - "refractor": ["refractor@3.6.0", "", { "dependencies": { "hastscript": "^6.0.0", "parse-entities": "^2.0.0", "prismjs": "~1.27.0" } }, "sha512-MY9W41IOWxxk31o+YvFCNyNzdkc9M20NoZK5vq6jkv4I/uh2zkWcfudj0Q1fovjUQJrNewS9NMzeTtqPf+n5EA=="], + "regex": ["regex@6.1.0", "", { "dependencies": { "regex-utilities": "^2.3.0" } }, "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg=="], + + "regex-recursion": ["regex-recursion@6.0.2", "", { "dependencies": { "regex-utilities": "^2.3.0" } }, "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg=="], + + "regex-utilities": ["regex-utilities@2.3.0", "", {}, "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng=="], "rehype-harden": ["rehype-harden@1.1.8", "", { "dependencies": { "unist-util-visit": "^5.0.0" } }, "sha512-Qn7vR1xrf6fZCrkm9TDWi/AB4ylrHy+jqsNm1EHOAmbARYA6gsnVJBq/sdBh6kmT4NEZxH5vgIjrscefJAOXcw=="], @@ -1080,6 +1101,8 @@ "shebang-regex": ["shebang-regex@3.0.0", "", {}, "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="], + "shiki": ["shiki@4.6.0", "", { "dependencies": { "@shikijs/core": "4.6.0", "@shikijs/engine-javascript": "4.6.0", "@shikijs/engine-oniguruma": "4.6.0", "@shikijs/langs": "4.6.0", "@shikijs/themes": "4.6.0", "@shikijs/types": "4.6.0", "@shikijs/vscode-textmate": "^10.1.0", "@types/hast": "^3.0.5" } }, "sha512-imjLsVHgPuWhvpU3P+zOekvMYqnel7QmKsFC4Sn0fCuAvaaalBsxwKEsrU8Ko5BdFnZA6Go/8a0RzahS634UgA=="], + "siginfo": ["siginfo@2.0.0", "", {}, "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g=="], "signal-exit": ["signal-exit@4.1.0", "", {}, "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="], @@ -1222,8 +1245,6 @@ "xmlchars": ["xmlchars@2.2.0", "", {}, "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw=="], - "xtend": ["xtend@4.0.2", "", {}, "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="], - "y18n": ["y18n@4.0.3", "", {}, "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ=="], "yallist": ["yallist@3.1.1", "", {}, "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="], @@ -1264,6 +1285,14 @@ "@radix-ui/react-tooltip/@radix-ui/react-slot": ["@radix-ui/react-slot@1.2.3", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A=="], + "@shikijs/core/@types/hast": ["@types/hast@3.0.5", "", { "dependencies": { "@types/unist": "*" } }, "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g=="], + + "@shikijs/core/hast-util-to-html": ["hast-util-to-html@9.0.6", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "zwitch": "^2.0.4" } }, "sha512-1SZUxCN3TtJAE7e2BQN2MBHsoZ1gnmi9GoCP5Di59CSWptIezSAW09yDZyVbanb78V9eCwrKqdQsjtfVTxYHWA=="], + + "@shikijs/primitive/@types/hast": ["@types/hast@3.0.5", "", { "dependencies": { "@types/unist": "*" } }, "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g=="], + + "@shikijs/types/@types/hast": ["@types/hast@3.0.5", "", { "dependencies": { "@types/unist": "*" } }, "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g=="], + "@testing-library/dom/aria-query": ["aria-query@5.3.0", "", { "dependencies": { "dequal": "^2.0.3" } }, "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A=="], "@testing-library/dom/dom-accessibility-api": ["dom-accessibility-api@0.5.16", "", {}, "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg=="], @@ -1278,18 +1307,6 @@ "glob/minimatch": ["minimatch@9.0.9", "", { "dependencies": { "brace-expansion": "^2.0.2" } }, "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg=="], - "hast-util-from-dom/hastscript": ["hastscript@9.0.1", "", { "dependencies": { "@types/hast": "^3.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-parse-selector": "^4.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0" } }, "sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w=="], - - "hast-util-from-parse5/hastscript": ["hastscript@9.0.1", "", { "dependencies": { "@types/hast": "^3.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-parse-selector": "^4.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0" } }, "sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w=="], - - "hastscript/@types/hast": ["@types/hast@2.3.10", "", { "dependencies": { "@types/unist": "^2" } }, "sha512-McWspRw8xx8J9HurkVBfYj0xKoE25tOFlHGdx4MJ5xORQrMGZNqJhVQWaIbm6Oyla5kYOXtDiopzKRJzEOkwJw=="], - - "hastscript/comma-separated-tokens": ["comma-separated-tokens@1.0.8", "", {}, "sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw=="], - - "hastscript/property-information": ["property-information@5.6.0", "", { "dependencies": { "xtend": "^4.0.0" } }, "sha512-YUHSPk+A30YPv+0Qf8i9Mbfe/C0hdPXk1s1jPVToV8pk8BQtpw10ct89Eo7OWkutrwqvT0eicAxlOg3dOAu8JA=="], - - "hastscript/space-separated-tokens": ["space-separated-tokens@1.1.5", "", {}, "sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA=="], - "make-dir/semver": ["semver@7.8.5", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA=="], "mdast-util-find-and-replace/escape-string-regexp": ["escape-string-regexp@5.0.0", "", {}, "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw=="], @@ -1310,26 +1327,22 @@ "mdast-util-mdx-jsx/mdast-util-to-markdown": ["mdast-util-to-markdown@2.1.2", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "longest-streak": "^3.0.0", "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", "micromark-util-classify-character": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "unist-util-visit": "^5.0.0", "zwitch": "^2.0.0" } }, "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA=="], - "mdast-util-mdx-jsx/parse-entities": ["parse-entities@4.0.2", "", { "dependencies": { "@types/unist": "^2.0.0", "character-entities-legacy": "^3.0.0", "character-reference-invalid": "^2.0.0", "decode-named-character-reference": "^1.0.0", "is-alphanumerical": "^2.0.0", "is-decimal": "^2.0.0", "is-hexadecimal": "^2.0.0" } }, "sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw=="], - "mdast-util-mdxjs-esm/mdast-util-to-markdown": ["mdast-util-to-markdown@2.1.2", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "longest-streak": "^3.0.0", "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", "micromark-util-classify-character": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "unist-util-visit": "^5.0.0", "zwitch": "^2.0.0" } }, "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA=="], - "parse-entities/character-entities": ["character-entities@1.2.4", "", {}, "sha512-iBMyeEHxfVnIakwOuDXpVkc54HijNgCyQB2w0VfGQThle6NXn50zU6V/u+LDhxHcDUPojn6Kpga3PTAD8W1bQw=="], + "parse-entities/@types/unist": ["@types/unist@2.0.11", "", {}, "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA=="], "path-scurry/lru-cache": ["lru-cache@10.4.3", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="], "postcss-nested/postcss-selector-parser": ["postcss-selector-parser@6.1.2", "", { "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" } }, "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg=="], - "refractor/prismjs": ["prismjs@1.27.0", "", {}, "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA=="], - "remark-stringify/mdast-util-to-markdown": ["mdast-util-to-markdown@2.1.2", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "longest-streak": "^3.0.0", "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", "micromark-util-classify-character": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "unist-util-visit": "^5.0.0", "zwitch": "^2.0.0" } }, "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA=="], + "shiki/@types/hast": ["@types/hast@3.0.5", "", { "dependencies": { "@types/unist": "*" } }, "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g=="], + "streamdown/remend": ["remend@1.3.1", "", {}, "sha512-N3DiY5qbRPoa5vkxn1oDLMyXOVTeo6Hp+XOj6SIqJAYUgLS0Q587gILPMom/qm86AQ/ZrcOdwEIzCz8V3J0nxQ=="], "streamdown/tailwind-merge": ["tailwind-merge@3.6.0", "", {}, "sha512-uxL7qAVQriqRQPAyK3pj66VqskWqoZ37PW94jwOTwNfq/z9oyu1V+eqrZqtR2+fCiXdYOZe/Modt8GtvqNzu+w=="], - "stringify-entities/character-entities-legacy": ["character-entities-legacy@3.0.0", "", {}, "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ=="], - "sucrase/commander": ["commander@4.1.1", "", {}, "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA=="], "tailwindcss/postcss-selector-parser": ["postcss-selector-parser@6.1.2", "", { "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" } }, "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg=="], @@ -1350,30 +1363,10 @@ "glob/minimatch/brace-expansion": ["brace-expansion@2.1.4", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg=="], - "hast-util-from-dom/hastscript/hast-util-parse-selector": ["hast-util-parse-selector@4.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A=="], - - "hast-util-from-parse5/hastscript/hast-util-parse-selector": ["hast-util-parse-selector@4.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A=="], - - "hastscript/@types/hast/@types/unist": ["@types/unist@2.0.11", "", {}, "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA=="], - - "mdast-util-mdx-jsx/parse-entities/@types/unist": ["@types/unist@2.0.11", "", {}, "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA=="], - - "mdast-util-mdx-jsx/parse-entities/character-entities-legacy": ["character-entities-legacy@3.0.0", "", {}, "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ=="], - - "mdast-util-mdx-jsx/parse-entities/character-reference-invalid": ["character-reference-invalid@2.0.1", "", {}, "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw=="], - - "mdast-util-mdx-jsx/parse-entities/is-alphanumerical": ["is-alphanumerical@2.0.1", "", { "dependencies": { "is-alphabetical": "^2.0.0", "is-decimal": "^2.0.0" } }, "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw=="], - - "mdast-util-mdx-jsx/parse-entities/is-decimal": ["is-decimal@2.0.1", "", {}, "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A=="], - - "mdast-util-mdx-jsx/parse-entities/is-hexadecimal": ["is-hexadecimal@2.0.1", "", {}, "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg=="], - "yargs/find-up/locate-path": ["locate-path@5.0.0", "", { "dependencies": { "p-locate": "^4.1.0" } }, "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g=="], "glob/minimatch/brace-expansion/balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="], - "mdast-util-mdx-jsx/parse-entities/is-alphanumerical/is-alphabetical": ["is-alphabetical@2.0.1", "", {}, "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ=="], - "yargs/find-up/locate-path/p-locate": ["p-locate@4.1.0", "", { "dependencies": { "p-limit": "^2.2.0" } }, "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A=="], "yargs/find-up/locate-path/p-locate/p-limit": ["p-limit@2.3.0", "", { "dependencies": { "p-try": "^2.0.0" } }, "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w=="], diff --git a/webui/package-lock.json b/webui/package-lock.json index 12ba0e19d..97ace9dad 100644 --- a/webui/package-lock.json +++ b/webui/package-lock.json @@ -8,6 +8,8 @@ "name": "nanobot-webui", "version": "0.1.0", "dependencies": { + "@pierre/diffs": "1.6.4", + "@pierre/highlights": "0.4.0", "@radix-ui/react-alert-dialog": "^1.1.4", "@radix-ui/react-dialog": "^1.1.4", "@radix-ui/react-dropdown-menu": "^2.1.4", @@ -31,7 +33,6 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-i18next": "^17.0.4", - "react-syntax-highlighter": "^15.6.1", "rehype-katex": "^7.0.1", "remark-breaks": "^4.0.0", "remark-cjk-friendly": "2.3.3", @@ -40,6 +41,7 @@ "remark-parse": "^11.0.0", "remend": "1.3.0", "saxes": "6.0.0", + "shiki": "4.6.0", "streamdown": "2.6.0", "tailwind-merge": "^2.6.0", "unified": "^11.0.5" @@ -58,7 +60,6 @@ "@types/qrcode": "^1.5.6", "@types/react": "^18.3.18", "@types/react-dom": "^18.3.5", - "@types/react-syntax-highlighter": "^15.5.13", "@vitejs/plugin-react": "^4.3.4", "@vitest/coverage-v8": "2.1.9", "autoprefixer": "^10.4.20", @@ -1165,6 +1166,78 @@ "node": ">= 8" } }, + "node_modules/@pierre/diffs": { + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/@pierre/diffs/-/diffs-1.6.4.tgz", + "integrity": "sha512-RsKoruCOp50qaDM3a7BQan5K77xMkGWT1NF01fiYP1PfT3v4CvIjwytNk5WjZG0BesBkMOP2UbrBIDigB1k0ug==", + "license": "apache-2.0", + "dependencies": { + "@pierre/highlights": "0.4.0", + "@pierre/theme": "2.0.0", + "@pierre/theming": "1.0.2", + "diff": "9.0.0", + "hast-util-to-html": "9.0.5", + "lru_map": "0.4.1", + "shiki": "^3.0.0 || ^4.0.0" + }, + "peerDependencies": { + "react": "^18.3.1 || ^19.0.0", + "react-dom": "^18.3.1 || ^19.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, + "node_modules/@pierre/highlights": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@pierre/highlights/-/highlights-0.4.0.tgz", + "integrity": "sha512-2a38H7ep3KweGi1fGQpJk+Krod2OMpDIXagKPlqBd1Y9P460T7zQmc66Wm2JAH1SpIG93wCyyhZVrkc5dnAJVQ==", + "license": "apache-2.0" + }, + "node_modules/@pierre/theme": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@pierre/theme/-/theme-2.0.0.tgz", + "integrity": "sha512-yNDd9GYLQl1mEUJR8AneJ5e4ohLIHQd/wZLWr4fagt78vS2RwwZNW530vVgHqXFAyFVcFlRmGUD5ramXH46OXw==", + "license": "apache-2.0", + "engines": { + "vscode": "^1.0.0" + } + }, + "node_modules/@pierre/theming": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@pierre/theming/-/theming-1.0.2.tgz", + "integrity": "sha512-RmXLLqtx31UGcR8kZyO5hGAQ1EXz6loT1Cu0BFAGsbnBboIxp2BlomkLfWyvdT4WZXnBGyu25onL1gKpFQuSUw==", + "license": "apache-2.0", + "peerDependencies": { + "@pierre/theme": "^1.1.0 || ^2.0.0", + "@shikijs/themes": "^3.0.0 || ^4.0.0", + "react": "^18.3.1 || ^19.0.0", + "react-dom": "^18.3.1 || ^19.0.0", + "shiki": "^3.0.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "@pierre/theme": { + "optional": true + }, + "@shikijs/themes": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "shiki": { + "optional": true + } + } + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -2370,6 +2443,129 @@ "win32" ] }, + "node_modules/@shikijs/core": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.6.0.tgz", + "integrity": "sha512-bfd4OKgvoyXYiYmMRuleA656P4V7M/Du9lcTl38Ngm6KszMj7bq4J1IGZwSYR4c95Tv5UQALtYNWUwaI9UT3xw==", + "license": "MIT", + "dependencies": { + "@shikijs/primitive": "4.6.0", + "@shikijs/types": "4.6.0", + "@shikijs/vscode-textmate": "^10.1.0", + "@types/hast": "^3.0.5", + "hast-util-to-html": "^9.0.6" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/core/node_modules/hast-util-to-html": { + "version": "9.0.6", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.6.tgz", + "integrity": "sha512-1SZUxCN3TtJAE7e2BQN2MBHsoZ1gnmi9GoCP5Di59CSWptIezSAW09yDZyVbanb78V9eCwrKqdQsjtfVTxYHWA==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "ccount": "^2.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-whitespace": "^3.0.0", + "html-void-elements": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0", + "stringify-entities": "^4.0.0", + "zwitch": "^2.0.4" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/@shikijs/engine-javascript": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.6.0.tgz", + "integrity": "sha512-K0oqxFoL+kEMdz89mHLFO15Tsbv3kFZ6WR1cXZKMvLSc+oqaM00A6pyga1qSeXB22dP0tTiSApRcGBaKWsEccg==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.6.0", + "@shikijs/vscode-textmate": "^10.1.0", + "oniguruma-to-es": "^4.3.6" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/engine-oniguruma": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.6.0.tgz", + "integrity": "sha512-aggd6Q7SuJOXNnsUbfG2XesxBJKBMAw/PDTUo9PyRjMaaJJ2dNrI+q0C+25ARXAK9yLHAlwxc9oRT2u68YKZ7w==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.6.0", + "@shikijs/vscode-textmate": "^10.1.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/langs": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.6.0.tgz", + "integrity": "sha512-1yMEX3oCVV54LUq/ovfpRkDQoYDkcvjSWFFa/YLUDMiSoRzMi2uxLJYbv41ahT8Lu9lFMaa7hecd3Q39trqUyg==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.6.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/primitive": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.6.0.tgz", + "integrity": "sha512-c54+TQEo9ToqgfL/AU8FpjnV09+GA9Oa7M5ROkkXteZfp5XzpAJGXjjvZQFQioJOwm/w/6Z3lIzQstAkl8coag==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.6.0", + "@shikijs/vscode-textmate": "^10.1.0", + "@types/hast": "^3.0.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/themes": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.6.0.tgz", + "integrity": "sha512-qHAVAs80RiGD+IRuH9G+JPDOEc9A/kHsng4EzCUCwB9bLzW6Z0y9WETh2YyCcADJBmfrIaJ1Jp7KBNP6FHkgtQ==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.6.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/types": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.6.0.tgz", + "integrity": "sha512-+ENG1adsKt/X7cRYw1Nl7BEpBmPOjmQ7bR/eGmHuMlT8gtOFf3KEi5l31DJYyAWhW6Y6bjP1plU7FmaxWGENFw==", + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^10.1.0", + "@types/hast": "^3.0.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/vscode-textmate": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.1.0.tgz", + "integrity": "sha512-cVBuhDQjBZaNMTwBquYfPydrUP+E3hE6oYGasx8h6ZrODIM7/r+gxLDXdd66oszbrggZHEntdE6j+5gYIVyMWQ==", + "license": "MIT" + }, "node_modules/@tailwindcss/typography": { "version": "0.5.19", "dev": true, @@ -2554,7 +2750,9 @@ } }, "node_modules/@types/hast": { - "version": "3.0.4", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.5.tgz", + "integrity": "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==", "license": "MIT", "dependencies": { "@types/unist": "*" @@ -2624,14 +2822,6 @@ "@types/react": "^18.0.0" } }, - "node_modules/@types/react-syntax-highlighter": { - "version": "15.5.13", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/react": "*" - } - }, "node_modules/@types/unist": { "version": "3.0.3", "license": "MIT" @@ -3352,14 +3542,6 @@ "node": ">=18" } }, - "node_modules/character-entities": { - "version": "1.2.4", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/character-entities-html4": { "version": "2.1.0", "license": "MIT", @@ -3368,22 +3550,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/character-entities-legacy": { - "version": "1.1.4", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/character-reference-invalid": { - "version": "1.1.4", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/check-error": { "version": "2.1.3", "dev": true, @@ -4056,17 +4222,6 @@ "reusify": "^1.0.4" } }, - "node_modules/fault": { - "version": "1.0.4", - "license": "MIT", - "dependencies": { - "format": "^0.2.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/fdir": { "version": "6.5.0", "dev": true, @@ -4162,12 +4317,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/format": { - "version": "0.2.2", - "engines": { - "node": ">=0.4.x" - } - }, "node_modules/fraction.js": { "version": "5.3.4", "dev": true, @@ -4497,14 +4646,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/hast-util-parse-selector": { - "version": "2.2.5", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/hast-util-raw": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-9.1.0.tgz", @@ -4545,6 +4686,29 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/hast-util-to-html": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz", + "integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "ccount": "^2.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-whitespace": "^3.0.0", + "html-void-elements": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0", + "stringify-entities": "^4.0.0", + "zwitch": "^2.0.4" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/hast-util-to-jsx-runtime": { "version": "2.3.6", "license": "MIT", @@ -4614,59 +4778,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/hastscript": { - "version": "6.0.0", - "license": "MIT", - "dependencies": { - "@types/hast": "^2.0.0", - "comma-separated-tokens": "^1.0.0", - "hast-util-parse-selector": "^2.0.0", - "property-information": "^5.0.0", - "space-separated-tokens": "^1.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hastscript/node_modules/@types/hast": { - "version": "2.3.10", - "license": "MIT", - "dependencies": { - "@types/unist": "^2" - } - }, - "node_modules/hastscript/node_modules/@types/hast/node_modules/@types/unist": { - "version": "2.0.11", - "license": "MIT" - }, - "node_modules/hastscript/node_modules/comma-separated-tokens": { - "version": "1.0.8", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/hastscript/node_modules/property-information": { - "version": "5.6.0", - "license": "MIT", - "dependencies": { - "xtend": "^4.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/hastscript/node_modules/space-separated-tokens": { - "version": "1.1.5", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/hermes-estree": { "version": "0.25.1", "resolved": "https://registry.npmjs.org/hermes-estree/-/hermes-estree-0.25.1.tgz", @@ -4684,17 +4795,6 @@ "hermes-estree": "0.25.1" } }, - "node_modules/highlight.js": { - "version": "10.7.3", - "license": "BSD-3-Clause", - "engines": { - "node": "*" - } - }, - "node_modules/highlightjs-vue": { - "version": "1.0.0", - "license": "CC0-1.0" - }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -4792,26 +4892,6 @@ "version": "0.2.7", "license": "MIT" }, - "node_modules/is-alphabetical": { - "version": "1.0.4", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/is-alphanumerical": { - "version": "1.0.4", - "license": "MIT", - "dependencies": { - "is-alphabetical": "^1.0.0", - "is-decimal": "^1.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/is-binary-path": { "version": "2.1.0", "dev": true, @@ -4837,14 +4917,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-decimal": { - "version": "1.0.4", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/is-extglob": { "version": "2.1.1", "dev": true, @@ -4873,14 +4945,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-hexadecimal": { - "version": "1.0.4", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/is-number": { "version": "7.0.0", "dev": true, @@ -5124,17 +5188,11 @@ "dev": true, "license": "MIT" }, - "node_modules/lowlight": { - "version": "1.20.0", - "license": "MIT", - "dependencies": { - "fault": "^1.0.0", - "highlight.js": "~10.7.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } + "node_modules/lru_map": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.4.1.tgz", + "integrity": "sha512-I+lBvqMMFfqaV8CJCISjI3wbjmwVu/VyOoU7+qtu9d7ioW5klMgsTTiUOUp+DJvfTTzKXoPbyC6YfgkNcyPSOg==", + "license": "MIT" }, "node_modules/lru-cache": { "version": "5.1.1", @@ -6346,6 +6404,23 @@ "node": ">= 6" } }, + "node_modules/oniguruma-parser": { + "version": "0.12.2", + "resolved": "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.2.tgz", + "integrity": "sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==", + "license": "MIT" + }, + "node_modules/oniguruma-to-es": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.6.tgz", + "integrity": "sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==", + "license": "MIT", + "dependencies": { + "oniguruma-parser": "^0.12.2", + "regex": "^6.1.0", + "regex-recursion": "^6.0.2" + } + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", @@ -6412,22 +6487,6 @@ "dev": true, "license": "BlueOak-1.0.0" }, - "node_modules/parse-entities": { - "version": "2.0.0", - "license": "MIT", - "dependencies": { - "character-entities": "^1.0.0", - "character-entities-legacy": "^1.0.0", - "character-reference-invalid": "^1.0.0", - "is-alphanumerical": "^1.0.0", - "is-decimal": "^1.0.0", - "is-hexadecimal": "^1.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/parse5": { "version": "7.3.0", "license": "MIT", @@ -6765,13 +6824,6 @@ "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" } }, - "node_modules/prismjs": { - "version": "1.30.0", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/property-information": { "version": "7.1.0", "license": "MIT", @@ -6951,21 +7003,6 @@ } } }, - "node_modules/react-syntax-highlighter": { - "version": "15.6.6", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.3.1", - "highlight.js": "^10.4.1", - "highlightjs-vue": "^1.0.0", - "lowlight": "^1.17.0", - "prismjs": "^1.30.0", - "refractor": "^3.6.0" - }, - "peerDependencies": { - "react": ">= 0.14.0" - } - }, "node_modules/read-cache": { "version": "1.0.0", "dev": true, @@ -7010,26 +7047,30 @@ "node": ">=8" } }, - "node_modules/refractor": { - "version": "3.6.0", + "node_modules/regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/regex/-/regex-6.1.0.tgz", + "integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==", "license": "MIT", "dependencies": { - "hastscript": "^6.0.0", - "parse-entities": "^2.0.0", - "prismjs": "~1.27.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" + "regex-utilities": "^2.3.0" } }, - "node_modules/refractor/node_modules/prismjs": { - "version": "1.27.0", + "node_modules/regex-recursion": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz", + "integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==", "license": "MIT", - "engines": { - "node": ">=6" + "dependencies": { + "regex-utilities": "^2.3.0" } }, + "node_modules/regex-utilities": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz", + "integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==", + "license": "MIT" + }, "node_modules/rehype-harden": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/rehype-harden/-/rehype-harden-1.1.8.tgz", @@ -7365,6 +7406,25 @@ "node": ">=8" } }, + "node_modules/shiki": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-4.6.0.tgz", + "integrity": "sha512-imjLsVHgPuWhvpU3P+zOekvMYqnel7QmKsFC4Sn0fCuAvaaalBsxwKEsrU8Ko5BdFnZA6Go/8a0RzahS634UgA==", + "license": "MIT", + "dependencies": { + "@shikijs/core": "4.6.0", + "@shikijs/engine-javascript": "4.6.0", + "@shikijs/engine-oniguruma": "4.6.0", + "@shikijs/langs": "4.6.0", + "@shikijs/themes": "4.6.0", + "@shikijs/types": "4.6.0", + "@shikijs/vscode-textmate": "^10.1.0", + "@types/hast": "^3.0.5" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/siginfo": { "version": "2.0.0", "dev": true, @@ -8375,13 +8435,6 @@ "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", "license": "MIT" }, - "node_modules/xtend": { - "version": "4.0.2", - "license": "MIT", - "engines": { - "node": ">=0.4" - } - }, "node_modules/y18n": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", diff --git a/webui/package.json b/webui/package.json index 4bf433bab..236009a33 100644 --- a/webui/package.json +++ b/webui/package.json @@ -18,6 +18,8 @@ "lint": "cd .. && eslint --config webui/eslint.config.js webui/src webui/browser \"nanobot/channels/*/webui/**/*.{ts,tsx}\" \"nanobot/channels/*/tests/webui/**/*.{ts,tsx}\" \"scripts/check_client_import_boundaries*.mjs\" --max-warnings 0" }, "dependencies": { + "@pierre/diffs": "1.6.4", + "@pierre/highlights": "0.4.0", "@radix-ui/react-alert-dialog": "^1.1.4", "@radix-ui/react-dialog": "^1.1.4", "@radix-ui/react-dropdown-menu": "^2.1.4", @@ -41,7 +43,6 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-i18next": "^17.0.4", - "react-syntax-highlighter": "^15.6.1", "rehype-katex": "^7.0.1", "remark-breaks": "^4.0.0", "remark-cjk-friendly": "2.3.3", @@ -50,6 +51,7 @@ "remark-parse": "^11.0.0", "remend": "1.3.0", "saxes": "6.0.0", + "shiki": "4.6.0", "streamdown": "2.6.0", "tailwind-merge": "^2.6.0", "unified": "^11.0.5" @@ -68,7 +70,6 @@ "@types/qrcode": "^1.5.6", "@types/react": "^18.3.18", "@types/react-dom": "^18.3.5", - "@types/react-syntax-highlighter": "^15.5.13", "@vitejs/plugin-react": "^4.3.4", "@vitest/coverage-v8": "2.1.9", "autoprefixer": "^10.4.20", diff --git a/webui/src/components/CodeBlock.tsx b/webui/src/components/CodeBlock.tsx index af4538910..fff3bd712 100644 --- a/webui/src/components/CodeBlock.tsx +++ b/webui/src/components/CodeBlock.tsx @@ -1,4 +1,4 @@ -import { Suspense, lazy, memo, startTransition, useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react"; +import { Component, Suspense, lazy, memo, startTransition, useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react"; import { Check, Copy } from "lucide-react"; import { useTranslation } from "react-i18next"; @@ -6,6 +6,7 @@ import { useThemeValue } from "@/hooks/useTheme"; import { hasAnsi, parseAnsiSegments, stripAnsi } from "@/lib/ansi"; import { copyTextToClipboard } from "@/lib/clipboard"; import { normalizeCodeLanguage } from "@/lib/code-language"; +import { discardCodeHighlight } from "@/lib/code-highlight-cache"; import { cn } from "@/lib/utils"; interface CodeBlockProps { @@ -20,82 +21,41 @@ interface CodeBlockProps { viewportHighlight?: boolean; } -interface HighlightedCodeProps { - language?: string; - code: string; - chrome: "default" | "none"; - showLineNumbers: boolean; - wrapLongLines: boolean; - viewportHighlight: boolean; -} - const ANSI_LANGUAGES = new Set(["ansi", "ansi-output"]); const LazyHighlightedCode = lazy(async () => { - const [ - { default: SyntaxHighlighter }, - { ViewportCodeRows }, - { WrappedCodeRows }, - ] = await Promise.all([ - import("react-syntax-highlighter/dist/esm/prism-async-light"), - import("@/components/ViewportCodeRows"), - import("@/components/WrappedCodeRows"), - ]); - - return { - default({ - language, - code, - chrome, - showLineNumbers, - wrapLongLines, - viewportHighlight, - }: HighlightedCodeProps) { - return ( - - // during progressive highlighting must not reset horizontal scroll. - ...(viewportHighlight ? { overflow: "visible" } : {}), - }} - codeTagProps={{ - style: { - background: "transparent", - fontFamily: "inherit", - fontSize: "inherit", - ...(viewportHighlight ? { lineHeight: "inherit" } : {}), - }, - }} - lineNumberStyle={{ - minWidth: "2.6em", - paddingRight: "1.15rem", - color: "var(--code-comment)", - fontFamily: "inherit", - userSelect: "none", - }} - PreTag="pre" - showLineNumbers={showLineNumbers && !viewportHighlight} - wrapLongLines={wrapLongLines} - renderer={viewportHighlight ? props => - : showLineNumbers && wrapLongLines ? props => : undefined} - > - {code} - - ); - }, - }; + const { HighlightedCode } = await import("./HighlightedCode"); + return { default: HighlightedCode }; }); +class CodeHighlightBoundary extends Component<{ + code: string; + language: string; + fallback: ReactNode; + children: ReactNode; +}, { failed: boolean }> { + state = { failed: false }; + + static getDerivedStateFromError() { + return { failed: true }; + } + + componentDidCatch(error: Error) { + discardCodeHighlight(this.props.code, this.props.language); + console.warn("Code highlighting failed.", error); + } + + componentDidUpdate(previous: Readonly<{ code: string; language: string }>) { + if (this.state.failed && (previous.code !== this.props.code || previous.language !== this.props.language)) { + this.setState({ failed: false }); + } + } + + render() { + return this.state.failed ? this.props.fallback : this.props.children; + } +} + function renderPlainText(value: string): ReactNode { return value; } @@ -188,7 +148,7 @@ export const CodeBlock = memo(function CodeBlock({ const hasChrome = chrome === "default"; const syntaxLanguage = normalizeCodeLanguage(language); const useViewportHighlight = viewportHighlight && showLineNumbers && !wrapLongLines; - // Minified/very large previews must not monopolize the main thread in Prism. + // Minified/very large previews must not monopolize the main thread during highlighting. // Plain text still contains the entire preview, with normal selection and find. const withinHighlightBudget = useMemo(() => { if (!useViewportHighlight) return true; @@ -226,6 +186,8 @@ export const CodeBlock = memo(function CodeBlock({ }; }, [code, deferHighlight]); const copyLabel = copied ? t("code.copied") : t("code.copyAria"); + const plainBlock = ; const onCopy = useCallback(() => { void copyTextToClipboard(plainCode).then((ok) => { @@ -256,35 +218,19 @@ export const CodeBlock = memo(function CodeBlock({ compact={useViewportHighlight} /> ) : highlight && withinHighlightBudget && (!deferHighlight || highlightedSource === code) ? ( - + + - } - > - - - ) : ( - - )} + + + ) : plainBlock} {hasChrome ? ( @@ -330,72 +302,3 @@ function FileUnifiedDiff({ function countDiffLines(diff: RenderableFileDiff): number { return diff.hunks.reduce((total, hunk) => total + hunk.lines.length, 0); } - -function selectVisibleDiffLines( - diff: RenderableFileDiff, - lineLimit: number, - totalLineCount: number, -): VisibleDiff { - if (lineLimit >= totalLineCount) { - return { - hunks: diff.hunks.map((hunk, index) => ({ - hunk, - skippedBefore: index > 0 ? countSkippedUnchangedLines(diff.hunks[index - 1], hunk) : 0, - })), - hiddenLineCount: 0, - }; - } - - let remaining = Math.max(0, lineLimit); - const hunks: VisibleDiffHunk[] = []; - let previousHunk: RenderableFileDiffHunk | null = null; - for (const hunk of diff.hunks) { - if (remaining <= 0) break; - const skippedBefore = previousHunk ? countSkippedUnchangedLines(previousHunk, hunk) : 0; - if (hunk.lines.length <= remaining) { - hunks.push({ hunk, skippedBefore }); - remaining -= hunk.lines.length; - previousHunk = hunk; - continue; - } - hunks.push({ hunk: { ...hunk, lines: hunk.lines.slice(0, remaining) }, skippedBefore }); - remaining = 0; - previousHunk = hunk; - } - return { - hunks, - hiddenLineCount: Math.max(0, totalLineCount - lineLimit), - }; -} - -function countSkippedUnchangedLines( - previous: RenderableFileDiffHunk, - current: RenderableFileDiffHunk, -): number { - const oldGap = current.old_start - (previous.old_start + previous.old_lines); - const newGap = current.new_start - (previous.new_start + previous.new_lines); - return Math.max(0, oldGap, newGap); -} - -function DiffHunkGap({ lineCount }: { lineCount: number }) { - const { t } = useTranslation(); - return ( -
- - ... - - - {t("message.fileEditUnchangedLinesHidden", { - count: lineCount, - defaultValue: "{{count}} unchanged lines hidden", - })} - -
- ); -} diff --git a/webui/src/components/thread/activity/PierreFileDiff.tsx b/webui/src/components/thread/activity/PierreFileDiff.tsx new file mode 100644 index 000000000..a694ea7f8 --- /dev/null +++ b/webui/src/components/thread/activity/PierreFileDiff.tsx @@ -0,0 +1,159 @@ +import { FileDiff, getSharedHighlighter, getSingularPatch, registerCustomTheme, type FileDiffMetadata, type FileDiffOptions, type RenderRange } from "@pierre/diffs"; +import { WorkerPoolManager } from "@pierre/diffs/worker"; +import { isSupportedLanguage } from "@pierre/highlights"; +import { bundledLanguages } from "shiki/langs"; +import { useCallback, useContext, useLayoutEffect, useMemo, useRef } from "react"; +import { useTranslation } from "react-i18next"; + +import { useThemeValue } from "@/hooks/useTheme"; +import { CODE_TEXTMATE_THEME, CODE_THEME, CODE_THEME_NAME, codeHighlighterLanguage } from "@/lib/code-theme"; +import { DiffViewportContext } from "./DiffViewportContext"; +import type { DiffSyntaxHighlightProps } from "./DiffSyntaxHighlight"; +import { DIFF_GAP_HEIGHT, diffRenderWindow, diffRowOffsets } from "./diff-render-window"; +import { selectedDiffRows } from "./diff-selection"; + +const THEME = CODE_THEME_NAME; +const CACHE_ENTRIES = 16; +const CACHE_SOURCE_BYTES = 2 * 1024 * 1024; +const metadataCache = new Map(); +let sourceBytes = 0; +let revision = 0; +let pool: WorkerPoolManager | undefined; +let grammarPool: WorkerPoolManager | undefined; +let preparation: Promise | undefined; + +registerCustomTheme(THEME, async () => CODE_THEME, "zed"); +registerCustomTheme(THEME, async () => CODE_TEXTMATE_THEME, "textmate"); + +export function prepareDiffRenderer(): Promise { + return preparation ??= (async () => { + await getSharedHighlighter({ themes: [THEME], langs: ["text"], preferredHighlighter: "highlights" }); + pool = new WorkerPoolManager({ + // The zero-worker pool owns the bounded AST cache; Highlights shares its main-thread engine with code blocks. + workerFactory: () => { throw new Error("The Highlights cache does not create workers"); }, + poolSize: 0, + totalASTLRUCacheSize: CACHE_ENTRIES, + mainThreadMaxCharacters: Number.MAX_SAFE_INTEGER, + }, { theme: THEME, preferredHighlighter: "highlights", lineDiffType: "word" }); + })(); +} + +function getGrammarPool(): WorkerPoolManager { + return grammarPool ??= new WorkerPoolManager({ + workerFactory: () => new Worker(new URL("@pierre/diffs/worker/worker.js", import.meta.url), { type: "module" }), + poolSize: 1, totalASTLRUCacheSize: CACHE_ENTRIES, + }, { theme: THEME, preferredHighlighter: "shiki-js", lineDiffType: "word" }); +} + +export function getDiffMetadata(text: string, language: string): FileDiffMetadata { + const alias = codeHighlighterLanguage(language); + const lang = isSupportedLanguage(alias) || Object.hasOwn(bundledLanguages, alias) + ? alias as NonNullable : "text"; + const key = `${lang}\0${text}`; + const cached = metadataCache.get(key); + if (cached) { + metadataCache.delete(key); + metadataCache.set(key, cached); + return cached; + } + const metadata = getSingularPatch(text); + metadata.lang = lang; + const bytes = key.length * 2; + if (bytes <= CACHE_SOURCE_BYTES) { + while (metadataCache.size >= CACHE_ENTRIES || sourceBytes + bytes > CACHE_SOURCE_BYTES) { + const [oldKey, oldMetadata] = metadataCache.entries().next().value!; + metadataCache.delete(oldKey); + sourceBytes -= oldKey.length * 2; + pool?.evictDiffFromCache(oldMetadata.cacheKey!); + grammarPool?.evictDiffFromCache(oldMetadata.cacheKey!); + } + metadata.cacheKey = `nanobot-diff-${++revision}`; + metadataCache.set(key, metadata); + sourceBytes += bytes; + } + return metadata; +} + +export function PierreFileDiff({ text, language, diff, lineLimit }: DiffSyntaxHighlightProps) { + const theme = useThemeValue(); + const { t } = useTranslation(); + const viewport = useContext(DiffViewportContext); + const wrapperRef = useRef(null); + const instanceRef = useRef(); + const metadata = useMemo(() => getDiffMetadata(text, language), [text, language]); + const needsGrammar = !isSupportedLanguage(metadata.lang!); + const gapLabel = useCallback((count: number) => `… ${t("message.fileEditUnchangedLinesHidden", { count, defaultValue: "{{count}} unchanged lines hidden" })}`, [t]); + const options = useMemo>(() => ({ + theme: THEME, themeType: theme, preferredHighlighter: "highlights", diffStyle: "unified", diffIndicators: "classic", + disableFileHeader: true, lineDiffType: "word", + // Function separators disable Pierre's incremental row updates and destroy native selections. + hunkSeparators: "line-info", + onPostRender: (node, _instance, phase) => { + if (phase === "unmount") return; + for (const gap of node.shadowRoot!.querySelectorAll("[data-separator]")) { + const nextIndex = Number(gap.nextElementSibling?.getAttribute("data-line-index")?.split(",")[0]); + const hunk = metadata.hunks.find(item => item.unifiedLineStart === nextIndex); + const label = gap.querySelector("[data-unmodified-lines]"); + if (!hunk || !label) continue; + const text = gapLabel(hunk.collapsedBefore); + if (label.textContent !== text) label.textContent = text; + if (gap.closest("[data-gutter]")) label.dataset.testid = "file-edit-diff-hunk-gap"; + } + }, + unsafeCSS: `:host, pre, code { font: inherit; } pre { padding-block: 0; } [data-line], [data-column-number] { padding-block: 1px; } [data-separator] { height: ${DIFF_GAP_HEIGHT}px; margin: 0; padding: 0; } [data-separator-wrapper], [data-separator-content] { background: transparent; color: hsl(var(--muted-foreground)); } [data-separator-wrapper] { padding-inline: 8px; background: hsl(var(--muted) / .35); font-size: 11px; } [data-separator-first], [data-separator-last] { display: none; }`, + }), [theme, gapLabel, metadata]); + + useLayoutEffect(() => { + const wrapper = wrapperRef.current!; + const instance = new FileDiff({ theme: THEME, preferredHighlighter: "highlights" }, needsGrammar ? getGrammarPool() : pool); + instanceRef.current = instance; + return () => { instance.cleanUp(); instanceRef.current = undefined; wrapper.replaceChildren(); }; + }, [needsGrammar]); + + useLayoutEffect(() => { + const wrapper = wrapperRef.current!; + const instance = instanceRef.current!; + instance.setOptions(options); + const scroller = viewport?.scroller.current; + const eventTarget = scroller ?? window; + let frame = 0; + let previous: RenderRange | undefined; + let forceRender = true; + const render = () => { + frame = 0; + const lineHeight = Math.floor((parseFloat(getComputedStyle(wrapper).lineHeight) + 2) * 64) / 64; + const offsets = diffRowOffsets(diff, lineLimit, lineHeight); + const rootRect = scroller?.getBoundingClientRect(); + const wrapperTop = wrapper.getBoundingClientRect().top; + const top = (rootRect?.top ?? 0) - wrapperTop; + const height = rootRect?.height ?? window.innerHeight; + const range = diffRenderWindow(diff, offsets, top - height, top + height * 2, lineHeight, selectedDiffRows(wrapper, metadata)); + if (!forceRender && previous && Object.keys(range).every(key => range[key as keyof RenderRange] === previous![key as keyof RenderRange])) return; + previous = range; + instance.render({ fileDiff: metadata, containerWrapper: wrapper, renderRange: range, forceRender }); + forceRender = false; + }; + const schedule = () => { if (!frame) frame = requestAnimationFrame(render); }; + // This observer projects a read-only window; ThreadCameraController remains the sole scroll writer. + const resize = new ResizeObserver(schedule); + resize.observe(wrapper); + if (scroller) resize.observe(scroller); + if (viewport?.content.current) resize.observe(viewport.content.current); + const typography = new MutationObserver(schedule); + typography.observe(document.documentElement, { attributes: true, attributeFilter: ["data-reading-text-size"] }); + eventTarget.addEventListener("scroll", schedule, { passive: true }); + document.addEventListener("selectionchange", schedule); + window.addEventListener("resize", schedule); + render(); + return () => { + cancelAnimationFrame(frame); + resize.disconnect(); + typography.disconnect(); + eventTarget.removeEventListener("scroll", schedule); + document.removeEventListener("selectionchange", schedule); + window.removeEventListener("resize", schedule); + }; + }, [diff, lineLimit, metadata, options, viewport]); + + return
; +} diff --git a/webui/src/components/thread/activity/diff-render-window.ts b/webui/src/components/thread/activity/diff-render-window.ts new file mode 100644 index 000000000..77f42caca --- /dev/null +++ b/webui/src/components/thread/activity/diff-render-window.ts @@ -0,0 +1,50 @@ +import type { RenderableFileDiff } from "@/lib/file-diff"; + +export const DIFF_GAP_HEIGHT = 26; +const ROW_BATCH = 40; + +export function diffRowOffsets(diff: RenderableFileDiff, lineLimit: number, lineHeight: number): number[] { + const offsets: number[] = []; + let top = 0; + for (const [index, hunk] of diff.hunks.entries()) { + if (offsets.length >= lineLimit) break; + const previous = diff.hunks[index - 1]; + if (previous && (hunk.old_start > previous.old_start + previous.old_lines || hunk.new_start > previous.new_start + previous.new_lines)) top += DIFF_GAP_HEIGHT; + for (let line = 0; line < hunk.lines.length; line++) { + if (offsets.length >= lineLimit) break; + offsets.push(top); + top += lineHeight; + } + } + offsets.push(top); + return offsets; +} + +export function diffRenderWindow(diff: RenderableFileDiff, offsets: number[], top: number, bottom: number, lineHeight: number, selected?: readonly [number, number]) { + const count = offsets.length - 1; + if (count <= 160) return { startingLine: 0, totalLines: count, bufferBefore: 0, bufferAfter: 0 }; + let start = offsets.findIndex((offset) => offset >= top); + if (start < 0) start = count - 1; + // Keep both edges together, with one extra batch for the rounded-down start. + const capacity = Math.min(count, (Math.ceil((bottom - top) / lineHeight / ROW_BATCH) + 1) * ROW_BATCH); + start = Math.min(count - capacity, Math.max(0, Math.floor((start - 1) / ROW_BATCH) * ROW_BATCH)); + let end = start + capacity; + // Retain only the active selection's rows as the viewport keeps moving. Clearing it + // returns to the ordinary bounded window; do not freeze rendering or accumulate old windows. + if (selected) { + start = Math.min(start, selected[0]); + end = Math.min(count, Math.max(end, selected[1])); + } + let before = offsets[start]; + let after = offsets[count] - offsets[end]; + // A separator is rendered with its first row, not with the preceding window. + let row = 0; + for (const [index, hunk] of diff.hunks.entries()) { + const previous = diff.hunks[index - 1]; + const gap = previous && (hunk.old_start > previous.old_start + previous.old_lines || hunk.new_start > previous.new_start + previous.new_lines); + if (gap && row === start) before -= DIFF_GAP_HEIGHT; + if (gap && row === end) after += DIFF_GAP_HEIGHT; + row += hunk.lines.length; + } + return { startingLine: start, totalLines: end - start, bufferBefore: before, bufferAfter: after }; +} diff --git a/webui/src/components/thread/activity/diff-selection.ts b/webui/src/components/thread/activity/diff-selection.ts new file mode 100644 index 000000000..8049978fc --- /dev/null +++ b/webui/src/components/thread/activity/diff-selection.ts @@ -0,0 +1,40 @@ +import type { FileDiffMetadata } from "@pierre/diffs"; + +// Native ranges must be read inside Pierre's shadow tree, not from retargeted host endpoints. +export function selectedDiffRows(wrapper: HTMLElement, metadata: FileDiffMetadata): readonly [number, number] | undefined { + const host = wrapper.querySelector("diffs-container"); + const root = host?.shadowRoot; + const selection = document.getSelection(); + if (!root || !selection) return; + const shadowSelection = (root as ShadowRoot & { getSelection?(): Selection | null }).getSelection?.(); + const ranges = typeof selection.getComposedRanges === "function" + ? selection.getComposedRanges({ shadowRoots: [root] }) + : shadowSelection?.rangeCount ? [shadowSelection.getRangeAt(0)] : selection.rangeCount ? [selection.getRangeAt(0)] : []; + const selected = ranges[0]; + // Chromium can report document Selection.isCollapsed=true for a nonempty shadow selection. + if (!selected || (selected.startContainer === selected.endContainer && selected.startOffset === selected.endOffset)) return; + const startsInside = selected.startContainer.getRootNode() === root; + const endsInside = selected.endContainer.getRootNode() === root; + if (!startsInside && !endsInside && (!selection.rangeCount || !selection.getRangeAt(0).intersectsNode(host))) return; + const localRange = document.createRange(); + localRange.selectNodeContents(root); + if (startsInside) localRange.setStart(selected.startContainer, selected.startOffset); + if (endsInside) localRange.setEnd(selected.endContainer, selected.endOffset); + let first: number | undefined; + let last: number | undefined; + for (const row of root.querySelectorAll("[data-code] [data-line][data-line-index]")) { + if (!localRange.intersectsNode(row)) continue; + const index = Number(row.dataset.lineIndex!.split(",")[0]); + let renderedStart = 0; + for (const hunk of metadata.hunks) { + if (index >= hunk.unifiedLineStart && index < hunk.unifiedLineStart + hunk.unifiedLineCount) { + const renderedIndex = renderedStart + index - hunk.unifiedLineStart; + first = first === undefined ? renderedIndex : Math.min(first, renderedIndex); + last = last === undefined ? renderedIndex + 1 : Math.max(last, renderedIndex + 1); + break; + } + renderedStart += hunk.unifiedLineCount; + } + } + return first === undefined || last === undefined ? undefined : [first, last]; +} diff --git a/webui/src/components/workbench/PaneWorkbench.tsx b/webui/src/components/workbench/PaneWorkbench.tsx index d51fc8cb2..373cd405f 100644 --- a/webui/src/components/workbench/PaneWorkbench.tsx +++ b/webui/src/components/workbench/PaneWorkbench.tsx @@ -205,6 +205,7 @@ export function PaneWorkbench({ }: PaneWorkbenchProps) { const { t } = useTranslation(); const compact = useMediaQuery("(max-width: 767px)"); + const sharedComposer = chrome && panes.length > 1; const effectiveLayout = layout; const [headerPortalTarget, setHeaderPortalTarget] = useState(null); const [composerPortalTarget, setComposerPortalTarget] = useState(null); @@ -728,7 +729,7 @@ export function PaneWorkbench({ active, multiplePanes: displayedPanes.length > 1, headerPortalTarget: chrome && displayedPanes.length > 1 ? headerPortalTarget : undefined, - composerPortalTarget: chrome ? composerPortalTarget : undefined, + composerPortalTarget: sharedComposer ? composerPortalTarget : undefined, navigationFrame: displayedPanes.length === 1 ? navigationFrame : undefined, headerActions, })} @@ -827,7 +828,7 @@ export function PaneWorkbench({ ) : null}
- {chrome ? ( + {sharedComposer ? (