# IntelligenceToolbar

- File ID: file:q33ld0:intelligencetoolbar-razor
- Path: NexusReader.UI.Shared/Components/Molecules/IntelligenceToolbar.razor
- Role: ui-component
- Layer: frontend

## Purpose

Blazor UI component that provides an intelligence/AI toolbar with navigation, focus mode toggle, cache clearing and logout actions; wires UI events to injected services and updates UI state on FocusMode changes.

## Key Details

Component is event-driven: subscribes to FocusMode events, exposes async actions (clear cache, logout) via injected application services, logs operations to Console, and triggers UI re-renders; markup binds FocusMode.IsFocusModeActive to adjust CSS classes.

## Symbols

- IntelligenceToolbar: Blazor UI component that provides an intelligence/AI toolbar with navigation, focus mode toggle, cache clearing and logout actions; wires UI events to injected services and updates UI state on FocusMode changes.
- OnInitialized(): Component lifecycle initialization: subscribes to FocusMode change events to trigger UI updates.
- HandleClearCache(): Asynchronously requests clearing the AI/knowledge cache via KnowledgeService and logs the outcome.
- HandleLogout(): Logs the user out via IdentityService and then navigates to the logout form.
- HandleUpdate(): Triggers a UI refresh on the Blazor renderer when FocusMode changes.
- Dispose(): Lifecycle cleanup: unsubscribes from FocusMode change events to avoid memory leaks.

## Dependencies

- imports NexusReader.UI.Shared/Services/IFocusModeService.cs

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.Application.Abstractions/Services/IKnowledgeService.cs
- dependency-target: NexusReader.Application.Abstractions/Services/IIdentityService.cs
- dependency-target: Microsoft.AspNetCore.Components/NavigationManager (framework)
- call-target: NexusReader.UI.Shared/Services/IFocusModeService.cs
- call-target: NexusReader.Application.Abstractions/Services/IKnowledgeService.cs
- call-target: NexusReader.Application.Abstractions/Services/IIdentityService.cs
- call-target: NexusReader.UI.Shared/Services/IFocusModeService.cs
- interaction-target: await KnowledgeService.ClearCacheAsync()
- interaction-target: await IdentityService.LogoutAsync()

## Coverage

- Symbols: 6
- Executable symbols: 5
- Executable symbols with control flow: 5
- Grounded edges: 7
- Unresolved references: 9
- Control-flow fragments: 5
- Unresolved jumps: 4
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 6

## Control Flow Fragments

- OnInitialized: 4 nodes, 3 edges, 1 jumps, 0 unsupported constructs
- HandleClearCache: 15 nodes, 16 edges, 1 jumps, 0 unsupported constructs
- HandleLogout: 6 nodes, 5 edges, 1 jumps, 0 unsupported constructs
- HandleUpdate: 3 nodes, 2 edges, 0 jumps, 0 unsupported constructs
- Dispose: 4 nodes, 3 edges, 1 jumps, 0 unsupported constructs

## Diagrams

### IntelligenceToolbar Neighborhood

```mermaid
flowchart LR
    class_nsawvo_intelligencetoolbar("IntelligenceToolbar")
    file_q33ld0_intelligencetoolbar_razor("IntelligenceToolbar")
    method_1dyzngl_handleclearcache[["HandleClearCache()"]]
    method_1ef8df_oninitialized[["OnInitialized()"]]
    method_1nyg1j6_dispose[["Dispose()"]]
    method_68za1u_handlelogout[["HandleLogout()"]]
    method_oj5ghm_handleupdate[["HandleUpdate()"]]
    file_xs3ks1_ifocusmodeservice_cs[/"IFocusModeService"/]
    file_q33ld0_intelligencetoolbar_razor -->|IFocusModeService| file_xs3ks1_ifocusmodeservice_cs
```

### IntelligenceToolbar Execution Overview

