MCPcopy Index your code
hub / github.com/codeaashu/claude-code / useTerminalNotification

Function useTerminalNotification

src/ink/useTerminalNotification.ts:25–126  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23}
24
25export function useTerminalNotification(): TerminalNotification {
26 const writeRaw = useContext(TerminalWriteContext)
27 if (!writeRaw) {
28 throw new Error(
29 'useTerminalNotification must be used within TerminalWriteProvider',
30 )
31 }
32
33 const notifyITerm2 = useCallback(
34 ({ message, title }: { message: string; title?: string }) => {
35 const displayString = title ? `${title}:\n${message}` : message
36 writeRaw(wrapForMultiplexer(osc(OSC.ITERM2, `\n\n${displayString}`)))
37 },
38 [writeRaw],
39 )
40
41 const notifyKitty = useCallback(
42 ({
43 message,
44 title,
45 id,
46 }: {
47 message: string
48 title: string
49 id: number
50 }) => {
51 writeRaw(wrapForMultiplexer(osc(OSC.KITTY, `i=${id}:d=0:p=title`, title)))
52 writeRaw(wrapForMultiplexer(osc(OSC.KITTY, `i=${id}:p=body`, message)))
53 writeRaw(wrapForMultiplexer(osc(OSC.KITTY, `i=${id}:d=1:a=focus`, '')))
54 },
55 [writeRaw],
56 )
57
58 const notifyGhostty = useCallback(
59 ({ message, title }: { message: string; title: string }) => {
60 writeRaw(wrapForMultiplexer(osc(OSC.GHOSTTY, 'notify', title, message)))
61 },
62 [writeRaw],
63 )
64
65 const notifyBell = useCallback(() => {
66 // Raw BEL — inside tmux this triggers tmux's bell-action (window flag).
67 // Wrapping would make it opaque DCS payload and lose that fallback.
68 writeRaw(BEL)
69 }, [writeRaw])
70
71 const progress = useCallback(
72 (state: Progress['state'] | null, percentage?: number) => {
73 if (!isProgressReportingAvailable()) {
74 return
75 }
76 if (!state) {
77 writeRaw(
78 wrapForMultiplexer(
79 osc(OSC.ITERM2, ITERM2.PROGRESS, PROGRESS.CLEAR, ''),
80 ),
81 )
82 return

Callers 5

ConsoleOAuthFlowFunction · 0.85
MessagesImplFunction · 0.85
REPLFunction · 0.85
useInboxPollerFunction · 0.85
useNotifyAfterTimeoutFunction · 0.85

Calls 4

wrapForMultiplexerFunction · 0.85
oscFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected