Merge remote-tracking branch 'origin/237958b2c8722ce0f87cf139d9e17988ea4d075c' into 237958b2c8

This commit is contained in:
alex phone S25
2026-05-28 18:34:57 +06:00
4 changed files with 126 additions and 9 deletions
@@ -0,0 +1,45 @@
# reflect-skip Android SAF Debug Log
## Root Cause Found (2026-05-28)
### Problem: #if SKIP blocks dead in Skip Fuse mode
The project uses SkipFuse (not transpile-mode Skip). In Fuse mode:
- `#if SKIP` is NOT defined — only `#if SKIP_BRIDGE` is active
- All SAF-based code in ProfileManager used `#if SKIP` guards
- Fallback iOS FileManager code ran instead → empty profile, 0 sessions, agent said "no data"
This affected ALL vault read/write operations:
- `loadProfile()` → returned ""
- `sessionCount` → returned 0
- `loadRecentSessions()` → returned ""
- `loadSessionDocuments()` (BM25 search) → returned []
- `appendSession()` / `updateProfile()` / `addInsight()` → wrote nothing
### Secondary Bug: HomeViewModel dead regex
`HomeViewModel.loadStats()` searched for `"Сессий проведено: (\d+)"` in profile.md.
This string is NEVER written anywhere in the codebase.
Fixed to use `ProfileManager.shared.sessionCount` (actual file count).
## Fix Applied
`Sources/ReflectApp/Services/ProfileManager.swift`:
- Added private SAF bridge helpers (`saf_read`, `saf_write`, `saf_list`, `saf_exists`, `saf_mkdirs`) using `AnyDynamicObject(forStaticsOfClassName: "reflect.app.AndroidAppMain")`
- Changed all `#if SKIP``#if SKIP_BRIDGE` throughout the file
- Added `#if SKIP_BRIDGE` blocks to methods that had no SAF guard: `appendToProfile`, `incrementSessionCount`, `loadSessionDocuments`, `updateSessionIndex`, `getSessionIndex`
`Sources/ReflectApp/ViewModels/HomeViewModel.swift`:
- Replaced dead regex with `ProfileManager.shared.sessionCount`
## Milestone History
| Date | Version | Milestone |
|------|---------|-----------|
| 2026-05-28 | 0.0.91 | Alert shows files found, buttons appear, HomeView loads |
| 2026-05-28 | 0.0.93 | SAF reads work in Fuse mode → sessions/profile visible |
## Pattern for future Skip Fuse code
In Skip Fuse projects, ALWAYS use `#if SKIP_BRIDGE` (not `#if SKIP`) for any Android-native calls.
Use `AnyDynamicObject(forStaticsOfClassName: "your.package.ClassName")` to call Kotlin companion object methods.