Commit 00e1325
fix(web-ui): refactor broker to context provider with precision and U… (#162)
* fix(web-ui): refactor broker to context provider with precision and UX improvements
Migrate use0GBroker hook to BrokerProvider context to eliminate duplicate
broker instances. Fix isInitializing lifecycle by fetching ledger data
directly via broker instance in initializeBroker, replacing fragile
cross-effect handoff. Add cancellation-safe finally block.
Key changes:
- Extract BrokerProvider with Symbol-based cancellation and self-contained init lifecycle
- Add neuronToA0giString for lossless BigInt-to-string conversion
- Unify formatNumber across 5 components with optional full-precision mode
- Fix XSS: replace dangerouslySetInnerHTML with React.ReactNode
- Fix balance validation: use availableBalance instead of totalBalance
- Fix scroll: increase threshold to 50px, use refs to avoid stale closures
- Centralize minimum deposit constants in limits.ts
- Extract ChainAwareDataCache to shared chainCache module
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(web-ui): fix double loading on init and clean up dead code
- Fix spurious chain switch during initial wallet connection by
initializing currentChainIdRef as undefined and only recording
chainId when wallet is connected
- Reset currentChainIdRef on disconnect to prevent false chain
switch on reconnection
- Remove deprecated use0GBroker hook (no consumers remain)
- Remove redundant refreshLedgerInfo effect from OptimizedChatPage
- Simplify scroll handler by removing unnecessary refs and using
proper useEffect deps
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: minor type issue
* fix(web-ui): fix ChatOnboarding cascade step-skip bug
Replace props-driven auto-advance logic with localStorage-driven step
tracking to prevent steps from cascading 1→2→3 on page load when
hasProvider and hasBalance are already true.
- Change localStorage key from 'chat-onboarding-completed' to
'chat-onboarding-step' storing "1"/"2"/"3"/"completed"
- Remove hasProvider/hasBalance props and internal useEffect
auto-advance logic from ChatOnboarding component
- Move step state management to useChatOnboarding hook with
advanceStep/completeOnboarding/resetOnboarding
- Make step indicator dots clickable (forward-only persistence)
- Remove unnecessary typeof window guards inside useEffect/callbacks
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(web-ui): compare against persisted step to prevent localStorage regression
advanceStep was comparing against React state which gets updated on
dot navigation, causing localStorage to regress when viewing earlier
steps then clicking forward (e.g. step 3 → dot 1 → dot 2 wrote "2").
Compare against localStorage value instead.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 351fffa commit 00e1325
File tree
34 files changed
+524
-526
lines changed- web-ui
- src
- app
- inference
- chat
- components
- constants
- components
- image-edit
- image-gen
- speech-to-text
- wallet
- components
- x402-demo
34 files changed
+524
-526
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
7 | 12 | | |
Lines changed: 36 additions & 69 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 51 | + | |
96 | 52 | | |
97 | 53 | | |
98 | 54 | | |
99 | 55 | | |
100 | 56 | | |
101 | | - | |
| 57 | + | |
102 | 58 | | |
103 | 59 | | |
104 | 60 | | |
| |||
128 | 84 | | |
129 | 85 | | |
130 | 86 | | |
131 | | - | |
| 87 | + | |
132 | 88 | | |
133 | 89 | | |
134 | 90 | | |
| |||
144 | 100 | | |
145 | 101 | | |
146 | 102 | | |
147 | | - | |
| 103 | + | |
148 | 104 | | |
149 | 105 | | |
150 | 106 | | |
151 | 107 | | |
152 | 108 | | |
153 | | - | |
| 109 | + | |
154 | 110 | | |
155 | 111 | | |
156 | 112 | | |
| |||
165 | 121 | | |
166 | 122 | | |
167 | 123 | | |
168 | | - | |
| 124 | + | |
169 | 125 | | |
170 | | - | |
| 126 | + | |
| 127 | + | |
171 | 128 | | |
172 | 129 | | |
173 | 130 | | |
| |||
183 | 140 | | |
184 | 141 | | |
185 | 142 | | |
186 | | - | |
| 143 | + | |
187 | 144 | | |
188 | 145 | | |
| 146 | + | |
189 | 147 | | |
190 | 148 | | |
191 | | - | |
192 | | - | |
193 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
194 | 155 | | |
195 | 156 | | |
196 | 157 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
201 | 163 | | |
| 164 | + | |
202 | 165 | | |
203 | 166 | | |
204 | 167 | | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
209 | 176 | | |
210 | 177 | | |
211 | | - | |
| 178 | + | |
212 | 179 | | |
Lines changed: 26 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | 240 | | |
249 | 241 | | |
250 | 242 | | |
| |||
361 | 353 | | |
362 | 354 | | |
363 | 355 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
372 | 361 | | |
373 | 362 | | |
374 | 363 | | |
375 | 364 | | |
376 | 365 | | |
377 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
378 | 374 | | |
379 | 375 | | |
380 | 376 | | |
| |||
648 | 644 | | |
649 | 645 | | |
650 | 646 | | |
651 | | - | |
652 | | - | |
653 | | - | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
654 | 657 | | |
655 | 658 | | |
656 | 659 | | |
| |||
Lines changed: 1 addition & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | 48 | | |
67 | 49 | | |
68 | 50 | | |
| |||
0 commit comments