Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(md-ux): one-shot force-ON migration for openMarkdownPreview

enes52ce8460088c
diff --git a/src/core/settings-store.test.ts b/src/core/settings-store.test.ts
index 9ef6eafcf..485e49574 100644
--- a/src/core/settings-store.test.ts
+++ b/src/core/settings-store.test.ts
@@ -62,14 +62,18 @@ describe('SettingsStore nested-default merge', () => {
it('turns markdown auto-preview ON for a settings.json that predates the key', () => {
// Every pre-v0.3.3 install upgrades with no `openMarkdownPreview` in its file: the shallow
- // merge is what delivers the flipped default (#495) to exactly that population.
+ // merge plus the one-shot migration deliver the flipped default (#495) to that population.
writeFileSync(path.join(dir, 'settings.json'), JSON.stringify({ fontSize: 15 }), 'utf-8')
const store = new SettingsStore()
store.init()
expect(store.get().openMarkdownPreview).toBe(true)
+ expect(store.get().openMarkdownPreviewMigrated).toBe(true)
})
- it('keeps an explicit openMarkdownPreview:false — an opt-out survives the default flip', () => {
+ it('migrates a v0.3.3-materialized openMarkdownPreview:false to ON, exactly once', () => {
+ // v0.3.3 (the sole release that defaulted off) materialized `false` into every file it
+ // saved, indistinguishable from an explicit opt-out — the maintainer call on #495 is that
+ // everyone sees ON at least once, so the un-stamped file is force-flipped and stamped.
writeFileSync(
path.join(dir, 'settings.json'),
JSON.stringify({ openMarkdownPreview: false }),
@@ -77,6 +81,18 @@ describe('SettingsStore nested-default merge', () => {
)
const store = new SettingsStore()
store.init()
+ expect(store.get().openMarkdownPreview).toBe(true)
+ expect(store.get().openMarkdownPreviewMigrated).toBe(true)
+ })
+
+ it('keeps a post-migration opt-out — a stamped openMarkdownPreview:false is permanent', () => {
+ writeFileSync(
+ path.join(dir, 'settings.json'),
+ JSON.stringify({ openMarkdownPreview: false, openMarkdownPreviewMigrated: true }),
+ 'utf-8'
+ )
+ const store = new SettingsStore()
+ store.init()
expect(store.get().openMarkdownPreview).toBe(false)
})
diff --git a/src/core/settings-store.ts b/src/core/settings-store.ts
index 40a4bc155..a30c1a077 100644
--- a/src/core/settings-store.ts
+++ b/src/core/settings-store.ts
@@ -45,6 +45,18 @@ function mergeSettings(saved: Partial<Settings> | null | undefined): Settings {
"speech.dictation": [merged.speech.shortcut],
};
}
+ // One-shot markdown-preview default flip (#495, maintainer decision): every file written
+ // before the flip gets `openMarkdownPreview: true` exactly once — INCLUDING one saved by
+ // v0.3.3, the sole release that defaulted off, whose full-snapshot saves materialized `false`
+ // for users who never touched the toggle (indistinguishable from an explicit off, so the
+ // absent-key merge alone could not reach them). The stamped `openMarkdownPreviewMigrated`
+ // is what makes it one-shot: once present, the stored value is the user's own and an opt-out
+ // is permanent. Same shape as the dictation seed above — keyed on the marker's absence in
+ // the SAVED file, never on the merged value.
+ if (!saved?.openMarkdownPreviewMigrated) {
+ merged.openMarkdownPreview = true;
+ merged.openMarkdownPreviewMigrated = true;
+ }
// Legacy `terminalGpuRendering` was a boolean whose default (true) was merged into every saved
// file — so a stored `true` is indistinguishable from "never touched" and maps to the new
// 'auto' (platform-aware) default, while a stored `false` was always an explicit escape-hatch
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 91d9a21bc..54821c517 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -1215,13 +1215,18 @@ export interface Settings {
/** Open Markdown files (.md, .markdown, …) in rendered preview instead of the code editor.
* Only picks the view an editor node OPENS in — the node's Preview/Edit toggle (and the
* markdown-toggle chord) still switches either way. Default ON since the release after
- * v0.3.3 (maintainer decision on issue #495; docs open as docs). An absent key picks up the
- * new default via the shallow merge; an explicit `false` is respected. Caveat, same shape as
- * `terminalGpuRendering`'s boolean history: `saveNow` materializes EVERY key, so a file
- * saved by v0.3.3 itself (the one release that defaulted off) carries `false`
- * indistinguishable from a user's explicit off — those installs keep off, which is the safe
- * direction (never overwrite what may be an explicit choice). */
+ * v0.3.3 (maintainer decision on issue #495; a preview is one ⌘M from the editor, so the
+ * rendered view is the better first sight for docs). A one-shot load migration keyed on
+ * `openMarkdownPreviewMigrated` (see mergeSettings) forces this ON once for every existing
+ * file — including one saved by v0.3.3, the one release that defaulted off and whose
+ * full-snapshot saves materialized `false` for users who never touched the toggle. After
+ * the migration the user's own opt-out is permanent. */
openMarkdownPreview: boolean
+ /** One-shot marker for the openMarkdownPreview default flip (#495). Absent = the file
+ * predates the flip → the load migration sets `openMarkdownPreview: true` and stamps this
+ * true; present = the migration already ran (or the install was born after it) and the
+ * stored `openMarkdownPreview` value is the user's own, never touched again. */
+ openMarkdownPreviewMigrated: boolean
/**
* Let a MIDDLE CLICK inside a terminal paste (Linux in practice — macOS and Windows have no
* PRIMARY selection and no tmux middle-click habit, so the guard changes nothing visible there).
@@ -1501,6 +1506,7 @@ export const DEFAULT_SETTINGS: Settings = {
panHoverDelay: 600,
doubleClickFocus: true,
openMarkdownPreview: true,
+ openMarkdownPreviewMigrated: true,
terminalMiddleClickPaste: false,
wheelZoom: false,
trackpadPan: true,