diff --git a/pkg/interface/webterm/Buffer.tsx b/pkg/interface/webterm/Buffer.tsx index 67b8f03c6..8d5ae2ce7 100644 --- a/pkg/interface/webterm/Buffer.tsx +++ b/pkg/interface/webterm/Buffer.tsx @@ -12,7 +12,7 @@ import useTermState from './state'; import React from 'react'; import { Box, Col } from '@tlon/indigo-react'; import { makeTheme } from './lib/theme'; -import { showBlit, csi } from './lib/blit'; +import { showBlit, csi, hasBell } from './lib/blit'; import { DEFAULT_SESSION } from './constants'; import { retry } from './lib/retry'; @@ -180,7 +180,8 @@ export default function Buffer({ name, selected, dark }: BufferProps) { app: 'herm', path: '/session/' + name + '/view', event: (e) => { showBlit(ses.term, e); - if (e.bel && !selected) { + //NOTE getting selected from state because selected prop is stale + if (hasBell(e) && (useTermState.getState().selected !== name)) { useTermState.getState().set((state) => { state.sessions[name].hasBell = true; }); diff --git a/pkg/interface/webterm/lib/blit.ts b/pkg/interface/webterm/lib/blit.ts index cd25de168..e98f8fe75 100644 --- a/pkg/interface/webterm/lib/blit.ts +++ b/pkg/interface/webterm/lib/blit.ts @@ -73,3 +73,13 @@ export const showSlog = (term: Terminal, slog: string) => { + csi('r') + csi('u')); }; + +export const hasBell = (blit: Blit) => { + if ('bel' in blit) { + return true; + } else if ('mor' in blit) { + return blit.mor.some(hasBell); + } else { + return false; + } +}