@@ -142,6 +142,7 @@ export default function SessionView(props: SessionViewProps) {
142142 const [ agentOptions , setAgentOptions ] = createSignal < Agent [ ] > ( [ ] ) ;
143143 const [ autoScrollEnabled , setAutoScrollEnabled ] = createSignal ( false ) ;
144144 const [ scrollOnNextUpdate , setScrollOnNextUpdate ] = createSignal ( false ) ;
145+ const [ unreadCount , setUnreadCount ] = createSignal ( 0 ) ;
145146
146147 const COMMAND_ARGS_RE = / \$ ( A R G U M E N T S | \d + ) / i;
147148
@@ -525,6 +526,28 @@ export default function SessionView(props: SessionViewProps) {
525526 ) ,
526527 ) ;
527528
529+ createEffect (
530+ on (
531+ ( ) => props . messages . length ,
532+ ( current , previous ) => {
533+ if ( previous == null ) return ;
534+ if ( current < previous ) {
535+ setUnreadCount ( 0 ) ;
536+ return ;
537+ }
538+ if ( current > previous && ! autoScrollEnabled ( ) ) {
539+ setUnreadCount ( ( count ) => count + ( current - previous ) ) ;
540+ }
541+ } ,
542+ ) ,
543+ ) ;
544+
545+ createEffect ( ( ) => {
546+ if ( autoScrollEnabled ( ) ) {
547+ setUnreadCount ( 0 ) ;
548+ }
549+ } ) ;
550+
528551 const triggerFlyout = (
529552 sourceEl : Element | null ,
530553 targetId : string ,
@@ -1136,6 +1159,12 @@ export default function SessionView(props: SessionViewProps) {
11361159 } ) ;
11371160 } ;
11381161
1162+ const jumpToLatest = ( ) => {
1163+ setScrollOnNextUpdate ( true ) ;
1164+ scrollToLatest ( "smooth" ) ;
1165+ setUnreadCount ( 0 ) ;
1166+ } ;
1167+
11391168 return (
11401169 < div class = "h-screen flex flex-col bg-gray-1 text-gray-12 relative pb-16 md:pb-12" >
11411170 < header class = "h-16 border-b border-gray-6 flex items-center justify-between px-6 bg-gray-1/80 backdrop-blur-md z-10 sticky top-0" >
@@ -1385,6 +1414,23 @@ export default function SessionView(props: SessionViewProps) {
13851414 isRemoteWorkspace = { props . activeWorkspaceDisplay . workspaceType === "remote" }
13861415 />
13871416
1417+ < Show when = { unreadCount ( ) > 0 } >
1418+ < div class = "fixed bottom-24 right-6 z-40" >
1419+ < button
1420+ type = "button"
1421+ onClick = { jumpToLatest }
1422+ class = "flex items-center gap-2 rounded-full border border-gray-6 bg-gray-2/90 px-3 py-2 text-xs text-gray-11 shadow-lg shadow-gray-12/10 transition-all hover:text-gray-12 hover:border-gray-7"
1423+ aria-label = "Jump to latest message"
1424+ >
1425+ < span > New messages</ span >
1426+ < span class = "rounded-full bg-gray-12/10 px-2 py-0.5 text-[10px] font-semibold text-gray-12" >
1427+ { unreadCount ( ) }
1428+ </ span >
1429+ < ChevronDown size = { 12 } class = "text-gray-9" />
1430+ </ button >
1431+ </ div >
1432+ </ Show >
1433+
13881434 < div class = "fixed bottom-0 left-0 right-0" >
13891435 < StatusBar
13901436 clientConnected = { props . clientConnected }
0 commit comments