PluginProbe
Extendify / 3.1.4
Extendify v3.1.4
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Agent / components / messages / StatusIndicator.jsx

StatusIndicator.jsx in Extendify 3.1.4, at src/Agent/components/messages/StatusIndicator.jsx

55 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useStatusStore } from '@agent/state/status';
2 import { useEffect, useMemo, useState } from '@wordpress/element';
3 import { decodeEntities } from '@wordpress/html-entities';
4 import { __ } from '@wordpress/i18n';
5
6 const linesFor = (label) => ({
7 'calling-agent': __('Thinking...', 'extendify-local'),
8 'agent-working': [
9 __('Working on it...', 'extendify-local'),
10 __('Interpreting message...', 'extendify-local'),
11 __('Formulating a response...', 'extendify-local'),
12 __('Reviewing logic...', 'extendify-local'),
13 ],
14 'workflow-tool-processing': __('Processing...', 'extendify-local'),
15 'tool-started': label || __('Gathering data...', 'extendify-local'),
16 'credits-exhausted': __('Usage limit reached', 'extendify-local'),
17 'credits-restored': __('Usage limit restored', 'extendify-local'),
18 });
19
20 // Randomized 3-5s beat so a long wait never looks stuck or syncs across sites.
21 const useCurrentLine = (lines) => {
22 const [index, setIndex] = useState(0);
23 const isList = Array.isArray(lines);
24
25 useEffect(() => setIndex(0), [lines]);
26
27 useEffect(() => {
28 if (!isList) return;
29 const timer = setTimeout(
30 () => setIndex((i) => (i + 1) % lines.length),
31 3000 + Math.random() * 2000,
32 );
33 return () => clearTimeout(timer);
34 }, [isList, lines, index]);
35
36 return isList ? lines[index] : lines;
37 };
38
39 export const StatusIndicator = () => {
40 const { type, label } = useStatusStore((s) => s.statuses.at(-1)) ?? {};
41 const lines = useMemo(() => linesFor(label)[type], [label, type]);
42 const text = useCurrentLine(lines);
43
44 if (!text) return null;
45
46 return (
47 <div className="p-2 text-center text-xs italic text-gray-700">
48 {/* Reusing the node drops the new line mid-sweep. */}
49 <span key={text} className="status-animation">
50 {decodeEntities(text)}
51 </span>
52 </div>
53 );
54 };
55