diff --git a/AGENTS.md b/AGENTS.md index b8007b4..2069032 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -177,14 +177,14 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu | Date | Log | |------|-----| +| 2026-12-04 | [20261204-microblog-5xx-wording-token-settings-page_log.md](20261204-microblog-5xx-wording-token-settings-page_log.md) | | 2026-12-03 | [20261203-issue205-reveal-in-finder-copy-path_log.md](20261203-issue205-reveal-in-finder-copy-path_log.md) | | 2026-12-03 | [20261203-issue204-fix-cards-jump-to-the-anchor_log.md](20261203-issue204-fix-cards-jump-to-the-anchor_log.md) | +| 2026-12-03 | [20261203-release-012-image-drop-fix_log.md](20261203-release-012-image-drop-fix_log.md) | | 2026-12-03 | [20261203-image-drop-27-2-drag-routing-pastes-path_log.md](20261203-image-drop-27-2-drag-routing-pastes-path_log.md) | | 2026-12-03 | [20261203-release-011-apex-refresh-is-step-one_log.md](20261203-release-011-apex-refresh-is-step-one_log.md) | | 2026-12-01 | [20261201-release-010-readme-notes-packaging_log.md](20261201-release-010-readme-notes-packaging_log.md) | | 2026-11-30 | [20261130-external-watch-compares-unnormalized-text_log.md](20261130-external-watch-compares-unnormalized-text_log.md) | | 2026-11-23 | [20261123-home-repoint-retains-old-editor-target_log.md](20261123-home-repoint-retains-old-editor-target_log.md) | | 2026-11-19 | [20261119-issue200-gate-quit-time-flushes-through-departure-gate_log.md](20261119-issue200-gate-quit-time-flushes-through-departure-gate_log.md) | -| 2026-11-17 | [20261117-acp-backpressure-defeats-timeout-and-shutdown_log.md](20261117-acp-backpressure-defeats-timeout-and-shutdown_log.md) | -| 2026-11-17 | [20261117-issue193-split-fat-files-along-postsmodel-pattern_log.md](20261117-issue193-split-fat-files-along-postsmodel-pattern_log.md) | \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 880e643..05ed413 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,16 @@ All notable changes to this project will be documented in this file. The format ### Added +- **settings:** **Micro.blog** page in Settings — the app token's home (unticketed; owner report 2026-12-04) — the token could only be entered in the publish sheet, and that field came back only after a 401/403, so a saved token had no standing way to be replaced or removed (a 503 left the writer stuck with whatever was stored). The new sidebar destination, after Provider Keys, writes the SAME login-keychain slot the sheet reads (`MicropubTokenStore`): a status row under the field (✓ Token saved in your Keychain / No token saved), a Save field that replaces the stored token, and a Remove button while one is stored. `saved` is read back from the Keychain after every write instead of assumed — a locked keychain fails the save and the status row says so rather than claiming "stored". The publish sheet picks up a Settings-saved token unchanged, and names it when it sends with the stored one (the field's absence alone never said which token a send carried). No new pins (a view over the already-pinned token store; the repo pins pure seams, not SwiftUI). Suite 736 + - **library:** **Reveal in Finder** and **Copy Path** on every piece row — the library column's menu and the Archive pane's (#205) — one shared `FinderHandOffButtons` fragment in the workspace chrome over a model-resolved path: `PostsModel.fileURL(for:)` answers the piece's `post.md` through the one `PostStore.folder(of:home:)` resolver against the watched Home (never the scan snapshot), and a vanished piece answers nil so both entries no-op instead of revealing a stale path. Reveal selects the file in Finder; Copy Path puts the POSIX path on the pasteboard (Finder's own form; the pasteboard is cleared first). Library placement sits between Move to Archive and the destructive Trash behind a divider; the Archive menu appends after Convert. +3 tests (projects/ resolve, archive/ resolve, vanished → nil), flip-verified — bypassing the resolver reddens exactly the vanished and archive pins. Suite 735 - **fix cards:** **Jump** on a Fix Card selects the anchor's span in the piece's editor and makes the main window key (#204) — the borderless button sits in every non-stale card's action row (closed cards keep it; a stale anchor has nothing to land on); the span is the card's quote at its 1-based occurrence, resolved against the LIVE session text so a dirty buffer still lands, and it rides the reading flip-back's caret rail (one token counter; a zero-length hint stays a bare caret, a non-zero range selects). A jump leaves reading mode first, writes nothing, and re-fires on every click. Two review rounds closed the view-layer gaps the pure pins could not see: a jump dropped in reading mode, a main window that never became key (`NSApp.activate` is a no-op once the palette's click activated the app), a leading-blank caret hop that moved a span onto the title, and a cursor record taken before the scroll. +3 tests (`anchorRange` occurrence math with a UTF-16 fixture, the model's reveal stamp, the editor's `landingSpan`), all flip-verified. Suite 732 +### Fixed + +- **publish:** A Micro.blog 5xx names their outage instead of a bare `HTTP 503` (unticketed; owner report 2026-12-04) — their errors arrive as HTML pages, never Micropub JSON, so `decodeFailure` fell through to the status code and the sheet read "Micro.blog said 503: HTTP 503", which says nothing about whose side it is on. A live probe at report time found the endpoint healthy (25/25 tokenless POSTs answered the usual 400; their news feed logs repeated 503 incidents), so the 503 was theirs and transient. The decode now answers `unavailable on their side — retry in a few minutes (status.micro.blog)` for any 5xx that carries no JSON description — ONE decode, so create, publish, q=config, and media uploads all speak it; a described 5xx keeps its description, a 4xx keeps the bare status. +1 test (a 503 over an HTML body → the their-side wording; a 422 over the same body → `HTTP 422`; a 502 with `error_description` → the description), flip-verified — the guard off reddens exactly that pin with `detail → "HTTP 503"`. Suite 736 + ## [0.1.2] - 2026-12-03 Human-readable notes: [docs/releases/0.1.2.md](docs/releases/0.1.2.md). diff --git a/Museion/AGENTS.md b/Museion/AGENTS.md index 02a3a5a..b4fae55 100644 --- a/Museion/AGENTS.md +++ b/Museion/AGENTS.md @@ -40,7 +40,7 @@ The map and the contracts, one bullet per file. Pin-level detail lives in the te - `DeslopLint.swift` — the deslop skill's findings computed in Swift at pass invocation (no engine round-trip; a failed lint never blocks a pass). `Resources/deslop-lint.json` bundled default; `/deslop-lint.json` override wins when it exists AND decodes, any failure → bundled. Whole-word ICU matches; em-dash finding first, then tiers by first-match position; `emit` dedups against OPEN cards (closed never block, re-runs make progress). - `Pass.swift` — `PassKind` (pass1/pass2 — the app's own names) + `PassContext.stub` (the pinned minimal engine prompt: verdict in the reply, findings as fix-card tool calls, research as candidate tool calls — the engine never writes to the piece folder) + `estimateTokens` (chars/4). - `BlindRead.swift` — neutral "Version A/B" prompt (both bodies inline, origin-free words never appear — the judge must not know which is the rewrite; caller randomizes order), ask = pick + one line why; `reveal` mapping appended by the model ONLY after the turn ends. -- Micropub (`Micropub.swift`, `MicropubMedia.swift`, `MicropubPublishSheet.swift`) — the Micro.blog publish path. Client over the injectable Transport: draft = h=entry (name, markdown content verbatim, post-status draft, sorted keys; `category:` frontmatter NEVER travels; NO `photo` property — uploaded illustrations ride INLINE in content, refs rewritten to uploaded URLs on the WIRE only, the piece on disk never changes). Every URL through `trustworthyURL` (https + host + no line/control characters — the URL is trust-boundary data landing in frontmatter); 401/403 → authFailed with `error_description`; `preview` is display-only, never the publish target. `MicropubTokenStore` = the app's own login-keychain credential (ADR-0014's no-Keychain rule covers only provider keys). Media: `illustrations(in:)` parses only `![alt](assets/…)` refs (remote refs ride as prose; multi-line alts don't parse at all — by design); parse + rewrite share ONE regex; markdown-active URLs ride the angle form. The model rail (`uploadIllustrations`) is the publish FLOOR: whitespace-empty alt refuses BEFORE any wire traffic, payload reads are contained (`../` or a symlinked asset refuses), uploads are all-or-nothing, style judgment stays with the author. The sheet owns Send as Draft → Publish, each an explicit click; refusals inline with buttons kept. +- Micropub (`Micropub.swift`, `MicropubMedia.swift`, `MicropubPublishSheet.swift`) — the Micro.blog publish path. Client over the injectable Transport: draft = h=entry (name, markdown content verbatim, post-status draft, sorted keys; `category:` frontmatter NEVER travels; NO `photo` property — uploaded illustrations ride INLINE in content, refs rewritten to uploaded URLs on the WIRE only, the piece on disk never changes). Every URL through `trustworthyURL` (https + host + no line/control characters — the URL is trust-boundary data landing in frontmatter); 401/403 → authFailed with `error_description`; a 5xx over Micro.blog's HTML error page names their outage (`unavailable on their side — retry in a few minutes`), never a bare `HTTP 503` — ONE decode (`decodeFailure`), every step; `preview` is display-only, never the publish target. `MicropubTokenStore` = the app's own login-keychain credential (ADR-0014's no-Keychain rule covers only provider keys) — entered in the sheet on first use, managed from Settings → Micro.blog (saved status, replace, remove; the page reads the slot back after every write — a locked keychain fails visibly, never a false "stored"; the status is a standing `✓ Token saved in your Keychain` row in the Settings verdict idiom, not an intro-line swap). Media: `illustrations(in:)` parses only `![alt](assets/…)` refs (remote refs ride as prose; multi-line alts don't parse at all — by design); parse + rewrite share ONE regex; markdown-active URLs ride the angle form. The model rail (`uploadIllustrations`) is the publish FLOOR: whitespace-empty alt refuses BEFORE any wire traffic, payload reads are contained (`../` or a symlinked asset refuses), uploads are all-or-nothing, style judgment stays with the author. The sheet owns Send as Draft → Publish, each an explicit click; refusals inline with buttons kept; with a stored token in use it names it (the field's absence alone never said which token a send carries). - `PostsModel.swift` — @MainActor @Observable, app-scoped. Domain extensions live in their own files (guard+Convert `PostsModelOutline.swift`, passes+Blind Read `PostsModelPasses.swift`, fix cards `PostsModelCards.swift`, write rail+structural ops `PostsModelWrites.swift`, external guest+imports `PostsModelImports.swift`, watcher+rescan `PostsModelWatcher.swift` (home of `PostsWatcher`), (Home, ID) identity `PostsModelIdentity.swift` — `openSessionTargets` + #205 `fileURL(for:)`, the row menus' post.md path, a pure read) — the #146/#193 splits. **#179 write rail**: every library store write (draft save, session-born post, rename, move to project, archive/restore, trash, convert, project creation, import batch, pass advance) rides `performWrite` — ONE seam pairing the write with exactly one rescan and owning the error strip (cleared BEFORE the write, so importFiles' mid-closure per-file failures survive; a nil-Home refusal writes nothing); the MODEL owns the Home (`watchedHome` — written only by the watcher extension's `startWatching` behind `bind`, driven by WorkspaceView's root `.task(id: museionHome)` (first frame + every repoint, whichever pane is showing); no public method takes a Home parameter); the editor's debounced flush and the micropub publish stay OUTSIDE the rail (own error semantics). `PostDraft` in-memory until first save; `mountID` keys the editor `.id` so every staging REMOUNTS (the outliner re-seeds its tree). Mixed-outline guard: a lossy outline select HOLDS the ask over an empty editor (nothing can normalize on ⌘S before the choice); reselect of the held piece is a no-op. Convert: consent rechecked at answer time (Headings aborts when the body went lossy behind the ask); converting the open piece tears down and reopens routed prose. `runPass` chain: guards through `guardOpenPieceRun` (#181: the ONE guard rail shared with blindRead — nothing running, mentor not mid-turn, engine ready, open saved piece) → readiness (missingKey names the provider) → flush → snapshot (unconditional, even for a later cancel) → capture stats → lint emit → `runningPass` live → own-engine run → advance ONLY on `.ended` with stopReason ≠ "refusal"; #179 audit: a Home repoint across the engine's turn REFUSES the advance with a strip message (the rail resolves `watchedHome` at call time — stamping into the repointed library would be silent on a slug collision). `blindRead` rides the same guard rail; nothing advances or records. `refreshCards` rides the rescan + open tails; `applyCard` = flush-first, stale anchor flags the card with no text change, the edit lands through `EditorSession.adoptText`; `promoteCard` writes a Learning and touches no text; #204 `revealCard` stamps ONE `revealRequest` (the anchor's span in the LIVE session text + a per-jump token) — a view act, nothing written; the editor column feeds it into the #71 caret rail (`caretHint`, now a `FixCardRevealRequest` — a non-zero range selects the span). `micropubSendDraft` = flush-first, ONE disk read serves both wire fields, success stamps `micropub_url`. `canArmWritingLock`/`editorBodyText` mirror the editor's outline routing (prose only). #200: quit is a document departure — `shutdown()` routes both sessions through `documentsMayDepart` (void — the verdict channel is quitReply's); `PostsModel.active` (weak static, registered by `AppGateState.init` — the `WritingLockState.active` precedent) is the quit gate's reachability, bare test rigs never register. - `PostsModelWatcher.swift` — #193: the watching domain of PostsModel (moved from PostsModel.swift) — `PostsWatcher` (recursive FSEvents stream, file-level, 0.5 s latency) on BOTH `projects/` and `archive/`; `bind(home:)` (WorkspaceView's root `.task(id: museionHome)` drives it); `startWatching` (the one `watchedHome` writer); `rescan` off-main through the app-scoped scan cache, skipping the `posts` assignment on equality (@Observable invalidates on assignment — panes would regroup on autosave echoes), bumping `contentRevision` on list change OR cache miss (#144), handing the session the open post's disk text (the #67 check, watcher echo suppressed by equality), riding the cards refresh at the tail. - `PostsModelWrites.swift` — #193: the #179 write rail + structural ops (moved from PostsModel.swift) — `performWrite` (ONE seam: write + exactly one rescan + the error strip, cleared before the write), `flushOrAbort` (flush-first; a failed write, an unanswered #67 conflict, or a never-loaded session's retyped words abort with nothing changed — the alert stays up), `documentsMayDepart` (#200: the departure gate's quit run — shutdown's flush half shared with `applicationShouldTerminate`; BLOCK-QUIT posture, never silently drop), rename, trash, the #108 project ops (create/stage, `moveTargets`, move to project, archive/restore/unarchive); document departure (new post/outline, select, open external, guest dismissal) rides the same gates through `sessionMayDepart`/`departOpenDocuments` — a navigation whose outgoing flush fails aborts with the dirty session retained (brief-25). @@ -52,7 +52,7 @@ The map and the contracts, one bullet per file. Pin-level detail lives in the te - `FileDropTextView.swift` — the editor text views' drag base (macOS 27.2.1 routing): a live NSTextView registers itself for drag types and receives the drag a window-level SwiftUI destination never sees; URL-bearing drops route through `onFileDrop` (nil = bounce), text-only drops keep the stock drop, everything else bounces — never `super` for URLs (stock NSTextView pastes the dropped file's PATH via `readSelection` on NSFilenamesPboardType). The pasteboard probe is memoized per `changeCount` (`draggingUpdated` fires per mouse-move). - Editor core — `ProsePresenter.swift` (line-kind → attributes map mirroring the reading surface; plain store stays the source of truth — presentation-only attributes, ADR-0010). `EditorSession.swift` — per-document session: `SessionTarget` (post | external file), ~1 s debounce → `flush` (⌘S / selection change / quit also flush); externals write in place with NO sidecar; `loadFailed` never opens a writable empty session over a failed read (the first keystroke would destroy the file); the #67 conflict raises when disk ≠ last-flushed ≠ local, and the debounce never fires while the alert is unanswered; `adoptText` = programmatic writer-consented adoption (the #67 guard is the CALLER's job). Cursor sidecar `.museion-state.json` in the piece folder, written separately (a failed sidecar is not a failed save). `PostEditorView`/`ProseTextView` — plain NSTextView representable, loads keyed by `loadGeneration` (never per keystroke); spellcheck off by default (markdown on disk carries the spelling). `ProseListTextView` rides `FileDropTextView` with `onFileDrop` → the gate's `routeFileDrop`, so file drags landing on it ingest (never paste the path); `lastIngestNotice` is the refusal text the pins read. - Prose list machinery — `ProseList.swift` (pure item scan/mutation over the plain buffer; every structural edit is ONE range replacement = single undo step); `ProseListTextView.swift` — folds are VIEW state (buffer never changes; hidden scopes styled via `foldedAttributes`), re-keyed to the nearest same-marker parent, dying when the marker text vanishes; single-line edits re-key in place (`rekey`), the newline gate is `\.isNewline` NEVER literal `\n`/`\r` compares (a CRLF pair is one grapheme); wholesale restyles self-heal into the full pass via a font probe. Fold chrome renders as tiny per-glyph CALayers in a click-through overlay — NEVER a document-sized bitmap. Image drops bridge through `ProseDropBridge` into `ingestDrop` (saved posts only, publishable files only, PLAIN files only — a dropped symlink refuses); the drop point is solved by the pure `dropIndex` (sampling + bracket + binary search; the SwiftUI closure's `location` is unusable under this hosting, off-screen rects return garbage). -- Settings — `SettingsPaneView.swift` (sidebar + detail: Content · Pass 1 · Pass 2 · Chat · Provider Keys; the pane takes the gate's `binaryPath` and hydrates at open; detail forms left-anchored). `SettingsModel.swift` — #181: `ModelProvider` is the provider-descriptor TABLE — label, effort ladder, flagship, default endpoint, env var, wire `dialect` (chat/models paths + the SSE decoder selector), `authMode` (Bearer vs Anthropic's header pair), `keyless` (nous rides the shared Portal login); the keyless UI branch, the probe's selectors, and both credential consumers key off it. `ProviderCredential` = the ONE credential resolution (provider key, else the Portal session key for keyless providers — official endpoint ONLY, never a user-set URL) serving Test Connection and pass readiness. Writes COALESCE: the newer write queues past an in-flight one, superseded writes never spawn (partial key prefixes of a secret never reach `.env`); `hydrate` reads only and never stomps a pending edit. `HermesSettingsWriter.swift` — the real write path: surface writes and the base_url write-through ride the HermesConfigRail (#182 — the writer only builds its key list: provider, default, effort set-or-unset, base_url LAST); provider keys upsert into ALL THREE profiles' `.env` (foreign lines byte-preserved, 0600, line-broken values REFUSED — env injection; paths via ProfileLayout). `ProviderProbe.swift` — Test Connection: every request carries `Content-Type: application/json` (without it z.ai answers 200 with an error envelope); per-provider dialects (OpenAI speaks the Responses API, Anthropic `x-api-key` + pinned version + required max_tokens, zai thinking+reasoning_effort, nous plain chat-completions) — #181: URL paths, auth shape, and the SSE decoder SELECT by the descriptor's dialect, the per-dialect code stays separate functions; 512 token cap; errors riding a 2xx decode as the provider error. `onChatSurfaceWrite` → `requestRestart` (chat surface only — pass engines are one-shot). `PassReadiness.swift` — #181: the per-surface readiness module (ready / missingKey / unknown): reads each surface's provider + `.env` key through the settings seam and resolves credentials through `ProviderCredential` (the keyless fallback included); MentorSessionModel stores the verdicts and reads no keys or auth files itself. +- Settings — `SettingsPaneView.swift` (sidebar + detail: Content · Pass 1 · Pass 2 · Chat · Provider Keys · Micro.blog (the app token's home — `MicroblogSettingsPage` in SettingsPagesView.swift: a standing saved-status row / replace / remove over `MicropubTokenStore`); the pane takes the gate's `binaryPath` and hydrates at open; detail forms left-anchored). `SettingsModel.swift` — #181: `ModelProvider` is the provider-descriptor TABLE — label, effort ladder, flagship, default endpoint, env var, wire `dialect` (chat/models paths + the SSE decoder selector), `authMode` (Bearer vs Anthropic's header pair), `keyless` (nous rides the shared Portal login); the keyless UI branch, the probe's selectors, and both credential consumers key off it. `ProviderCredential` = the ONE credential resolution (provider key, else the Portal session key for keyless providers — official endpoint ONLY, never a user-set URL) serving Test Connection and pass readiness. Writes COALESCE: the newer write queues past an in-flight one, superseded writes never spawn (partial key prefixes of a secret never reach `.env`); `hydrate` reads only and never stomps a pending edit. `HermesSettingsWriter.swift` — the real write path: surface writes and the base_url write-through ride the HermesConfigRail (#182 — the writer only builds its key list: provider, default, effort set-or-unset, base_url LAST); provider keys upsert into ALL THREE profiles' `.env` (foreign lines byte-preserved, 0600, line-broken values REFUSED — env injection; paths via ProfileLayout). `ProviderProbe.swift` — Test Connection: every request carries `Content-Type: application/json` (without it z.ai answers 200 with an error envelope); per-provider dialects (OpenAI speaks the Responses API, Anthropic `x-api-key` + pinned version + required max_tokens, zai thinking+reasoning_effort, nous plain chat-completions) — #181: URL paths, auth shape, and the SSE decoder SELECT by the descriptor's dialect, the per-dialect code stays separate functions; 512 token cap; errors riding a 2xx decode as the provider error. `onChatSurfaceWrite` → `requestRestart` (chat surface only — pass engines are one-shot). `PassReadiness.swift` — #181: the per-surface readiness module (ready / missingKey / unknown): reads each surface's provider + `.env` key through the settings seam and resolves credentials through `ProviderCredential` (the keyless fallback included); MentorSessionModel stores the verdicts and reads no keys or auth files itself. - Focus mode — transient per-launch (no persistence); `FocusChrome` hover zones + overlay panels float over the measure, never push it; `CaretCentering` is EDITOR-WIDE, not focus-gated; focus × reading are orthogonal axes. Cold Turkey chrome (`ColdTurkeySeat`/`ColdTurkeyDot`) mounts as overlays on the focused branch only. - Reading mode (ADR-0011) — `ReadingPresenter.swift`: the bundled apex binary (arm64, Developer ID–signed with the hardened runtime at commit time, beside `libyaml.bundle/libyaml-0.2.dylib` — self-contained through the single rpath `@executable_path/../Resources/libyaml.bundle`; the `.bundle` wrapper is load-bearing: a bare dylib in the synced folder (with or without extension — Xcode sniffs Mach-O content) becomes the APP's link target; re-sign both when the Developer ID certificate rotates) with `-t html --no-mixed-lists --embed-images` (no-mixed-lists REQUIRED — the default merges ordered-after-bullets, killing `1. 1. 1.` renumbering; embed-images inlines base64 so `loadHTMLString` needs no file access); `` sentinels rewritten to `data-source-line` stamps; `blocks(for:)` = the click→edit line map; stylesheet = `Resources/reading.css` read fresh per build (dev builds prefer the repo copy); fallback on apex failure = escaped source, never a second renderer. `ReadingSurface.swift` — ONE WKWebView reloaded in place (remount was the dominant switch cost); only our own about:blank main-frame load is allowed. - `AppGateState.museionHome` — fresh installs resolve once and PIN the winner: legacy `~/Documents/Museion` (dir-ness gated) → `/Museion` (resolved at the unprefixed path, never a hard-coded `iCloud~` form) → silent Documents fallback. Hosted tests take an early return — the machine's real iCloud state and defaults are never touched. diff --git a/Museion/Micropub.swift b/Museion/Micropub.swift index 0f19c66..f9928ec 100644 --- a/Museion/Micropub.swift +++ b/Museion/Micropub.swift @@ -168,13 +168,21 @@ nonisolated enum Micropub { /// Internal for MicropubMedia's media steps (#34) — the one failure /// decode this client speaks; extensions share it rather than fork it. + /// A 5xx is Micro.blog's side (their nginx front with the app not + /// answering behind it, or a rate limit) and arrives as an HTML page, + /// never Micropub JSON — so the fallback names the outage instead of + /// a bare `HTTP 503` (2026-12-04: a 503 in the sheet while the + /// endpoint answered its usual 400 to a tokenless probe minutes later). static func decodeFailure(status: Int, body: Data) -> Outcome { let root = (try? JSONSerialization.jsonObject(with: body)) as? [String: Any] ?? [:] - let detail = (root["error_description"] as? String) ?? (root["error"] as? String) ?? "HTTP \(status)" + let described = (root["error_description"] as? String) ?? (root["error"] as? String) if status == 401 || status == 403 { - return .authFailed(detail) + return .authFailed(described ?? "HTTP \(status)") } - return .requestFailed(status: status, detail: detail) + let fallback = (500 ... 599).contains(status) + ? "unavailable on their side — retry in a few minutes (status.micro.blog)" + : "HTTP \(status)" + return .requestFailed(status: status, detail: described ?? fallback) } } diff --git a/Museion/MicropubPublishSheet.swift b/Museion/MicropubPublishSheet.swift index 9ac72e0..7c68591 100644 --- a/Museion/MicropubPublishSheet.swift +++ b/Museion/MicropubPublishSheet.swift @@ -7,8 +7,9 @@ // sheet owns the whole two-step flow over the OPEN piece: Send as // Draft (h=entry, name, markdown content) → review on Micro.blog → // Publish (the post-status update against the piece's remembered -// draft URL). The app token is entered here ONCE and lives in the -// Keychain (G11; re-offered only on an auth failure). Refusals show +// draft URL). The app token is entered here when none is saved and +// lives in the Keychain (G11; re-offered only on an auth failure — +// Settings → Micro.blog is the standing manager). Refusals show // inline with the buttons kept (ApplyAskSheet posture). // @@ -60,6 +61,12 @@ struct MicropubPublishSheet: View { Text("From micro.blog → Account → App Tokens. Stored in your Keychain.") .font(.system(size: 11, design: DesignTokens.mono)) .foregroundStyle(DesignTokens.muted) + } else { + // A stored token is in use — the field's absence alone + // never said which token a send carries. + Text("Sends with the app token in your Keychain — Settings → Micro.blog manages it.") + .font(.system(size: 11, design: DesignTokens.mono)) + .foregroundStyle(DesignTokens.muted) } if phase == .drafting || phase == .publishing { diff --git a/Museion/SettingsPagesView.swift b/Museion/SettingsPagesView.swift index d940400..15c812e 100644 --- a/Museion/SettingsPagesView.swift +++ b/Museion/SettingsPagesView.swift @@ -6,7 +6,9 @@ // in-memory SettingsModel — one page per LLM surface (provider select, // registry combobox with first-class free text, per-provider effort menu) // and the Provider Keys page (endpoint, z.ai key-type toggle swapping the -// endpoint family, masked key + reveal). Visual contract: #130 prototype +// endpoint family, masked key + reveal). The Micro.blog page is the app +// token's home (saved status, replace, remove over the publish sheet's own +// Keychain slot). Visual contract: #130 prototype // variant C, with variant B's current-model headline folded in. // @@ -340,6 +342,83 @@ private struct TestConnectionResult: View { } } +/// The Micro.blog page: the app token's home — saved status, replace, +/// remove. Writes the SAME Keychain slot the publish sheet reads +/// (`MicropubTokenStore`), so a token saved here is the one a send +/// carries; the sheet's own field stays the first-run path and its +/// 401/403 re-entry. `saved` is read back from the Keychain after every +/// write, never assumed — a locked keychain fails the save and the +/// status line says so. +struct MicroblogSettingsPage: View { + @State private var tokenField = "" + @State private var saved = MicropubTokenStore.read() != nil + + var body: some View { + VStack(alignment: .leading, spacing: 4) { + Text("Micro.blog") + .font(.system(size: 15, weight: .semibold, design: DesignTokens.serif)) + Text("Where the Micro.blog app token lives.") + .font(.system(size: 12)) + .foregroundStyle(DesignTokens.muted) + form + .padding(.top, 12) + .frame(maxWidth: DesignTokens.settingsFormWidth, alignment: .leading) + .frame(maxWidth: .infinity, alignment: .leading) + } + .padding(.horizontal, 24) + .padding(.top, 17) + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) + } + + private var trimmedToken: String { + tokenField.trimmingCharacters(in: .whitespaces) + } + + private var form: some View { + VStack(alignment: .leading, spacing: 6) { + SettingsFieldLabel("App Token") + HStack(spacing: 8) { + SecureField("App token", text: $tokenField) + .textFieldStyle(.roundedBorder) + .font(.system(size: 12, design: DesignTokens.mono)) + Button("Save") { + let token = trimmedToken + MicropubTokenStore.save(token) + tokenField = "" + saved = MicropubTokenStore.read() == token + } + .buttonStyle(BorderedSecondaryButtonStyle(minHeight: 28)) + .disabled(trimmedToken.isEmpty) + if saved { + Button("Remove") { + MicropubTokenStore.delete() + saved = MicropubTokenStore.read() != nil + } + .buttonStyle(BorderedSecondaryButtonStyle(minHeight: 28)) + } + } + // The standing state, in the Settings verdict idiom (Provider + // Keys' "✓ works"). The intro line is a description — a state + // swap there never read as a status. + status + Text("From micro.blog → Account → App Tokens. Stored in your Keychain — the publish sheet sends with this token.") + .font(.system(size: 11.5)) + .foregroundStyle(DesignTokens.muted) + .padding(.top, 2) + } + } + + /// Live: Save and Remove read the Keychain back, so this line is + /// both the confirmation that a write landed and the standing + /// answer to "is a token stored?". + private var status: some View { + Text(saved ? "✓ Token saved in your Keychain" : "No token saved — publishing will ask for one") + .font(.system(size: 11, design: DesignTokens.mono)) + .foregroundStyle(saved ? DesignTokens.accent : DesignTokens.muted) + .padding(.top, 2) + } +} + /// The z.ai key-type toggle (prototype `.seg`): a two-segment capsule, the /// selected segment filled with the foreground ink. Toggling swaps the /// endpoint family (the model guards a custom endpoint). diff --git a/Museion/SettingsPaneView.swift b/Museion/SettingsPaneView.swift index 70c98a7..1cefb82 100644 --- a/Museion/SettingsPaneView.swift +++ b/Museion/SettingsPaneView.swift @@ -5,9 +5,9 @@ // #17 (S1.1): Settings — the Museion Home path, repoint-only (ADR-0004). // #135 (Profiles S2): reworked to the #130 prototype's variant C verdict — // a Settings sidebar + detail column (System Settings shape): destinations -// Content · Pass 1 · Pass 2 · Chat · Provider Keys. Content keeps the #17 -// Home control unchanged; the surface and keys pages live in -// SettingsPagesView.swift. +// Content · Pass 1 · Pass 2 · Chat · Provider Keys · Micro.blog. Content +// keeps the #17 Home control unchanged; the surface, keys, and Micro.blog +// pages live in SettingsPagesView.swift. // #136 (Profiles S3): the model runs over HermesSettingsWriter (the real // CLI/.env rail) and hydrates from the profiles at pane open. // @@ -109,6 +109,8 @@ struct SettingsPaneView: View { SurfaceSettingsPage(model: model, surface: .chat) case .keys: ProviderKeysPage(model: model) + case .microblog: + MicroblogSettingsPage() } } .frame(maxWidth: .infinity, maxHeight: .infinity) @@ -116,13 +118,15 @@ struct SettingsPaneView: View { } /// The sidebar's destinations (#135): the #17 Content control, one page per -/// LLM surface (Sessions rides Chat — #126), and the provider keys. +/// LLM surface (Sessions rides Chat — #126), the provider keys, and the +/// Micro.blog app token (the one Keychain credential, ADR-0014). enum SettingsPage: String, CaseIterable, Identifiable, Hashable { case content case pass1 case pass2 case chat case keys + case microblog var id: String { rawValue @@ -135,6 +139,7 @@ enum SettingsPage: String, CaseIterable, Identifiable, Hashable { case .pass2: "Pass 2" case .chat: "Chat" case .keys: "Provider Keys" + case .microblog: "Micro.blog" } } diff --git a/MuseionTests/MicropubTests.swift b/MuseionTests/MicropubTests.swift index a2f93f5..eb6496b 100644 --- a/MuseionTests/MicropubTests.swift +++ b/MuseionTests/MicropubTests.swift @@ -214,6 +214,25 @@ struct MicropubTests { } } + @Test func `a 5xx names micro.blog's outage not a bare status`() { + // Their errors arrive as HTML pages, so the JSON decode finds + // nothing — a 503 over that body names their side; a 4xx keeps + // the bare status; a described 5xx keeps the description. + let html = Data("503 Service Unavailable".utf8) + let outage = Micropub.decodeFailure(status: 503, body: html) + guard case let .requestFailed(status, detail) = outage else { + Issue.record("expected requestFailed, got \(outage)") + return + } + #expect(status == 503) + #expect(detail.contains("their side")) + + let bare = Micropub.decodeFailure(status: 422, body: html) + #expect(bare == .requestFailed(status: 422, detail: "HTTP 422")) + let described = Micropub.decodeFailure(status: 502, body: Data(#"{"error_description":"upstream timeout"}"#.utf8)) + #expect(described == .requestFailed(status: 502, detail: "upstream timeout")) + } + @Test func `publish outcome is published on 2xx`() async { let log = MicropubRequestLog() let outcome = await Micropub.publish( diff --git a/docs/devlog/20261203-release-012-image-drop-fix_log.md b/docs/devlog/20261203-release-012-image-drop-fix_log.md new file mode 100644 index 0000000..caed38d --- /dev/null +++ b/docs/devlog/20261203-release-012-image-drop-fix_log.md @@ -0,0 +1,51 @@ +# Release 0.1.2 — the macOS 27.2 image-drop fix ships + +> **Date:** 2026-12-03 +> **Type:** milestone +> **Reference:** Gitea release id 29 (tag v0.1.2); follow-up to #141 (unticketed fix, same-day) + +## Goal + +Ship the macOS 27.2 image-drop fix (this morning's `fix(editor)` work, finish-audited) as **0.1.2** — the first cut under the release skill's new patch-for-a-bug-fix rule — through the full runbook: apex check, bump, changelog heading, notes, rail, sliced commits, annotated tag, notarized DMG, then on Alexander's go: push, forge release, Micro.blog draft, Buy Me a Coffee draft. + +## What Was Done + +- **apex check (step 1):** GitHub `releases/latest` is still **v1.1.59** — identical to the bundled binary (published 2026-12-01). The shipped layout re-proven without any upgrade: exactly one rpath (`@executable_path/../Resources/libyaml.bundle`), `flags=0x10000(runtime)` + Developer ID authority, `--version` 1.1.59, and the load-bearing `--no-mixed-lists` check emits `