```mermaid
flowchart TD
    class_nsawvo_intelligencetoolbar("IntelligenceToolbar")
    method_1dyzngl_handleclearcache[["HandleClearCache()"]]
    method_1ef8df_oninitialized[["OnInitialized()"]]
    method_1nyg1j6_dispose[["Dispose()"]]
    method_68za1u_handlelogout[["HandleLogout()"]]
    method_oj5ghm_handleupdate[["HandleUpdate()"]]
    unresolved_unresolved_1cqxa9n_interaction_target{"Unresolved: await IdentityService.LogoutAsync()"}
    unresolved_unresolved_1vsk4w2_call_target{"Unresolved: LogoutAsync"}
    unresolved_unresolved_2xgh31_call_target{"Unresolved: OnFocusModeChanged (event add)"}
    unresolved_unresolved_4foxma_call_target{"Unresolved: OnFocusModeChanged (event remove)"}
    unresolved_unresolved_854yi0_call_target{"Unresolved: ClearCacheAsync"}
    unresolved_unresolved_9twudu_interaction_target{"Unresolved: await KnowledgeService.ClearCacheAsync()"}
    class_nsawvo_intelligencetoolbar -->|contains| method_1dyzngl_handleclearcache
    class_nsawvo_intelligencetoolbar -->|contains| method_1ef8df_oninitialized
    class_nsawvo_intelligencetoolbar -->|contains| method_1nyg1j6_dispose
    class_nsawvo_intelligencetoolbar -->|contains| method_68za1u_handlelogout
    class_nsawvo_intelligencetoolbar -->|contains| method_oj5ghm_handleupdate
    class_nsawvo_intelligencetoolbar -->|unresolved interaction| unresolved_unresolved_1cqxa9n_interaction_target
    class_nsawvo_intelligencetoolbar -->|unresolved interaction| unresolved_unresolved_9twudu_interaction_target
    method_1dyzngl_handleclearcache -->|unresolved call| unresolved_unresolved_854yi0_call_target
    method_1ef8df_oninitialized -->|unresolved call| unresolved_unresolved_2xgh31_call_target
    method_1nyg1j6_dispose -->|unresolved call| unresolved_unresolved_4foxma_call_target
    method_68za1u_handlelogout -->|unresolved call| unresolved_unresolved_1vsk4w2_call_target
```

### OnInitialized() Control Flow

```mermaid
flowchart TD
    method_1ef8df_oninitialized__call_50_OnFocusModeChanged_event_add_[["OnFocusModeChanged (event add)"]]
    method_1ef8df_oninitialized__action_50_event_subscribe_50__linear("Subscribe to FocusMode changes")
    method_1ef8df_oninitialized__entry(["OnInitialized entry"])
    method_1ef8df_oninitialized__implicit_return(["return"])
    method_1ef8df_oninitialized__action_50_event_subscribe_50__linear -->|adds HandleUpdate delegate| method_1ef8df_oninitialized__call_50_OnFocusModeChanged_event_add_
    method_1ef8df_oninitialized__call_50_OnFocusModeChanged_event_add_ -->|return| method_1ef8df_oninitialized__implicit_return
    method_1ef8df_oninitialized__entry -->|next| method_1ef8df_oninitialized__action_50_event_subscribe_50__linear
```

### HandleClearCache() Control Flow

