feat: icon for choice commands on the mobile toolbar (#766)#1342
Conversation
Obsidian's mobile editing toolbar renders the default "question-mark-glyph"
("?") for any command registered without an `icon`. QuickAdd registered every
choice command without one (main.ts addCommandForChoice), so all QuickAdd
commands showed "?" on the mobile toolbar.
Resolve a per-type default icon at registration time and pass it to
addCommand: Template -> file-text, Capture -> pencil, Macro -> terminal,
Multi -> folder, with a file-plus fallback for unexpected runtime types. The
default arm is load-bearing: data.json is not runtime-validated and the repo
compiles with strict:false / no switch-exhaustiveness lint, so a missing case
would return undefined and silently re-introduce the "?".
Defaults are resolved only at registration time and never written to
data.json, so every existing choice gains a meaningful icon with no migration
and no settings bloat. An optional per-choice `icon?` override is honored when
set (typeof-guarded against malformed non-string data); no picker UI yet.
Closes #766
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughAdds an optional ChangesPer-choice icon resolution for registered commands
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying quickadd with
|
| Latest commit: |
a5de4d4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://435615af.quickadd.pages.dev |
| Branch Preview URL: | https://chhoumann-766-mobile-toolbar.quickadd.pages.dev |
Closes #766
Problem
On the Obsidian mobile editing toolbar, every QuickAdd command showed the default question-mark glyph instead of a meaningful icon.
Root cause (still live):
addCommandForChoiceregistered each choice command with noicon. Obsidian's mobile toolbar builder falls back toquestion-mark-glyphfor any iconless command:Verified in the dev vault before the fix: all 26
quickadd:choice:*commands hadicon: null.Fix
Resolve a per-type default icon at registration time and pass it to
addCommand:file-textpencilterminalfolderfile-plusdata.jsonbloat — defaults are resolved at registration time only, never persisted. Every existing choice gains an icon for free.defaultarm is load-bearing, not decorative:data.jsonis not runtime-validated and the repo compiles withstrict: falseand no switch-exhaustiveness lint, so a missing case would returnundefinedand silently re-introduce the?.icon?override is honored when set (a non-empty string wins;typeof-guarded so malformed non-string data can't throw during plugin load). There's no picker UI yet — see follow-up below.The resolver lives in
src/utils/choiceUtils.ts(an App-free core util) and is imported bymain.ts, keeping command-icon logic out of GUI metadata.Verification
resolveChoiceIcon/defaultIconForChoiceType— override wins, blank/whitespace falls back, all four type defaults, thedefaultarm, and non-string data doesn't throw. Full suite: 2021 passing.file-text, Capture→pencil, Macro→terminal; a synthetic command-enabled Multi→folder; an override→its value; a whitespace override→the type default.tsc --noEmit,eslint ., andbuild-with-lintall clean.Known limitation (Obsidian-side, documented)
Obsidian's
compileToolbarcaches by the command-id list and only rebuilds when that list changes. For a command already pinned to a user's mobile toolbar, the new icon appears after the next app restart (it self-heals, no user action) — consistent with QuickAdd's existing "Requires a reload" pattern for the ribbon toggle. Newly added toolbar entries and the command palette pick up the icon immediately.Scope note / follow-up
This is the focused fix for #766: it removes the
?for everyone with zero config. A per-choice icon picker (a context-menu "Set icon…" over the icon list writing theicon?override) was designed and adversarially reviewed but intentionally deferred — it's a customization feature beyond the report, with extra UI surface and the toolbar-cache caveat. Theicon?field added here is the seam for it if there's demand.🤖 Generated with Claude Code
Summary by CodeRabbit