remove layout jank

This commit is contained in:
Nate Kelley 2025-04-10 13:45:23 -06:00
parent 8e4e423f1a
commit d99f61c289
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
5 changed files with 87 additions and 263 deletions

219
web/package-lock.json generated
View File

@ -78,7 +78,6 @@
"react-dom": "^18",
"react-hotkeys-hook": "^4.6.1",
"react-markdown": "^10.1.0",
"react-scroll-to-bottom": "^4.2.0",
"react-syntax-highlighter": "^15.6.1",
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.1",
@ -2050,19 +2049,6 @@
"node": ">=6.9.0"
}
},
"node_modules/@babel/runtime-corejs3": {
"version": "7.27.0",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.27.0.tgz",
"integrity": "sha512-UWjX6t+v+0ckwZ50Y5ShZLnlk95pP5MyW/pon9tiYzl3+18pkTHTFNTKr7rQbfRXPkowt2QAn30o1b6oswszew==",
"license": "MIT",
"dependencies": {
"core-js-pure": "^3.30.2",
"regenerator-runtime": "^0.14.0"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/template": {
"version": "7.26.9",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.26.9.tgz",
@ -2266,123 +2252,6 @@
"tslib": "^2.4.0"
}
},
"node_modules/@emotion/babel-plugin": {
"version": "11.13.5",
"resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.13.5.tgz",
"integrity": "sha512-pxHCpT2ex+0q+HH91/zsdHkw/lXd468DIN2zvfvLtPKLLMo6gQj7oLObq8PhkrxOZb/gGCq03S3Z7PDhS8pduQ==",
"license": "MIT",
"dependencies": {
"@babel/helper-module-imports": "^7.16.7",
"@babel/runtime": "^7.18.3",
"@emotion/hash": "^0.9.2",
"@emotion/memoize": "^0.9.0",
"@emotion/serialize": "^1.3.3",
"babel-plugin-macros": "^3.1.0",
"convert-source-map": "^1.5.0",
"escape-string-regexp": "^4.0.0",
"find-root": "^1.1.0",
"source-map": "^0.5.7",
"stylis": "4.2.0"
}
},
"node_modules/@emotion/babel-plugin/node_modules/convert-source-map": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz",
"integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==",
"license": "MIT"
},
"node_modules/@emotion/babel-plugin/node_modules/source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==",
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/@emotion/cache": {
"version": "11.14.0",
"resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.14.0.tgz",
"integrity": "sha512-L/B1lc/TViYk4DcpGxtAVbx0ZyiKM5ktoIyafGkH6zg/tj+mA+NE//aPYKG0k8kCHSHVJrpLpcAlOBEXQ3SavA==",
"license": "MIT",
"dependencies": {
"@emotion/memoize": "^0.9.0",
"@emotion/sheet": "^1.4.0",
"@emotion/utils": "^1.4.2",
"@emotion/weak-memoize": "^0.4.0",
"stylis": "4.2.0"
}
},
"node_modules/@emotion/css": {
"version": "11.1.3",
"resolved": "https://registry.npmjs.org/@emotion/css/-/css-11.1.3.tgz",
"integrity": "sha512-RSQP59qtCNTf5NWD6xM08xsQdCZmVYnX/panPYvB6LQAPKQB6GL49Njf0EMbS3CyDtrlWsBcmqBtysFvfWT3rA==",
"license": "MIT",
"dependencies": {
"@emotion/babel-plugin": "^11.0.0",
"@emotion/cache": "^11.1.3",
"@emotion/serialize": "^1.0.0",
"@emotion/sheet": "^1.0.0",
"@emotion/utils": "^1.0.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
},
"peerDependenciesMeta": {
"@babel/core": {
"optional": true
}
}
},
"node_modules/@emotion/hash": {
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.2.tgz",
"integrity": "sha512-MyqliTZGuOm3+5ZRSaaBGP3USLw6+EGykkwZns2EPC5g8jJ4z9OrdZY9apkl3+UP9+sdz76YYkwCKP5gh8iY3g==",
"license": "MIT"
},
"node_modules/@emotion/memoize": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.9.0.tgz",
"integrity": "sha512-30FAj7/EoJ5mwVPOWhAyCX+FPfMDrVecJAM+Iw9NRoSl4BBAQeqj4cApHHUXOVvIPgLVDsCFoz/hGD+5QQD1GQ==",
"license": "MIT"
},
"node_modules/@emotion/serialize": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.3.3.tgz",
"integrity": "sha512-EISGqt7sSNWHGI76hC7x1CksiXPahbxEOrC5RjmFRJTqLyEK9/9hZvBbiYn70dw4wuwMKiEMCUlR6ZXTSWQqxA==",
"license": "MIT",
"dependencies": {
"@emotion/hash": "^0.9.2",
"@emotion/memoize": "^0.9.0",
"@emotion/unitless": "^0.10.0",
"@emotion/utils": "^1.4.2",
"csstype": "^3.0.2"
}
},
"node_modules/@emotion/sheet": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.4.0.tgz",
"integrity": "sha512-fTBW9/8r2w3dXWYM4HCB1Rdp8NLibOw2+XELH5m5+AkWiL/KqYX6dc0kKYlaYyKjrQ6ds33MCdMPEwgs2z1rqg==",
"license": "MIT"
},
"node_modules/@emotion/unitless": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.10.0.tgz",
"integrity": "sha512-dFoMUuQA20zvtVTuxZww6OHoJYgrzfKM1t52mVySDJnMSEa08ruEvdYQbhvyu6soU+NeLVd3yKfTfT0NeV6qGg==",
"license": "MIT"
},
"node_modules/@emotion/utils": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.4.2.tgz",
"integrity": "sha512-3vLclRofFziIa3J2wDh9jjbkUz9qk5Vi3IZ/FSTKViB0k+ef0fPV7dYrUIugbgupYDx7v9ud/SjrtEP8Y4xLoA==",
"license": "MIT"
},
"node_modules/@emotion/weak-memoize": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.4.0.tgz",
"integrity": "sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==",
"license": "MIT"
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.25.2",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.2.tgz",
@ -7604,6 +7473,7 @@
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.2.tgz",
"integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==",
"devOptional": true,
"license": "MIT"
},
"node_modules/@types/phoenix": {
@ -9116,6 +8986,8 @@
"resolved": "https://registry.npmjs.org/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz",
"integrity": "sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==",
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"@babel/runtime": "^7.12.5",
"cosmiconfig": "^7.0.0",
@ -9975,12 +9847,6 @@
"url": "https://polar.sh/cva"
}
},
"node_modules/classnames": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz",
"integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==",
"license": "MIT"
},
"node_modules/clean-css": {
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.3.tgz",
@ -10277,6 +10143,7 @@
"version": "3.41.0",
"resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.41.0.tgz",
"integrity": "sha512-71Gzp96T9YPk63aUvE5Q5qP+DryB4ZloUZPSOebGM88VNw8VNfvdA7z6kGA8iGOTEzAomsRidp4jXSmUIJsL+Q==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"funding": {
@ -10295,6 +10162,7 @@
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.1.0.tgz",
"integrity": "sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==",
"devOptional": true,
"license": "MIT",
"dependencies": {
"@types/parse-json": "^4.0.0",
@ -11451,6 +11319,7 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=10"
@ -12326,12 +12195,6 @@
"url": "https://github.com/avajs/find-cache-dir?sponsor=1"
}
},
"node_modules/find-root": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz",
"integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==",
"license": "MIT"
},
"node_modules/find-up": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
@ -13475,6 +13338,7 @@
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
"integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==",
"devOptional": true,
"license": "MIT",
"dependencies": {
"parent-module": "^1.0.0",
@ -15909,12 +15773,6 @@
"node": ">= 0.4"
}
},
"node_modules/math-random": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/math-random/-/math-random-2.0.1.tgz",
"integrity": "sha512-oIEbWiVDxDpl5tIF4S6zYS9JExhh3bun3uLb3YAinHPTlRtW4g1S66LtJrJ4Npq8dgIa8CLK5iPVah5n4n0s2w==",
"license": "CC0-1.0"
},
"node_modules/md5.js": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
@ -17727,6 +17585,7 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
"integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
"devOptional": true,
"license": "MIT",
"dependencies": {
"callsites": "^3.0.0"
@ -17870,6 +17729,7 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
"devOptional": true,
"license": "MIT",
"engines": {
"node": ">=8"
@ -18874,53 +18734,6 @@
}
}
},
"node_modules/react-scroll-to-bottom": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/react-scroll-to-bottom/-/react-scroll-to-bottom-4.2.0.tgz",
"integrity": "sha512-1WweuumQc5JLzeAR81ykRdK/cEv9NlCPEm4vSwOGN1qS2qlpGVTyMgdI8Y7ZmaqRmzYBGV5/xPuJQtekYzQFGg==",
"license": "MIT",
"dependencies": {
"@babel/runtime-corejs3": "^7.15.4",
"@emotion/css": "11.1.3",
"classnames": "2.3.1",
"core-js": "3.18.3",
"math-random": "2.0.1",
"prop-types": "15.7.2",
"simple-update-in": "2.2.0"
},
"peerDependencies": {
"react": ">= 16.8.6"
}
},
"node_modules/react-scroll-to-bottom/node_modules/core-js": {
"version": "3.18.3",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.18.3.tgz",
"integrity": "sha512-tReEhtMReZaPFVw7dajMx0vlsz3oOb8ajgPoHVYGxr8ErnZ6PcYEvvmjGmXlfpnxpkYSdOQttjB+MvVbCGfvLw==",
"deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.",
"hasInstallScript": true,
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
}
},
"node_modules/react-scroll-to-bottom/node_modules/prop-types": {
"version": "15.7.2",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
"integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==",
"license": "MIT",
"dependencies": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.8.1"
}
},
"node_modules/react-scroll-to-bottom/node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
"license": "MIT"
},
"node_modules/react-style-singleton": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.3.tgz",
@ -19497,6 +19310,7 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"devOptional": true,
"license": "MIT",
"engines": {
"node": ">=4"
@ -20142,12 +19956,6 @@
"license": "MIT",
"optional": true
},
"node_modules/simple-update-in": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.2.0.tgz",
"integrity": "sha512-FrW41lLiOs82jKxwq39UrE1HDAHOvirKWk4Nv8tqnFFFknVbTxcHZzDS4vt02qqdU/5+KNsQHWzhKHznDBmrww==",
"license": "MIT"
},
"node_modules/sirv": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz",
@ -20735,12 +20543,6 @@
}
}
},
"node_modules/stylis": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz",
"integrity": "sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==",
"license": "MIT"
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@ -22473,6 +22275,7 @@
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz",
"integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==",
"devOptional": true,
"license": "ISC",
"engines": {
"node": ">= 6"

View File

@ -4,7 +4,6 @@ import type { Meta, StoryObj } from '@storybook/react';
import { StreamingMessageCode } from './StreamingMessageCode';
import type { FileType } from '@/api/asset_interfaces';
import { Button } from '@/components/ui/buttons';
import { fn } from '@storybook/test';
import React from 'react';
const meta: Meta<typeof StreamingMessageCode> = {
@ -23,9 +22,60 @@ const sampleYaml = `apiVersion: v1
kind: ConfigMap
metadata:
name: my-config
namespace: production
labels:
app: my-application
environment: production
team: platform
annotations:
description: "Production configuration for my-application"
lastModified: "2024-03-20"
version: "1.0.0"
data:
key1: value1
key2: value2
# Database Configuration
database:
host: db.example.com
port: "5432"
name: production_db
max_connections: "100"
idle_timeout: "300"
connection_timeout: "30"
# Cache Configuration
redis:
host: redis.example.com
port: "6379"
max_memory: "2gb"
eviction_policy: "allkeys-lru"
databases: "16"
# Application Settings
app_settings:
log_level: "INFO"
debug_mode: "false"
max_threads: "50"
worker_processes: "4"
request_timeout: "30s"
session_timeout: "24h"
# Feature Flags
features:
enable_new_ui: "true"
enable_analytics: "true"
enable_caching: "true"
enable_rate_limiting: "true"
beta_features: "false"
# API Configuration
api:
version: "v2"
base_url: "https://api.example.com"
rate_limit: "1000"
timeout: "5s"
retry_attempts: "3"
retry_delay: "1s"
`;
const baseProps = {
@ -125,7 +175,7 @@ export const InteractiveStreaming: Story = {
}
return prev + 1;
});
}, 500);
}, 50);
};
return (

View File

@ -3,12 +3,12 @@
import { BusterChatMessageReasoning_file } from '@/api/asset_interfaces';
import { SyntaxHighlighterLightTheme } from '@/components/ui/typography/AppCodeBlock';
import React, { useEffect, useMemo, useState } from 'react';
import { AnimatePresence, motion } from 'framer-motion';
import { Text } from '@/components/ui/typography';
import pluralize from 'pluralize';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { TextAndVersionPill } from '../../typography/TextAndVersionPill';
import { FileCard } from '../../card/FileCard';
import { cn } from '@/lib/classMerge';
const style = SyntaxHighlighterLightTheme;
@ -19,39 +19,12 @@ type LineSegment = {
numberOfLines?: number;
};
const containerVariants = {
hidden: { opacity: 0 },
show: {
opacity: 1,
transition: {
opacity: { duration: 0.12 },
staggerChildren: 0.08
}
}
};
const itemVariants = {
hidden: { opacity: 0, x: 0 },
show: { opacity: 1, x: 0 }
};
export const StreamingMessageCode: React.FC<
BusterChatMessageReasoning_file & {
isCompletedStream: boolean;
buttons?: React.ReactNode;
}
> = ({
status,
isCompletedStream,
file,
id,
file_name,
version_number,
file_type,
version_id,
buttons
}) => {
const showLoader = status === 'loading' && !isCompletedStream;
> = ({ status, isCompletedStream, file, file_name, version_number, buttons }) => {
const { text = '', modified } = file;
const [lineSegments, setLineSegments] = useState<LineSegment[]>([]);
@ -124,26 +97,22 @@ export const StreamingMessageCode: React.FC<
[file_name, version_number]
)}
headerButtons={buttons}>
<AnimatePresence initial={!isCompletedStream}>
<motion.div
className="w-full overflow-x-auto p-3"
variants={containerVariants}
initial="hidden"
animate="show">
{lineSegments.map((segment, index) => (
<motion.div
key={`${segment.lineNumber}-${index}`}
variants={itemVariants}
className="line-number pr-1">
{segment.type === 'text' ? (
<MemoizedSyntaxHighlighter lineNumber={segment.lineNumber} text={segment.content} />
) : (
<HiddenSection numberOfLinesUnmodified={segment.numberOfLines || 0} />
)}
</motion.div>
))}
</motion.div>
</AnimatePresence>
<div className="w-full overflow-x-auto p-3">
{lineSegments.map((segment, index) => (
<div
key={`${segment.lineNumber}-${index}`}
className={cn(
'line-number pr-1',
!isCompletedStream && 'animate-in fade-in duration-700'
)}>
{segment.type === 'text' ? (
<MemoizedSyntaxHighlighter lineNumber={segment.lineNumber} text={segment.content} />
) : (
<HiddenSection numberOfLinesUnmodified={segment.numberOfLines || 0} />
)}
</div>
))}
</div>
</FileCard>
);
};

