ebt-vue3 2.64.8 → 2.64.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/doc/inbound_link_bug.md +91 -0
- package/doc/startup_events.md +231 -0
- package/package.json +2 -2
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Research: Cards Disappearing on Startup
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
Users report "cards are disappearing." Investigation revealed **three independent but interacting bugs** in the startup/settings-hydration flow, not just the inbound-link regression. All three must be fixed together and in sequence for the symptom to be fully resolved.
|
|
5
|
+
|
|
6
|
+
## The Three Bugs
|
|
7
|
+
|
|
8
|
+
### Bug A — `isReady` Computed Gate is Inert (Root Cause)
|
|
9
|
+
**Location:** `src/App.vue:501-520`
|
|
10
|
+
|
|
11
|
+
The `isReady` computed is declared `async` inside Vue3 Options API `computed:` block. Vue3 does not await async computed getters — the computed's cached value is the `Promise` object itself, which is always truthy. This means:
|
|
12
|
+
- `<EbtCards v-if="isReady"/>` (line 104) has **never actually gated anything**
|
|
13
|
+
- EbtCards mounts immediately on every render, regardless of whether `settings.loaded` is true or cards exist
|
|
14
|
+
- The dead `return result;` branch at line 512 references an undefined variable (though this branch never executes because the Promise is always truthy before the async body even evaluates)
|
|
15
|
+
|
|
16
|
+
**Symptom:** EbtCards mounts before `settings.loadSettings()` completes, enabling Bug B.
|
|
17
|
+
|
|
18
|
+
### Bug B — Mount-Order Race Discards Freshly Created Cards
|
|
19
|
+
**Location:** Race between `src/App.vue:469` (`await settings.loadSettings()`) and `src/components/EbtCards.vue:57-69` (`EbtCards.mounted()`)
|
|
20
|
+
|
|
21
|
+
Because Bug A's gate never actually blocks, `EbtCards.mounted()` runs before `App.mounted()`'s `await settings.loadSettings(config)` resolves:
|
|
22
|
+
1. `EbtCards.mounted()` calls `cardFactory.pathToCard({path, addCard})`
|
|
23
|
+
2. This creates and pushes a new card into `settings.cards` via `#addCard` (card-factory.mjs:127-141)
|
|
24
|
+
3. When `loadSettings()` resolves, `src/stores/settings.mjs:85` runs `Utils.assignTyped(this, EbtSettings.INITIAL_STATE, savedState)`
|
|
25
|
+
4. `Utils.assignTyped` (src/utils.mjs:20-21) handles arrays by doing `dst[k] = [...value]` — it **replaces** the entire `settings.cards` array with a fresh copy built from the persisted `savedState.cards`
|
|
26
|
+
5. The card just pushed by `EbtCards.mounted()` is silently discarded
|
|
27
|
+
|
|
28
|
+
**Symptom:** Cards flash in then vanish on page load/refresh — visible, reproducible on every startup.
|
|
29
|
+
|
|
30
|
+
**Critical constraint:** `EbtSettings.INITIAL_STATE.cards = []` (src/ebt-settings.mjs:147). For a first-time visitor with no saved state, the *only* place a first card is created is inside `EbtCards.mounted()`. A gate that requires `cards.length > 0` would deadlock new users entirely, which is why the original `cards.length` branch in `isReady` is dead code.
|
|
31
|
+
|
|
32
|
+
### Bug C — Inbound-Link Mismatch Wipes All Settings, Not Just Cards
|
|
33
|
+
**Location:** `src/stores/settings.mjs`, `loadSettings()`, lines 71-73
|
|
34
|
+
|
|
35
|
+
When an inbound link points to a sutta not already in `savedState.cards`:
|
|
36
|
+
```javascript
|
|
37
|
+
if (context && !pathCard) {
|
|
38
|
+
savedState = null; // 🔴 wipes EVERYTHING
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This discards the entire hydrated settings object, losing:
|
|
43
|
+
- Theme (dark/light)
|
|
44
|
+
- Language preferences
|
|
45
|
+
- Audio volume
|
|
46
|
+
- Tutorial state
|
|
47
|
+
- All other persistent user configuration
|
|
48
|
+
|
|
49
|
+
**Symptom:** Following an inbound link to any new sutta (not already open) resets all user preferences.
|
|
50
|
+
|
|
51
|
+
## Why These Bugs Interact
|
|
52
|
+
|
|
53
|
+
The startup sequence is:
|
|
54
|
+
1. `App.mounted()` awaits `settings.loadSettings(config)` (line 469)
|
|
55
|
+
2. But because Bug A's gate is inert, `EbtCards` has already mounted (Bug B race setup)
|
|
56
|
+
3. When `loadSettings()` resolves, it may null `savedState` (Bug C), losing preferences
|
|
57
|
+
4. Then `Utils.assignTyped` replaces `settings.cards` wholesale (Bug B mechanism), losing any card created by prematurely-mounted EbtCards
|
|
58
|
+
|
|
59
|
+
All three must be fixed together:
|
|
60
|
+
- Fixing C alone doesn't stop cards from vanishing on ordinary loads (Bug B)
|
|
61
|
+
- Fixing A alone without understanding B's chicken-and-egg (cards-length gate vs. first-time-visitor startup) could deadlock new users
|
|
62
|
+
- Fixing B requires A to be real (a truly-blocking gate)
|
|
63
|
+
|
|
64
|
+
## Root Causes by Symptom
|
|
65
|
+
|
|
66
|
+
| User Reports | Root Cause | Triggered By |
|
|
67
|
+
|---|---|---|
|
|
68
|
+
| Cards disappear on page load/refresh | Bug B (mount race + array swap) | Every page load where Bug A is inert |
|
|
69
|
+
| Cards disappear after following inbound link | Bug C (`savedState = null`) | Following any link to a sutta not in saved cards |
|
|
70
|
+
| Settings (theme, lang) reset after inbound link | Bug C | Following any link to a sutta not in saved cards |
|
|
71
|
+
| First-time visitor sees nothing | Bug A (gate inert) + Bug B (race) + no existing cards | First page load with no saved state |
|
|
72
|
+
|
|
73
|
+
## The Fix Strategy
|
|
74
|
+
|
|
75
|
+
**Bug C (Fix First — Simplest, Most Isolated):**
|
|
76
|
+
```javascript
|
|
77
|
+
if (context && !pathCard) {
|
|
78
|
+
savedState.cards = []; // Clear only cards, preserve theme/lang/audio/tutorial
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
Narrow the blast radius. The `catch(e)` block's full `savedState = null` remains appropriate for genuinely corrupt stored data.
|
|
82
|
+
|
|
83
|
+
**Bug A (Fix Second — Structural):**
|
|
84
|
+
Replace the broken async computed with a real reactive boolean (`data.isReady`) driven by a `watch` handler. Gate only on `settings.loaded` (not `cards.length`, which would deadlock new users). Move `volatile.verifyState()` out of the gate into `App.mounted()` after `loadSettings()` resolves.
|
|
85
|
+
|
|
86
|
+
**Bug B (Fix Third — Automatic):**
|
|
87
|
+
No code change needed; falls out naturally once Bug A's gate is real. Verify via regression tests.
|
|
88
|
+
|
|
89
|
+
## References
|
|
90
|
+
- See `/Users/visakha/.claude/plans/we-are-in-planning-shiny-ripple.md` for full implementation plan
|
|
91
|
+
- Related: `doc/startup_events.md` — event-driven startup flow architecture
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# App Startup Event Flow
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
The EBT app startup is driven by **external system events** that cascade through stores and components. The process is not a linear sequence but rather event-driven, with multiple parallel and sequential flows depending on user history (URL, settings, cache).
|
|
5
|
+
|
|
6
|
+
**Critical Architectural Note: State Collision Risk**
|
|
7
|
+
The startup process involves a high-stakes interaction between **Route/URL events** and **Storage/Settings events**. Because the application's initial state (settings) is hydrated based on the current URL, external inputs like an inbound link can collide with the initialization sequence. If not handled carefully, a Route event can inadvertently trigger a reset of the entire Settings state during the hydration phase.
|
|
8
|
+
|
|
9
|
+
## External Event Sources
|
|
10
|
+
|
|
11
|
+
### 1. Window & DOM Events
|
|
12
|
+
**Keyboard Input**
|
|
13
|
+
- `window.addEventListener('keydown', ...)` — src/App.vue:497
|
|
14
|
+
- Routes key events to audio controls, navigation, or settings
|
|
15
|
+
|
|
16
|
+
**Focus Events**
|
|
17
|
+
- `window.addEventListener('focusin', ...)` — src/App.vue:498
|
|
18
|
+
- Tracks active element for accessibility and audio focus
|
|
19
|
+
|
|
20
|
+
**Resize Events**
|
|
21
|
+
- `document.defaultView.onresize` — src/stores/volatile.mjs:112
|
|
22
|
+
- Triggered by `displayBox` computed getter
|
|
23
|
+
- Updates viewport dimensions for responsive layout
|
|
24
|
+
|
|
25
|
+
### 2. Storage & Settings Events
|
|
26
|
+
**LocalStorage Load**
|
|
27
|
+
- `settings.loadSettings(config)` — src/App.vue:469
|
|
28
|
+
- **Timing:** Awaited during mounted hook (blocks until complete)
|
|
29
|
+
- Loads user preferences: theme, language, tutorial state, card positions
|
|
30
|
+
- Sets `settings.loaded = true` gate for downstream components
|
|
31
|
+
- **Risk:** Susceptible to state corruption if URL-based logic mutates the settings object during hydration.
|
|
32
|
+
|
|
33
|
+
**Settings Subscription**
|
|
34
|
+
- `settings.$subscribe((mutation, state) => ...)` — src/App.vue:493-495
|
|
35
|
+
- Reactive listener for all setting changes
|
|
36
|
+
- Updates theme, locale, persists changes to localStorage
|
|
37
|
+
- Unsubscribed on component destroy
|
|
38
|
+
|
|
39
|
+
**IndexedDB Cache**
|
|
40
|
+
- `Idb.get(idbKey)` — src/stores/volatile.mjs:207
|
|
41
|
+
- Retrieves cached suttas, search results, audio metadata
|
|
42
|
+
- Used during search and card rendering to avoid refetches
|
|
43
|
+
|
|
44
|
+
### 3. Route & URL Hash Events
|
|
45
|
+
**Initial URL Hash**
|
|
46
|
+
- `window.location.hash` — src/App.vue:466, 481
|
|
47
|
+
- Read during mounted hook
|
|
48
|
+
- Determines which card to load (wiki path vs home path)
|
|
49
|
+
- **Collision Risk:** Inbound hash changes can trigger logic in the settings store that may inadvertently reset the entire configuration state (e.g., wiping preferences while attempting to create a new card).
|
|
50
|
+
|
|
51
|
+
**Hash Change (Implicit)**
|
|
52
|
+
- Setting `window.location.hash = route` — src/stores/volatile.mjs:424
|
|
53
|
+
- Browser fires hashchange event (Vue Router listens)
|
|
54
|
+
- Triggers route change, loads new card content
|
|
55
|
+
|
|
56
|
+
**Route-to-Card Mapping**
|
|
57
|
+
- `cardFactory.pathToCard({path:route, addCard})` — src/App.vue:485-487
|
|
58
|
+
- Parses hash like `#/sutta/dn1/en/bhikkhu` into card data
|
|
59
|
+
- Returns null if route invalid (falls back to home)
|
|
60
|
+
|
|
61
|
+
### 4. Network Events
|
|
62
|
+
**Search API**
|
|
63
|
+
- `volatile.fetch(url)` → POST search query — src/stores/volatile.mjs:168, 594
|
|
64
|
+
- Called by search card render
|
|
65
|
+
- Returns results + mlDocs (multilingual content)
|
|
66
|
+
|
|
67
|
+
**Wiki Content**
|
|
68
|
+
- `volatile.fetchWikiHtml(card)` — src/stores/volatile.mjs:488-543
|
|
69
|
+
- Fetches static wiki HTML from `${config.basePath}/content/{path}.html`
|
|
70
|
+
- Retries with home page if not found
|
|
71
|
+
- Shows error if both fail
|
|
72
|
+
|
|
73
|
+
**JSON Fetches**
|
|
74
|
+
- `this.fetchJson(url)` — used for API responses
|
|
75
|
+
- Wraps `this.fetch()` and calls `.json()`
|
|
76
|
+
|
|
77
|
+
**Text Fetches**
|
|
78
|
+
- `volatile.fetchText(href)` — src/stores/volatile.mjs:447-463
|
|
79
|
+
- Used for wiki HTML, content files
|
|
80
|
+
- Warns on 404, returns undefined
|
|
81
|
+
|
|
82
|
+
### 5. Timer Events
|
|
83
|
+
**Deferred Audio Setup**
|
|
84
|
+
- `setTimeout(..., 2000)` — src/App.vue:470-479
|
|
85
|
+
- Waits 2 seconds after mount, then sets audio volume from settings
|
|
86
|
+
- Allows audio element to stabilize before setting properties
|
|
87
|
+
|
|
88
|
+
**Playback Progress**
|
|
89
|
+
- `setInterval(..., 100)` — src/stores/audio.mjs:509-523
|
|
90
|
+
- Updates audioElapsed during playback
|
|
91
|
+
- Accumulates playedSeconds for timeout tracking
|
|
92
|
+
- Clears on scid change (segment interruption)
|
|
93
|
+
|
|
94
|
+
**Waiting Indicator**
|
|
95
|
+
- `setTimeout(..., waitingDelay)` — src/stores/volatile.mjs:568-572
|
|
96
|
+
- Shows spinner only if wait > delay (avoids flash for fast operations)
|
|
97
|
+
- Used during search, wiki fetch, IDB operations
|
|
98
|
+
|
|
99
|
+
## Event Timeline During Startup
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
1. HTML loads, Vue mounts App component
|
|
103
|
+
↓
|
|
104
|
+
2. created() hook — optional logging setup
|
|
105
|
+
↓
|
|
106
|
+
3. mounted() hook begins:
|
|
107
|
+
├─ await settings.loadSettings() — BLOCKING GATE #1
|
|
108
|
+
│ └─ loads from localStorage or config defaults
|
|
109
|
+
│
|
|
110
|
+
├─ read window.location.hash
|
|
111
|
+
├─ determine card (wiki hash or home path)
|
|
112
|
+
├─ create initial wikiCard or homeCard
|
|
113
|
+
│
|
|
114
|
+
├─ set theme & locale from settings
|
|
115
|
+
├─ subscribe to settings changes
|
|
116
|
+
│
|
|
117
|
+
├─ addEventListener('keydown')
|
|
118
|
+
├─ addEventListener('focusin')
|
|
119
|
+
│
|
|
120
|
+
└─ setTimeout(2000) → set audio volume
|
|
121
|
+
|
|
122
|
+
4. Template renders:
|
|
123
|
+
├─ EbtProcessing (immediately)
|
|
124
|
+
├─ Settings (immediately)
|
|
125
|
+
├─ EbtChips if !collapsed
|
|
126
|
+
└─ EbtCards if isReady (BLOCKING GATE #2)
|
|
127
|
+
|
|
128
|
+
5. isReady computed:
|
|
129
|
+
├─ check settings.loaded
|
|
130
|
+
├─ check settings.cards.length > 0
|
|
131
|
+
└─ trigger EbtCards render when true
|
|
132
|
+
|
|
133
|
+
6. EbtCards mount:
|
|
134
|
+
├─ load route from window.location.hash
|
|
135
|
+
├─ fetch sutta content or wiki HTML
|
|
136
|
+
├─ render segments/chips
|
|
137
|
+
└─ call card.open() → sets isOpen
|
|
138
|
+
|
|
139
|
+
7. Parallel events continue:
|
|
140
|
+
├─ window resize → update displayBox
|
|
141
|
+
├─ hash change → navigate to new card
|
|
142
|
+
├─ search query → fetch + cache results
|
|
143
|
+
└─ audio playback → setInterval updates
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Blocking Gates
|
|
147
|
+
|
|
148
|
+
### Gate #1: Settings Loaded
|
|
149
|
+
```javascript
|
|
150
|
+
// src/App.vue:469
|
|
151
|
+
await settings.loadSettings(config);
|
|
152
|
+
```
|
|
153
|
+
- **Blocks:** App.mounted() continuation
|
|
154
|
+
- **Triggers:** Settings template render (line 92)
|
|
155
|
+
- **Impact:** Audio elements, theme, locale all wait on this
|
|
156
|
+
|
|
157
|
+
### Gate #2: Cards Ready
|
|
158
|
+
```javascript
|
|
159
|
+
// src/App.vue:104
|
|
160
|
+
<EbtCards v-if="isReady"/>
|
|
161
|
+
```
|
|
162
|
+
- **Blocks:** EbtCards component render
|
|
163
|
+
- **Depends on:** settings.loaded && settings.cards.length
|
|
164
|
+
- **Impact:** Defers content render until settings complete
|
|
165
|
+
|
|
166
|
+
## Debug Flags
|
|
167
|
+
Enable with `src/defines.mjs`:
|
|
168
|
+
```javascript
|
|
169
|
+
export const DBG_STARTUP = 1; // line 66 — overall startup sequence
|
|
170
|
+
export const DBG_APP_MOUNTED = 1; // — App.mounted() hook
|
|
171
|
+
export const DBG_IS_READY = 1; // — isReady gate transitions
|
|
172
|
+
export const DBG_ROUTE = 1; // — setRoute() hash navigation
|
|
173
|
+
export const DBG_FETCH = 1; // — network requests
|
|
174
|
+
export const DBG_HOME = 1; // — home/wiki path logic
|
|
175
|
+
export const DBG_KEY = 1; // — keyboard event routing
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Trace a specific flow:
|
|
179
|
+
```bash
|
|
180
|
+
# Watch for route changes
|
|
181
|
+
grep -n "setRoute\|DBG_ROUTE" src/**/*.{js,vue,mjs}
|
|
182
|
+
|
|
183
|
+
# Watch settings load
|
|
184
|
+
grep -n "loadSettings\|settings.loaded" src/**/*.{js,vue,mjs}
|
|
185
|
+
|
|
186
|
+
# Watch card factory
|
|
187
|
+
grep -n "pathToCard\|addCard" src/**/*.{js,vue,mjs}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Key Components & Stores
|
|
191
|
+
| Component | Role | Lifecycle |
|
|
192
|
+
|-----------|------|-----------|
|
|
193
|
+
| **App.vue** | Entry point, mounts stores, routes | mounted hook |
|
|
194
|
+
| **EbtProcessing** | Async work indicator | Immediate render |
|
|
195
|
+
| **Settings** | User preferences modal | Immediate render |
|
|
196
|
+
| **EbtCards** | Card display + content | Conditional (isReady) |
|
|
197
|
+
| **EbtChips** | Segment/search results | Conditional (!collapsed) |
|
|
198
|
+
| **settings store** | User prefs (theme, lang, cards) | loadSettings() on mount |
|
|
199
|
+
| **audio store** | Playback state, keyboard handling | useAudioStore() in data |
|
|
200
|
+
| **volatile store** | Transient state (route, waiting, focus) | useVolatileStore() in data |
|
|
201
|
+
|
|
202
|
+
## Common Startup Issues
|
|
203
|
+
|
|
204
|
+
**Issue: State Collision (Inbound Links)**
|
|
205
|
+
- **Symptom:** Following a link to a new sutta resets the user's theme, language, and other settings.
|
|
206
|
+
- **Cause:** The settings hydration logic (Gate #1) incorrectly resets the entire `savedState` object to `null` when an inbound URL context doesn't match the current `pathCard`.
|
|
207
|
+
- **Debug:** Set `DBG.APP_MOUNTED = 1` and watch for unexpected resets in `src/stores/settings.mjs`.
|
|
208
|
+
|
|
209
|
+
**Issue: Settings not loading**
|
|
210
|
+
- Check: localStorage disabled? config.js malformed?
|
|
211
|
+
- Debug: Set `DBG.APP_MOUNTED = 1`, watch for error in console
|
|
212
|
+
|
|
213
|
+
**Issue: Cards not rendering (stuck on loading)**
|
|
214
|
+
- Check: `settings.cards` array empty? `isReady` computed never true?
|
|
215
|
+
- Debug: Set `DBG_IS_READY = 1`, inspect `this.settings.loaded` and `this.settings.cards`
|
|
216
|
+
|
|
217
|
+
**Issue: Hash change not routing**
|
|
218
|
+
- Check: Card factory returning null? Invalid path format?
|
|
219
|
+
- Debug: Set `DBG_ROUTE = 1`, watch setRoute() calls
|
|
220
|
+
|
|
221
|
+
**Issue: Wiki HTML not loading**
|
|
222
|
+
- Check: Network tab for 404 on `/content/...html`
|
|
223
|
+
- Debug: Set `DBG_HOME = 1`, watch fetchWikiHtml() attempts and fallback
|
|
224
|
+
|
|
225
|
+
## References
|
|
226
|
+
- App entry: `src/App.vue` lines 456-499 (mounted hook)
|
|
227
|
+
- Route handling: `src/stores/volatile.mjs` lines 358-445 (setRoute)
|
|
228
|
+
- Card factory: `src/card-factory.mjs`
|
|
229
|
+
- Settings store: `src/stores/settings.mjs`
|
|
230
|
+
- Volatile store: `src/stores/volatile.mjs`
|
|
231
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ebt-vue3",
|
|
3
|
-
"version": "2.64.
|
|
3
|
+
"version": "2.64.10",
|
|
4
4
|
"description": "Vue3 Library for SuttaCentral Voice EBT-Sites",
|
|
5
5
|
"author": "Karl Lew",
|
|
6
6
|
"scripts": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"merkle-json": "^2.15.0",
|
|
42
42
|
"pinia": "^2.0.16",
|
|
43
43
|
"roboto-fontface": "*",
|
|
44
|
-
"scv-esm": "^1.140.
|
|
44
|
+
"scv-esm": "^1.140.226",
|
|
45
45
|
"serve-favicon": "^2.5.0",
|
|
46
46
|
"tmp": "^0.2.6",
|
|
47
47
|
"uuid": "^14.0.0",
|