docs(devlog): #83 save-indicator session log
CI / ci (push) Canceled after 0s

[Generated by AI]
This commit is contained in:
AlexKucera committed 2026-10-08 18:27:28 +02:00
1 parent fc0dde4f7c
commit 4e8865e660
3 files changed
+86 -20

No files matched your search

+27 -20
View File
@@ -129,30 +129,29 @@ Single-context: `CONTEXT.md` + `docs/adr/` at the repo root. See `docs/agents/do
<!-- gitnexus:start -->
# GitNexus — Code Intelligence
This project is indexed by GitNexus as **museion** (1308 symbols, 2519 relationships, 39 execution flows).
This project is indexed by GitNexus as **museion** (2285 symbols, 5850 relationships, 138 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
> Index stale? Run `node .gitnexus/run.cjs analyze --index-only` from the project root — it auto-selects an available runner. No `.gitnexus/run.cjs` yet? Bootstrap with `npx`, `bunx`, or `pnpm dlx` — e.g. `bunx gitnexus@latest analyze` (npm 11 npx crash; #1939).
> Index stale? Run `node .gitnexus/run.cjs analyze` from the project root — it auto-selects an available runner. No `.gitnexus/run.cjs` yet? `npx gitnexus analyze` (npm 11 crash → `npm i -g gitnexus`; #1939).
## Always Do
- **MUST run impact before editing.** Use `impact({target: "symbolName", direction: "upstream"})` or `node .gitnexus/run.cjs impact "symbolName" --direction upstream --repo .`; report callers, processes, and risk. Never substitute grep for graph analysis.
- **MUST analyze graph changes before committing.** Use `detect_changes({scope: "all"})` (MCP) or `node .gitnexus/run.cjs detect-changes --scope all --repo .` (CLI fallback). `partial: true` or `truncated: true` is not a clean check — a zero means unseen, not unaffected; re-run it. For regression review: `detect_changes({scope: "compare", base_ref: "main"})` or `node .gitnexus/run.cjs detect-changes --scope compare --base-ref "main" --repo .`.
- MUST warn on HIGH/CRITICAL `risk` pre-edit; never use `riskSharedAxes` to waive a HIGH/CRITICAL `risk` warning. Compare File/symbol: MCP File omits axes; Graph-RAG expands File.
- **MUST treat `risk: UNKNOWN` as unresolved, not as low.** An empty caller set is not evidence the symbol is unused — it can also mean the callers are not resolvable by the index (plain-object property access, dynamic dispatch, cross-language calls). `impact` pairs `UNKNOWN` with a `riskNote` saying so. Confirm with a text search before treating the symbol as safe to change or delete; do not proceed on the strength of a zero.
- **MUST use `query({search_query: "concept"})` for concepts/flows, `context({name: "symbolName"})` for a named symbol, or `impact` for blast radius, on read-only callers, dependencies, imports, or execution flow.** Graph first; text search only for empty/`UNKNOWN`/literals.
- For security review, `explain({target: "fileOrSymbol"})` lists taint findings (source→sink flows; needs `analyze --pdg`).
- **MUST run impact analysis before editing any symbol.** Before modifying a function, class, or method, run `impact({target: "symbolName", direction: "upstream"})` and report the blast radius (direct callers, affected processes, risk level) to the user.
- **MUST run `detect_changes()` before committing** to verify your changes only affect expected symbols and execution flows. For regression review, compare against the default branch: `detect_changes({scope: "compare", base_ref: "main"})`.
- **MUST warn the user** if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.
- When exploring unfamiliar code, use `query({query: "concept"})` to find execution flows instead of grepping. It returns process-grouped results ranked by relevance.
- When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use `context({name: "symbolName"})`.
## Never Do
- NEVER edit a function, class, or method before MCP/CLI impact analysis.
- NEVER ignore HIGH or CRITICAL risk warnings from impact analysis, and never read `UNKNOWN` as an all-clear — it means the walk could not answer, which is the one verdict that requires confirming by other means.
- NEVER edit a function, class, or method without first running `impact` on it.
- NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.
- NEVER rename symbols with find-and-replace — use `rename` which understands the call graph.
- NEVER commit before MCP/CLI graph change analysis.
- NEVER commit changes without running `detect_changes()` to check affected scope.
## Resources
| Resource | Use for |
| --- | --- |
|----------|---------|
| `gitnexus://repo/museion/context` | Codebase overview, check index freshness |
| `gitnexus://repo/museion/clusters` | All functional areas |
| `gitnexus://repo/museion/processes` | All execution flows |
@@ -161,13 +160,13 @@ This project is indexed by GitNexus as **museion** (1308 symbols, 2519 relations
## CLI
| Task | Read this skill file |
| --- | --- |
| Understand architecture / "How does X work?" | `.claude/skills/gitnexus-exploring/SKILL.md` |
| Blast radius / "What breaks if I change X?" | `.claude/skills/gitnexus-impact-analysis/SKILL.md` |
| Trace bugs / "Why is X failing?" | `.claude/skills/gitnexus-debugging/SKILL.md` |
| Rename / extract / split / refactor | `.claude/skills/gitnexus-refactoring/SKILL.md` |
| Tools, resources, schema reference | `.claude/skills/gitnexus-guide/SKILL.md` |
| Index, status, clean, wiki CLI commands | `.claude/skills/gitnexus-cli/SKILL.md` |
|------|---------------------|
| Understand architecture / "How does X work?" | `.claude/skills/gitnexus/gitnexus-exploring/SKILL.md` |
| Blast radius / "What breaks if I change X?" | `.claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md` |
| Trace bugs / "Why is X failing?" | `.claude/skills/gitnexus/gitnexus-debugging/SKILL.md` |
| Rename / extract / split / refactor | `.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md` |
| Tools, resources, schema reference | `.claude/skills/gitnexus/gitnexus-guide/SKILL.md` |
| Index, status, clean, wiki CLI commands | `.claude/skills/gitnexus/gitnexus-cli/SKILL.md` |
<!-- gitnexus:end -->
@@ -178,5 +177,13 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu
<!-- write-log: window-start -->
| Date | Log |
|------|-----|
| 2026-10-08 | [20261008-issue83-save-indicator-honesty_log.md](docs/devlog/20261008-issue83-save-indicator-honesty_log.md) |
| 2026-10-08 | [20261008-issue77-editing-parity_log.md](docs/devlog/20261008-issue77-editing-parity_log.md) |
| 2026-10-06 | [20261006-issue76-apex-html-reading_log.md](docs/devlog/20261006-issue76-apex-html-reading_log.md) || 2026-10-05 | [20261005-issue71-reading-toggle_log.md](docs/devlog/20261005-issue71-reading-toggle_log.md) || 2026-10-03 | [20261003-issue19-editor-core_log.md](docs/devlog/20261003-issue19-editor-core_log.md) || 2026-10-03 | [20261003-issue18-post-lifecycle_log.md](docs/devlog/20261003-issue18-post-lifecycle_log.md) || 2026-10-01 | [20261001-issue17-home-posts-list_log.md](docs/devlog/20261001-issue17-home-posts-list_log.md) || 2026-10-01 | [20261001-issue55-verdict-substrate-adr-0010_log.md](docs/devlog/20261001-issue55-verdict-substrate-adr-0010_log.md) || 2026-09-25 | [20260925-issue50-profile-backup-s2-6_log.md](docs/devlog/20260925-issue50-profile-backup-s2-6_log.md) || 2026-09-16 | [20260916-issue14-acp-bridge-s2-2_log.md](docs/devlog/20260916-issue14-acp-bridge-s2-2_log.md) || 2026-09-05 | [20260905-issue48-provisioning-failure-alert-retry-ux_log.md](docs/devlog/20260905-issue48-provisioning-failure-alert-retry-ux_log.md) |<!-- write-log: window-end -->
| 2026-10-06 | [20261006-issue76-apex-html-reading_log.md](docs/devlog/20261006-issue76-apex-html-reading_log.md) |
| 2026-10-05 | [20261005-issue71-reading-toggle_log.md](docs/devlog/20261005-issue71-reading-toggle_log.md) |
| 2026-10-03 | [20261003-issue19-editor-core_log.md](docs/devlog/20261003-issue19-editor-core_log.md) |
| 2026-10-03 | [20261003-issue18-post-lifecycle_log.md](docs/devlog/20261003-issue18-post-lifecycle_log.md) |
| 2026-10-01 | [20261001-issue17-home-posts-list_log.md](docs/devlog/20261001-issue17-home-posts-list_log.md) |
| 2026-10-01 | [20261001-issue55-verdict-substrate-adr-0010_log.md](docs/devlog/20261001-issue55-verdict-substrate-adr-0010_log.md) |
| 2026-09-25 | [20260925-issue50-profile-backup-s2-6_log.md](docs/devlog/20260925-issue50-profile-backup-s2-6_log.md) |
| 2026-09-16 | [20260916-issue14-acp-bridge-s2-2_log.md](docs/devlog/20260916-issue14-acp-bridge-s2-2_log.md) |<!-- write-log: window-end -->
@@ -0,0 +1,58 @@
# Save Indicator does not work after first save (#83)
> **Date:** 2026-10-08
> **Type:** issue
> **Reference:** https://git.babylondreams.de/AlexKucera/Museion/issues/83
## Goal
The save-state dot in the editor toolbar always read "Saved" for an open post — even with dirty, unflushed keystrokes. Only draft mode (the static "⌘S saves" label) was honest. Make the indicator tell the truth: maintainer's wording — dirty shows "Changed", clean shows "Saved", and "Saving…" is deleted (a synchronous write of small text files never lasts a render pass).
## What Was Done
- `SaveState` (Museion/EditorSession.swift): added `.changed`, deleted `.saving` (dead state — the flush is synchronous on the main actor, so "Saving…" could never paint).
- New `syncSaveState()` mirrors cleanliness: `text != lastFlushedText` → `.changed` (escalating from `.saved` only — `.failed` is sticky), equal → `.saved`. Called from `edit()` (every keystroke) and `keepLocal()`.
- `flush()` unchanged in behavior; the dead guard-branch `syncSaveState()` call was removed after review (`.changed`-while-clean is unreachable there).
- `reloadFromDisk()` now also calls `onError?(nil)` — dot and error strip agree after a Reload resolves a failure.
- `keepLocal()` (audit fix): dropped the `?? text` fallback on the disk read. If the post vanished while the conflict alert was up, the session now stays dirty — previously it computed `.saved` over text that existed only in memory, and ⌘S silently no-oped forever (data loss with "Saved" on screen).
- `SaveStateDot` (Museion/PostEditorView.swift): label "Changed"; switch stays exhaustive.
- Tests (MuseionTests/EditorSessionTests.swift): new `dirty edits show Changed until flushed; reverting to flushed text clears it` (dirty-during-debounce, flush→Saved, revert-to-flushed-content→Saved, keepLocal→Changed, vanished-mid-alert→stays dirty→flush→failed); sticky-`.failed` pinned both via revert-to-flushed and via further edits; two stale expectations that had encoded the lying "Saved" were fixed.
- Docs: `Museion/AGENTS.md` editor-core bullet and the `CHANGELOG.md` Unreleased M1 entry updated to the Changed→Saved state machine.
## Decisions & Rationale
| Decision | Rationale |
|----------|-----------|
| "Changed" label, not "Unsaved Changes" | Maintainer's pick between the two offered wordings; shorter, matches the dot's size. |
| Delete `.saving` entirely | Maintainer call: the synchronous `PostStore.overwrite` of small markdown files finishes within one render pass — the state was unreachable UI. Deletion over addition. |
| `.failed` is sticky until a write actually succeeds | Never claim "Saved" without a verified write. Cries wolf (revert-to-flushed still shows failed) rather than falsely reassuring — conservative side chosen deliberately; the security review confirmed this bias. |
| `keepLocal` keeps old `lastFlushedText` when disk is unreadable | The vanish-teardown in PostsModel only fires on the next watcher tick, so the mid-alert race window is real. Staying dirty keeps ⌘S armed — the write is then attempted and fails loudly. |
| `reloadFromDisk` clears `.failed` without a write | After Reload, shown text == disk, so "Saved" is true; documented with a comment at the call site. |
## Gotchas & Fixes
| Problem | Root Cause | Fix |
|---------|------------|-----|
| Indicator lied "Saved" while dirty | `saveState` only ever mutated inside `flush()`; nothing represented the debounce-held-dirty window | `syncSaveState()` on `edit()`/`keepLocal()` |
| First eta test failed as written | Test asserted revert-to-"Base." = clean, but disk held the flushed "Dirty." — dirty means ≠ *last flushed*, not ≠ original | Test fixed to assert both directions honestly |
| `swiftformat .` reformatted 19 files (spike/, prototypes/, 5 app files) | Repo-root run hits space-indented spike dirs — collateral churn beyond the change | Reverted all but the session's files; scope swiftformat to touched files |
| Reviewers flagged the guard-branch `syncSaveState()` comment as a lie | The comment claimed it cleared stale `.failed`; the code couldn't (and shouldn't) | Removed the dead call; stickiness now test-pinned instead |
| Security review: vanished-post + Keep Local = lying "Saved" + dead ⌘S | `?? text` fallback adopted local text as flushed when disk read failed | `if let disk =` — only a real read updates `lastFlushedText` |
## Files Changed
| File | Change Summary |
|------|---------------|
| `Museion/EditorSession.swift` | `.changed` added, `.saving` deleted, `syncSaveState()`, `onError?(nil)` on reload, `keepLocal` disk-read guard, doc comments |
| `Museion/PostEditorView.swift` | `SaveStateDot` label "Changed"; `.saving` case removed |
| `MuseionTests/EditorSessionTests.swift` | New dirty/sticky/vanished tests (+53/−3); stale expectations corrected |
| `Museion/AGENTS.md` | Editor-core bullet: Changed→Saved state machine, #83 |
| `CHANGELOG.md` | Unreleased M1 entry amended (honest dot wording) |
## Open Items & Next Steps
- None for #83. (PRD.md carries the maintainer's own unrelated edit — deliberately left out of this commit.)
---
*Log written by write-log skill*
+1
View File
@@ -5,6 +5,7 @@ Complete history of session logs in this directory, newest first. One-line summa
<!-- write-log: full-index -->
| Date | Type | File | Summary |
|------|------|------|---------|
| 2026-10-08 | issue | [20261008-issue83-save-indicator-honesty_log.md](20261008-issue83-save-indicator-honesty_log.md) | #83 honest save dot: Changed while dirty, Saving… deleted, sticky failed, vanished-disk keepLocal fix — 106 tests green |
| 2026-10-08 | issue | [20261008-issue77-editing-parity_log.md](20261008-issue77-editing-parity_log.md) | #77 editing parity: reading-mirrored presenter (30/22/19 ladder, inline traits, 66ch measure), fence-staleness audit fix — 104 tests green |
| 2026-10-06 | issue | [20261006-issue76-apex-html-reading_log.md](20261006-issue76-apex-html-reading_log.md) | #76 apex HTML reading surface: WKWebView + bundled apex, data-source-line map, TextKit reading deleted — 94 tests green, PERF-3k 20 ms |
| 2026-10-05 | issue | [20261005-issue71-reading-toggle_log.md](20261005-issue71-reading-toggle_log.md) | #71 reading toggle: block-aware renderer, tap-to-edit canvas, typography slots, kitchen-sink — 94 tests green |