(props)
| 961 | } |
| 962 | |
| 963 | const ToolsView: Component<{ hook: HookRecord }> = (props) => { |
| 964 | const { state, applyToolFixture, deleteToolFixture } = useAIStore() |
| 965 | const styles = useStyles() |
| 966 | const [selectedToolName, setSelectedToolName] = createSignal<string | null>( |
| 967 | props.hook.tools[0]?.name ?? null, |
| 968 | ) |
| 969 | |
| 970 | const selectedTool = createMemo(() => |
| 971 | props.hook.tools.find((tool) => tool.name === selectedToolName()), |
| 972 | ) |
| 973 | |
| 974 | const savedFixtures = createMemo(() => |
| 975 | state.hooks.fixtures |
| 976 | .filter( |
| 977 | (fixture) => |
| 978 | fixture.hookId === props.hook.id || |
| 979 | (!!props.hook.threadId && fixture.threadId === props.hook.threadId), |
| 980 | ) |
| 981 | .sort((a, b) => b.createdAt - a.createdAt), |
| 982 | ) |
| 983 | |
| 984 | return ( |
| 985 | <div class={styles().hookDetails.toolsGrid} data-testid="ai-devtools-tools"> |
| 986 | <div class={styles().hookDetails.toolsList}> |
| 987 | <Show |
| 988 | when={props.hook.tools.length > 0} |
| 989 | fallback={ |
| 990 | <div class={styles().hookDetails.emptySmall}>No tools.</div> |
| 991 | } |
| 992 | > |
| 993 | <For each={props.hook.tools}> |
| 994 | {(tool) => ( |
| 995 | <button |
| 996 | type="button" |
| 997 | data-testid="ai-devtools-tool-row" |
| 998 | data-tool-name={tool.name} |
| 999 | class={`${styles().hookDetails.toolRow} ${ |
| 1000 | selectedToolName() === tool.name |
| 1001 | ? styles().hookDetails.toolRowSelected |
| 1002 | : '' |
| 1003 | }`} |
| 1004 | onClick={() => setSelectedToolName(tool.name)} |
| 1005 | > |
| 1006 | <span class={styles().hookDetails.toolName}>{tool.name}</span> |
| 1007 | <Show when={tool.needsApproval}> |
| 1008 | <span class={styles().hookDetails.eventBadge}>approval</span> |
| 1009 | </Show> |
| 1010 | </button> |
| 1011 | )} |
| 1012 | </For> |
| 1013 | </Show> |
| 1014 | </div> |
| 1015 | <div class={styles().hookDetails.toolDetail}> |
| 1016 | <Show |
| 1017 | when={selectedTool()} |
| 1018 | fallback={ |
| 1019 | <div class={styles().hookDetails.emptySmall}>Select a tool.</div> |
| 1020 | } |
nothing calls this directly
no test coverage detected