2026-01-23 20:32:35 -05:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2026 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { useMemo } from 'react';
|
|
|
|
|
import { useUIState } from '../contexts/UIStateContext.js';
|
2026-03-12 02:51:40 +05:30
|
|
|
import {
|
|
|
|
|
getConfirmingToolState,
|
|
|
|
|
type ConfirmingToolState,
|
|
|
|
|
} from '../utils/confirmingTool.js';
|
2026-01-23 20:32:35 -05:00
|
|
|
|
2026-02-18 15:28:17 -05:00
|
|
|
export type { ConfirmingToolState } from '../utils/confirmingTool.js';
|
2026-01-23 20:32:35 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Selects the "Head" of the confirmation queue.
|
|
|
|
|
* Returns the first tool in the pending state that requires confirmation.
|
|
|
|
|
*/
|
|
|
|
|
export function useConfirmingTool(): ConfirmingToolState | null {
|
|
|
|
|
// We use pendingHistoryItems to ensure we capture tools from both
|
|
|
|
|
// Gemini responses and Slash commands.
|
|
|
|
|
const { pendingHistoryItems } = useUIState();
|
|
|
|
|
|
2026-02-18 15:28:17 -05:00
|
|
|
return useMemo(
|
|
|
|
|
() => getConfirmingToolState(pendingHistoryItems),
|
|
|
|
|
[pendingHistoryItems],
|
|
|
|
|
);
|
2026-01-23 20:32:35 -05:00
|
|
|
}
|