mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
wara
This commit is contained in:
@@ -19,6 +19,7 @@ export default function AdminPanel() {
|
||||
setAdminReason,
|
||||
rebootRover,
|
||||
rebootServer,
|
||||
llmControl,
|
||||
adminLogs,
|
||||
llmCommentaryStatus,
|
||||
} = useSession();
|
||||
@@ -26,6 +27,7 @@ export default function AdminPanel() {
|
||||
const [lockStates, setLockStates] = useState({});
|
||||
const [rebootStates, setRebootStates] = useState({});
|
||||
const [serverRebooting, setServerRebooting] = useState(false);
|
||||
const [clearingLlmHistory, setClearingLlmHistory] = useState(false);
|
||||
const health = session?.health || null;
|
||||
const currentGoal = session?.communityGoal?.text || '';
|
||||
const goalUpdatedAt = session?.communityGoal?.updatedAt || null;
|
||||
@@ -93,6 +95,21 @@ export default function AdminPanel() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleClearLlmHistory = async () => {
|
||||
const ok = window.confirm(
|
||||
'Clear LLM commentary history now? This resets chat context, bot memory, and rover activity metrics for narration.',
|
||||
);
|
||||
if (!ok) return;
|
||||
setClearingLlmHistory(true);
|
||||
try {
|
||||
await llmControl('clearHistory');
|
||||
} catch (err) {
|
||||
alert(err.message);
|
||||
} finally {
|
||||
setClearingLlmHistory(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleGoalSave = async () => {
|
||||
try {
|
||||
await setCommunityGoal(goalDraft);
|
||||
@@ -237,13 +254,17 @@ export default function AdminPanel() {
|
||||
)}
|
||||
/>
|
||||
<ReplaySnapshotHealth health={health} />
|
||||
<LlmCommentaryPanel status={llmCommentaryStatus} />
|
||||
<LlmCommentaryPanel
|
||||
status={llmCommentaryStatus}
|
||||
onClearHistory={handleClearLlmHistory}
|
||||
clearingHistory={clearingLlmHistory}
|
||||
/>
|
||||
<AdminIpLogPanel entries={adminLogs} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function LlmCommentaryPanel({ status }) {
|
||||
function LlmCommentaryPanel({ status, onClearHistory, clearingHistory }) {
|
||||
if (!status) {
|
||||
return (
|
||||
<div className="space-y-0.5">
|
||||
@@ -267,6 +288,16 @@ function LlmCommentaryPanel({ status }) {
|
||||
return (
|
||||
<div className="space-y-0.5">
|
||||
<div className="panel-muted text-xs uppercase">LLM Commentary</div>
|
||||
<div className="flex gap-0.5 text-xs">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClearHistory}
|
||||
disabled={Boolean(clearingHistory)}
|
||||
className="button-danger disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
{clearingHistory ? 'Clearing...' : 'Clear LLM History'}
|
||||
</button>
|
||||
</div>
|
||||
<div className="surface space-y-0.5 text-xs text-slate-200">
|
||||
<div className="flex items-center justify-between">
|
||||
<span>Enabled</span>
|
||||
@@ -320,6 +351,16 @@ function LlmCommentaryPanel({ status }) {
|
||||
<span>Prompt chars</span>
|
||||
<span>{status.lastPromptChars ?? 0}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span>Cleared count</span>
|
||||
<span>{status.clearCount ?? 0}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span>Last cleared</span>
|
||||
<span className="text-slate-300">
|
||||
{status.lastClearedAt ? new Date(status.lastClearedAt).toLocaleString() : 'never'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="surface space-y-0.5 text-xs text-slate-300">
|
||||
<div className="flex items-center justify-between">
|
||||
|
||||
@@ -23,6 +23,7 @@ const SessionContext = createContext({
|
||||
setAdminReason: async () => {},
|
||||
rebootRover: async () => {},
|
||||
rebootServer: async () => {},
|
||||
llmControl: async () => {},
|
||||
});
|
||||
|
||||
function useAckEmitter(socket) {
|
||||
@@ -129,6 +130,7 @@ export function SessionProvider({ children }) {
|
||||
rebootRover: (roverId) =>
|
||||
emitWithAck('command', { roverId, type: 'reboot', data: { reboot: {} } }),
|
||||
rebootServer: () => emitWithAck('server:reboot'),
|
||||
llmControl: (action, payload = {}) => emitWithAck('llm:control', { action, ...payload }),
|
||||
pushAlert: (alert) =>
|
||||
setAlerts((prev) => [
|
||||
...prev.slice(-49),
|
||||
|
||||
Reference in New Issue
Block a user