All files / src/hooks useNotifications.js

100% Statements 9/9
80% Branches 4/5
100% Functions 4/4
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23        17x   17x 1x     17x 24x 24x 24x     17x            
import { useState } from 'react';
import { vscodeNative } from '../vscodeNative';
 
export function useNotifications() {
  const [agentLog, setAgentLog] = useState([]);
 
  const notify = (message, type = 'error') => {
    vscodeNative.notify(message, type === 'error' ? 'error' : 'info');
  };
 
  const logAgentAction = (action, details) => {
    const actionString = String(action);
    const detailString = typeof details === 'object' ? JSON.stringify(details) : String(details);
    setAgentLog(prev => [...prev, { action: actionString, details: detailString, timestamp: Date.now() }].slice(-15));
  };
 
  return {
    agentLog, setAgentLog,
    notify,
    logAgentAction,
  };
}