| | 1 | ## Input Sources to printCharacters |
| | 2 | |
| | 3 | |
| | 4 | `printCharacters` is the main function that triggers the fuzzy search process if fuzzy search is enabled. |
| | 5 | |
| | 6 | ```mermaid |
| | 7 | flowchart TD |
| | 8 | subgraph User Actions |
| | 9 | UA1[Character Search Input] |
| | 10 | UA2[Tag Filter Click] |
| | 11 | UA3[Folder Navigation] |
| | 12 | UA4[Character Delete] |
| | 13 | UA5[Character Create] |
| | 14 | UA6[Character Import] |
| | 15 | UA7[Clear All Filters] |
| | 16 | UA8[Bulk Edit Operations] |
| | 17 | UA9[Persona Changes] |
| | 18 | end |
| | 19 | |
| | 20 | subgraph API Events |
| | 21 | API1[Character List Update] |
| | 22 | API2[Group Update] |
| | 23 | API3[Tag Update] |
| | 24 | end |
| | 25 | |
| | 26 | subgraph System Events |
| | 27 | SE1[Page Load] |
| | 28 | SE2[Content Manager Update] |
| | 29 | SE3[Extension Events] |
| | 30 | end |
| | 31 | |
| | 32 | UA1 -->|triggers| PCD[printCharactersDebounced] |
| | 33 | UA2 -->|triggers| PCD |
| | 34 | UA7 -->|triggers| PCD |
| | 35 | UA8 -->|triggers| PCD |
| | 36 | UA9 -->|triggers| PCD |
| | 37 | |
| | 38 | UA3 -->|triggers| PC[printCharacters] |
| | 39 | UA4 -->|triggers| PC |
| | 40 | UA5 -->|triggers| PC |
| | 41 | UA6 -->|triggers| PC |
| | 42 | |
| | 43 | API1 -->|triggers| PC |
| | 44 | API2 -->|triggers| PC |
| | 45 | API3 -->|triggers| PC |
| | 46 | |
| | 47 | SE1 -->|triggers| PC |
| | 48 | SE2 -->|triggers| PC |
| | 49 | SE3 -->|triggers| PC |
| | 50 | |
| | 51 | PCD -->|debounced call| PC |
| | 52 | |
| | 53 | style PC fill:#f96,stroke:#333 |
| | 54 | style PCD fill:#f96,stroke:#333 |
| | 55 | ``` |
| | 56 | |
| | 57 | This diagram shows how `printCharacters` is called throughout the application: |
| | 58 | |
| | 59 | 1. User Actions that trigger character list updates: |
| | 60 | - Search input (debounced) |
| | 61 | - Tag filter clicks (debounced) |
| | 62 | - Folder navigation (direct) |
| | 63 | - Character management operations (direct) |
| | 64 | |
| | 65 | 2. API Events that require list refresh: |
| | 66 | - Character list updates |
| | 67 | - Group updates |
| | 68 | - Tag system updates |
| | 69 | |
| | 70 | 3. System Events: |
| | 71 | - Initial page load |
| | 72 | - Content manager updates |
| | 73 | - Extension-triggered refreshes |
| | 74 | |
| | 75 | |
| | 76 | |
| | 77 | ## Fuzzy Search Flow |
| | 78 | |
| | 79 | |
| | 80 | This diagram shows the flow of fuzzy search operations: |
| | 81 | ```mermaid |
| | 82 | sequenceDiagram |
| | 83 | participant Data as Data Sources |
| | 84 | participant PC as printCharacters |
| | 85 | participant GEL as getEntitiesList |
| | 86 | participant FH as FilterHelper |
| | 87 | participant AF as applyFilters |
| | 88 | participant FS as FuzzySearch Functions |
| | 89 | participant Cache as FuzzySearchCaches |
| | 90 | |
| | 91 | Note over Data: Changes from:<br/>- Tags<br/>- Personas<br/>- World Info<br/>- Groups |
| | 92 | |
| | 93 | Data->>PC: All changes trigger printCharacters<br/>(direct or debounced) |
| | 94 | |
| | 95 | PC->>GEL: Call with {doFilter: true} |
| | 96 | GEL->>FH: filterByTagState(entities) |
| | 97 | GEL->>AF: entitiesFilter.applyFilters(entities) |
| | 98 | |
| | 99 | AF->>FH: Check scoreCache for existing results |
| | 100 | FH-->>AF: Return cached scores if exist |
| | 101 | |
| | 102 | Note over FS: Filter functions include:<br/>SEARCH, <br/>FAV, <br/>GROUP, <br/>FOLDER, <br/>TAG, <br/>WORLD_INFO_SEARCH, <br/>PERSONA_SEARCH |
| | 103 | AF->>FS: fuzzySearchCharacters/Groups/Tags |
| | 104 | FS->>Cache: Check/Store results |
| | 105 | |
| | 106 | FS-->>AF: Return search results |
| | 107 | AF->>FH: Cache new scores |
| | 108 | AF-->>GEL: Return filtered entities |
| | 109 | GEL-->>PC: Return final entities list |
| | 110 | |
| | 111 | PC->>Cache: clearFuzzySearchCaches() |
| | 112 | Note over Cache: Cache is cleared at the end of<br/>each printCharacters call,<br/>ensuring fresh results for next search |
| | 113 | ``` |