File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed
features/sessions/components/session-update Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 11import { Box } from "@radix-ui/themes" ;
2+ import { useEffect , useRef } from "react" ;
23import ReactMarkdown from "react-markdown" ;
34import remarkGfm from "remark-gfm" ;
45
6+ const planScrollPosition = new Map < string , number > ( ) ;
7+
58interface PlanContentProps {
9+ id : string ;
610 plan : string ;
711}
812
9- export function PlanContent ( { plan } : PlanContentProps ) {
13+ export function PlanContent ( { id, plan } : PlanContentProps ) {
14+ const scrollRef = useRef < HTMLDivElement > ( null ) ;
15+
16+ useEffect ( ( ) => {
17+ const el = scrollRef . current ;
18+ if ( ! el ) return ;
19+
20+ const position = planScrollPosition . get ( id ) ;
21+ if ( position !== undefined ) {
22+ el . scrollTop = position ;
23+ }
24+
25+ const handleScroll = ( ) => {
26+ planScrollPosition . set ( id , el . scrollTop ) ;
27+ } ;
28+
29+ el . addEventListener ( "scroll" , handleScroll , { passive : true } ) ;
30+
31+ return ( ) => {
32+ el . removeEventListener ( "scroll" , handleScroll ) ;
33+ } ;
34+ } , [ id ] ) ;
35+
1036 return (
11- < Box className = "max-h-[50vh] max-w-[750px] overflow-y-auto rounded-lg border-2 border-blue-6 bg-blue-2 p-4" >
37+ < Box
38+ ref = { scrollRef }
39+ className = "max-h-[50vh] max-w-[750px] overflow-y-auto rounded-lg border-2 border-blue-6 bg-blue-2 p-4"
40+ >
1241 < Box className = "plan-markdown text-blue-12" >
1342 < ReactMarkdown remarkPlugins = { [ remarkGfm ] } > { plan } </ ReactMarkdown >
1443 </ Box >
Original file line number Diff line number Diff line change @@ -40,7 +40,9 @@ export function PlanApprovalView({
4040
4141 return (
4242 < Box className = "my-3" >
43- { showPlanContent && planText && < PlanContent plan = { planText } /> }
43+ { showPlanContent && planText && (
44+ < PlanContent id = { toolCall . toolCallId } plan = { planText } />
45+ ) }
4446
4547 { showResult && (
4648 < Flex align = "center" gap = "2" className = "px-1" >
You can’t perform that action at this time.
0 commit comments