PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
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.2.1, at src/Agent/components/messages/StatusIndicator.jsx

59 lines 1.9 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 leavingPage = useStatusStore((s) => s.leavingPage);
41 const { type, label } = useStatusStore((s) => s.statuses.at(-1)) ?? {};
42 const lines = useMemo(() => linesFor(label)[type], [label, type]);
43 const currentLine = useCurrentLine(lines);
44 const text = leavingPage
45 ? __('Refreshing the page to show your changes…', 'extendify-local')
46 : currentLine;
47
48 if (!text) return null;
49
50 return (
51 <div className="p-2 text-center text-xs italic text-gray-700">
52 {/* Reusing the node drops the new line mid-sweep. */}
53 <span key={text} className="status-animation">
54 {decodeEntities(text)}
55 </span>
56 </div>
57 );
58 };
59