View File

@ -4,7 +4,6 @@ import type {
BusterChatMessageReasoning_files,
BusterChatMessage
} from '@/api/asset_interfaces/chat';
import { BarContainer } from '../BarContainer';
import { ReasoningMessage_File } from './ReasoningMessageFile';
import { useGetChatMessage } from '@/api/buster_rest/chats';

View File

@ -8,6 +8,7 @@ import { BusterChatResponseMessage_file } from '@/api/asset_interfaces/chat';
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
import { useGetFileLink } from '@/context/Assets/useGetFileLink';
import { useChatLayoutContextSelector } from '../ChatLayoutContext';
import { usePrevious } from '@/hooks';
export const useAutoChangeLayout = ({
lastMessageId,
@ -31,6 +32,7 @@ export const useAutoChangeLayout = ({
const { getFileLinkMeta } = useGetFileLink();
const isCompletedStream = useGetChatMessage(lastMessageId, (x) => x?.isCompletedStream);
const previousIsCompletedStream = usePrevious(isCompletedStream);
const hasReasoning = !!reasoningMessagesLength;
@ -47,7 +49,8 @@ export const useAutoChangeLayout = ({
previousLastMessageId.current = lastMessageId;
}
if (isCompletedStream) {
//we check for false because on initial load, the isCompletedStream is false
if (isCompletedStream && previousIsCompletedStream === false) {
const chatMessage = getChatMessageMemoized(lastMessageId);
const lastFileId = findLast(chatMessage?.response_message_ids, (id) => {
const responseMessage = chatMessage?.response_messages[id];