From ffdca782ec728a8ab0af5dee1b918dcd33fa9f2d Mon Sep 17 00:00:00 2001 From: dawn <90008@klbr.net> Date: Tue, 17 Nov 2026 18:24:21 +0300 Subject: [PATCH] web: draw only the chat rows near the view, with tanstack virtual-core Signed-off-by: dawn <90008@klbr.net> --- nix/packages/web.nix | 2 +- web/package-lock.json | 11 + web/package.json | 1 + web/src/lib/chat/Chat.svelte | 952 ++++++++++++++++++----------- web/src/lib/chat/virtual.svelte.ts | 70 +++ 5 files changed, 663 insertions(+), 373 deletions(-) create mode 100644 web/src/lib/chat/virtual.svelte.ts diff --git a/nix/packages/web.nix b/nix/packages/web.nix index 355174ee0..a318ac3cf 100644 --- a/nix/packages/web.nix +++ b/nix/packages/web.nix @@ -19,7 +19,7 @@ buildNpmPackage { ../../web/src ]; }; - npmDepsHash = "sha256-YHTbHf+fDnek4B+0FCzbjF0E4DWh0PpDxYvz45sasxs="; + npmDepsHash = "sha256-OjQgdzCrG5A1ZHYRoRt8/CiXYp9Yv9Ujia6m5btIIxE="; installPhase = '' runHook preInstall cp -R dist $out diff --git a/web/package-lock.json b/web/package-lock.json index 302e5b330..d5b07695f 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -8,6 +8,7 @@ "dependencies": { "@lobehub/icons-static-svg": "^1.102.0", "@pierre/diffs": "^1.6.1", + "@tanstack/virtual-core": "3.19.11", "@xterm/addon-fit": "^0.11.0", "@xterm/addon-web-links": "^0.12.0", "@xterm/addon-webgl": "0.19.0", @@ -653,6 +654,16 @@ "vite": "^8.0.0-beta.7 || ^8.0.0" } }, + "node_modules/@tanstack/virtual-core": { + "version": "3.19.11", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.19.11.tgz", + "integrity": "sha512-/5iHb0RHBvj8Di59FDs4ESNm45jls33aZAi4zccVXZjc/6ZvwQP6nzEYeT6weXjTf9E6/vrp2JhYWRyO+ZP13A==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, "node_modules/@tsconfig/svelte": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-5.0.8.tgz", diff --git a/web/package.json b/web/package.json index 99c50860c..18b4ab4e2 100644 --- a/web/package.json +++ b/web/package.json @@ -26,6 +26,7 @@ "dependencies": { "@lobehub/icons-static-svg": "^1.102.0", "@pierre/diffs": "^1.6.1", + "@tanstack/virtual-core": "3.19.11", "@xterm/addon-fit": "^0.11.0", "@xterm/addon-web-links": "^0.12.0", "@xterm/addon-webgl": "0.19.0", diff --git a/web/src/lib/chat/Chat.svelte b/web/src/lib/chat/Chat.svelte index b11591bda..7f6730383 100644 --- a/web/src/lib/chat/Chat.svelte +++ b/web/src/lib/chat/Chat.svelte @@ -1,8 +1,9 @@