```mermaid
flowchart TD
    method_1dyzngl_handleclearcache__call_57_ClearCacheAsync[["ClearCacheAsync"]]
    method_1dyzngl_handleclearcache__action_56_log_56__linear("Requesting cache clear")
    method_1dyzngl_handleclearcache__action_57_handleclearcache_await_57_0__await[["Waits for async work"]]
    method_1dyzngl_handleclearcache__action_58_guard_clause_58__condition{"result.IsSuccess"}
    method_1dyzngl_handleclearcache__action_58_guard_clause_58__false("no-op")
    method_1dyzngl_handleclearcache__action_58_guard_clause_58__merge("merge")
    method_1dyzngl_handleclearcache__action_58_guard_clause_58__true("log-success")
    method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__condition{"result.IsSuccess"}
    method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__false("false")
    method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__merge("merge")
    method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__true("true")
    method_1dyzngl_handleclearcache__action_60_log_60__linear("Cache cleared confirmation")
    method_1dyzngl_handleclearcache__entry(["HandleClearCache entry"])
    method_1dyzngl_handleclearcache__action_57_external_call_57__linear("ClearCacheAsync invoked")
    method_1dyzngl_handleclearcache__implicit_return(["return"])
    method_1dyzngl_handleclearcache__action_56_log_56__linear -->|next| method_1dyzngl_handleclearcache__action_57_handleclearcache_await_57_0__await
    method_1dyzngl_handleclearcache__action_57_external_call_57__linear -->|no params, awaited call| method_1dyzngl_handleclearcache__call_57_ClearCacheAsync
    method_1dyzngl_handleclearcache__action_57_handleclearcache_await_57_0__await -->|next| method_1dyzngl_handleclearcache__action_57_external_call_57__linear
    method_1dyzngl_handleclearcache__action_58_guard_clause_58__condition -->|no-op| method_1dyzngl_handleclearcache__action_58_guard_clause_58__false
    method_1dyzngl_handleclearcache__action_58_guard_clause_58__condition -->|log-success| method_1dyzngl_handleclearcache__action_58_guard_clause_58__true
    method_1dyzngl_handleclearcache__action_58_guard_clause_58__false -->|next| method_1dyzngl_handleclearcache__action_58_guard_clause_58__merge
    method_1dyzngl_handleclearcache__action_58_guard_clause_58__merge -->|next| method_1dyzngl_handleclearcache__action_60_log_60__linear
    method_1dyzngl_handleclearcache__action_58_guard_clause_58__true -->|next| method_1dyzngl_handleclearcache__action_58_guard_clause_58__merge
    method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__condition -->|false| method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__false
    method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__condition -->|true| method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__true
    method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__false -->|next| method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__merge
    method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__merge -->|next| method_1dyzngl_handleclearcache__action_58_guard_clause_58__condition
    method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__true -->|next| method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__merge
    method_1dyzngl_handleclearcache__action_60_log_60__linear -->|return| method_1dyzngl_handleclearcache__implicit_return
    method_1dyzngl_handleclearcache__call_57_ClearCacheAsync -->|next| method_1dyzngl_handleclearcache__action_58_handleclearcache_branch_58_1__condition
    method_1dyzngl_handleclearcache__entry -->|next| method_1dyzngl_handleclearcache__action_56_log_56__linear
```

### HandleLogout() Control Flow

```mermaid
flowchart TD
    method_68za1u_handlelogout__call_66_LogoutAsync[["LogoutAsync"]]
    method_68za1u_handlelogout__action_66_handlelogout_await_66_0__await[["Waits for async work"]]
    method_68za1u_handlelogout__action_67_navigation_67__linear("Navigate to logout form")
    method_68za1u_handlelogout__entry(["HandleLogout entry"])
    method_68za1u_handlelogout__action_66_external_call_66__linear("Logout invoked")
    method_68za1u_handlelogout__implicit_return(["return"])
    method_68za1u_handlelogout__action_66_external_call_66__linear -->|no params, awaited call| method_68za1u_handlelogout__call_66_LogoutAsync
    method_68za1u_handlelogout__action_66_handlelogout_await_66_0__await -->|next| method_68za1u_handlelogout__action_66_external_call_66__linear
    method_68za1u_handlelogout__action_67_navigation_67__linear -->|return| method_68za1u_handlelogout__implicit_return
    method_68za1u_handlelogout__call_66_LogoutAsync -->|next| method_68za1u_handlelogout__action_67_navigation_67__linear
    method_68za1u_handlelogout__entry -->|next| method_68za1u_handlelogout__action_66_handlelogout_await_66_0__await
```

### Dispose() Control Flow

```mermaid
flowchart TD
    method_1nyg1j6_dispose__call_74_OnFocusModeChanged_event_remove_[["OnFocusModeChanged (event remove)"]]
    method_1nyg1j6_dispose__action_74_event_unsubscribe_74__linear("Unsubscribe from FocusMode changes")
    method_1nyg1j6_dispose__entry(["Dispose entry"])
    method_1nyg1j6_dispose__implicit_return(["return"])
    method_1nyg1j6_dispose__action_74_event_unsubscribe_74__linear -->|removes HandleUpdate delegate| method_1nyg1j6_dispose__call_74_OnFocusModeChanged_event_remove_
    method_1nyg1j6_dispose__call_74_OnFocusModeChanged_event_remove_ -->|return| method_1nyg1j6_dispose__implicit_return
    method_1nyg1j6_dispose__entry -->|next| method_1nyg1j6_dispose__action_74_event_unsubscribe_74__linear
```

## Diagram Validation

- Status: warn
- Warning: Control-flow extraction left 4 unresolved jumps.
