Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7587b98
Fix(tests): three editor suites finish the parse before they read the…
adibhanna Nov 5, 2026
7db7680
Fix(mcp): five scope and name answers from the review are right
adibhanna Nov 5, 2026
efd9e85
Fix(vault): copying folders into a new vault no longer leaves a stray…
adibhanna Nov 5, 2026
b33d101
Fix(tables): an embed in an editor table cell draws what read mode draws
adibhanna Nov 5, 2026
7617661
Fix(palette): Go to Files, Quick Notes and Inbox go there
adibhanna Nov 5, 2026
7c3e5d9
Fix(help): the manual on a tablet stops describing what is not there
adibhanna Nov 5, 2026
946b37a
Fix(search): a result names its folder by your label, and root notes …
adibhanna Nov 5, 2026
04e7e10
Fix(connections): touch screens no longer show a "hover" chip or a pr…
adibhanna Nov 5, 2026
e5a1944
Fix(editor): a pane toolbar button goes dark as soon as its panel closes
adibhanna Nov 5, 2026
4ae92f3
Fix(connections): the hover preview no longer smears the text behind it
adibhanna Nov 5, 2026
02d9ddb
Fix(lists): a note's preview line stops repeating its title
adibhanna Nov 5, 2026
217b76e
Fix(tasks): the Tasks header fits a tablet, and its filter hint follo…
adibhanna Nov 5, 2026
b71a80b
Fix(cloud): the footer can cancel a sign-in waiting on the browser
adibhanna Nov 5, 2026
cd05a16
Fix(home): an empty vault does not open with a Recent heading over no…
adibhanna Nov 5, 2026
c362271
Fix(sidebar): only the selected row is lit on a tablet, and after Dup…
adibhanna Nov 5, 2026
936bc37
Fix(tablet): the title row clears the status bar, and tooltips name t…
adibhanna Nov 5, 2026
ccea16d
Fix(title bar): the Assets page is named in the title bar
adibhanna Nov 5, 2026
cacbbfc
Fix(mcp): a local vault's record pages are notes, and a deny entry ca…
adibhanna Nov 5, 2026
ad059c5
Fix(reference): the pinned pane's reveal finds the note in any vault …
adibhanna Nov 5, 2026
14f8031
Fix(diagrams): the TikZ error stops naming a Mac key
adibhanna Nov 5, 2026
9189b42
Fix(capture): the Quick Capture picker names folders as search does
adibhanna Nov 5, 2026
63b4a4f
Fix(vault): only a verified Welcome leaves on its own, and only when …
adibhanna Nov 5, 2026
30fb79f
Fix(cloud): Cancel in the footer cannot sign out an account that just…
adibhanna Nov 5, 2026
69e4273
Fix(sidebar): a tablet with a keyboard gets its cursor, and a Cmd sel…
adibhanna Nov 5, 2026
b5adb71
Fix(mcp): a client with a path scope leaves a record page where it is
adibhanna Nov 5, 2026
327367e
Fix(tests): this branch's new source checks and reveal tests pass on …
adibhanna Nov 5, 2026
8f20e8a
Fix(mcp): a scoped client cannot delete a record page or treat a data…
adibhanna Nov 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/desktop/src/cli/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export interface VaultBackend {
* the tag tools and commands leave its notes out, as the app does. */
templateFolder(): Promise<string | null>
listNotes(): Promise<NoteMeta[]>
/** Where a folder listing leaves database folders out, names them: a path scope
* can name one even with no record page yet. */
listDatabaseDirs?(): Promise<{ folder: NoteFolder; subpath: string }[]>
listAssets(): Promise<VaultAssetMeta[]>
/** An attachment's bytes. */
readAsset(rel: string): Promise<Uint8Array>
Expand Down Expand Up @@ -321,6 +324,8 @@ class LocalBackend implements VaultBackend {
}
templateFolder = (): Promise<string | null> => readTemplateFolder(this.root)
listNotes = (): Promise<NoteMeta[]> => listNotes(this.root)
listDatabaseDirs = (): Promise<{ folder: NoteFolder; subpath: string }[]> =>
listDatabaseDirs(this.root)
marksLinks = async (): Promise<boolean> => true
linkedSystemFolders = async (): Promise<string[] | null> => {
const { primaryNotesLocation, systemFolderPaths } = await this.vaultLayout()
Expand Down
18 changes: 18 additions & 0 deletions apps/desktop/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ import {
writeFileAtomic,
setVaultSettings,
rootContentHiddenByInboxMode,
settleSeededInbox,
type PersistedRemoteWorkspaceConfig,
type PersistedRemoteWorkspaceProfile,
type PersistedWindowState,
Expand Down Expand Up @@ -445,6 +446,7 @@ const windowVaults = new WindowVaultRegistry({
if (vaultChangeAffectsSettings(ev)) {
invalidateVaultSettingsCache(root);
scheduleShareVaultsRefresh();
scheduleSeededInboxSettle(root);
}
},
sendVaultChange: (windowId, ev) => {
Expand All @@ -453,6 +455,22 @@ const windowVaults = new WindowVaultRegistry({
win.webContents.send(IPC.VAULT_ON_CHANGE, ev);
},
});
// A copy arrives as a burst of root-level events; one look after it is enough.
const SEEDED_INBOX_SETTLE_DELAY_MS = 400;
const seededInboxSettles = new Map<string, NodeJS.Timeout>();
function scheduleSeededInboxSettle(root: string): void {
clearTimeout(seededInboxSettles.get(root));
seededInboxSettles.set(
root,
setTimeout(() => {
seededInboxSettles.delete(root);
void settleSeededInbox(root).catch((err) =>
console.error("settling a seeded inbox failed", err),
);
}, SEEDED_INBOX_SETTLE_DELAY_MS),
);
}

const DEFAULT_WINDOW_WIDTH = 1280;
const DEFAULT_WINDOW_HEIGHT = 820;
const MIN_WINDOW_WIDTH = 900;
Expand Down
205 changes: 205 additions & 0 deletions apps/desktop/src/main/vault.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
restoreDeletedAsset,
restoreFromTrash,
rootContentHiddenByInboxMode,
settleSeededInbox,
searchVaultText,
searchVaultTextCapabilities,
setVaultSettings,
Expand Down Expand Up @@ -98,6 +99,210 @@ describe('rootContentHiddenByInboxMode (#195)', () => {
})
})

describe('a folder opened empty, then filled', () => {
const exists = (p: string): Promise<boolean> =>
stat(p).then(
() => true,
() => false
)

async function seededVault(): Promise<string> {
const root = await makeTempDir('zennotes-vault-seeded-')
await ensureVaultLayout(root)
expect(await exists(path.join(root, 'inbox', 'Welcome.md'))).toBe(true)
expect((await getVaultSettings(root)).primaryNotesLocation).toBe('inbox')
return root
}

async function copyFolderIn(root: string): Promise<void> {
await mkdir(path.join(root, 'Projects'), { recursive: true })
await writeFile(path.join(root, 'Projects', 'Plan.md'), '# Plan\n')
invalidateVaultSettingsCache(root)
}

it('takes away the system inbox holding only an untouched Welcome', async () => {
const root = await seededVault()
await copyFolderIn(root)
expect(await settleSeededInbox(root)).toBe(true)
expect(await exists(path.join(root, 'inbox'))).toBe(false)
expect((await getVaultSettings(root)).primaryNotesLocation).toBe('root')
expect(await readFile(path.join(root, 'Projects', 'Plan.md'), 'utf8')).toBe('# Plan\n')
})

it('heals a vault that already turned, the next time it opens', async () => {
const root = await seededVault()
await copyFolderIn(root)
await ensureVaultLayout(root)
expect(await exists(path.join(root, 'inbox'))).toBe(false)
})

it('leaves an empty inbox on its own: it may be a capture tool\'s', async () => {
const root = await seededVault()
await rm(path.join(root, 'inbox', 'Welcome.md'))
await writeFile(path.join(root, 'inbox', '.DS_Store'), 'x')
await copyFolderIn(root)
expect(await settleSeededInbox(root)).toBe(false)
await ensureVaultLayout(root)
expect(await exists(path.join(root, 'inbox'))).toBe(true)
})

it('takes away an empty inbox and what Finder left in it on a switch to root mode', async () => {
const root = await seededVault()
await rm(path.join(root, 'inbox', 'Welcome.md'))
await writeFile(path.join(root, 'inbox', '.DS_Store'), 'x')
const base = await getVaultSettings(root)
const stated = await setVaultSettings(root, { ...base, primaryNotesLocation: 'inbox' })
await setVaultSettings(root, { ...stated, primaryNotesLocation: 'root' })
expect(await exists(path.join(root, 'inbox'))).toBe(false)
})

it('keeps an edit that lands while the Welcome is being looked at', async () => {
const root = await seededVault()
await copyFolderIn(root)
const welcome = path.join(root, 'inbox', 'Welcome.md')
const realRename = fsPromises.rename
const rename = vi.spyOn(fsPromises, 'rename').mockImplementationOnce(async (from, to) => {
// The first hash has passed. The edit lands before the file moves.
await writeFile(welcome, '# Mine now\n')
await realRename(from, to)
})
expect(await settleSeededInbox(root)).toBe(false)
rename.mockRestore()
expect(await readFile(welcome, 'utf8')).toBe('# Mine now\n')
expect((await fsPromises.readdir(path.join(root, 'inbox'))).sort()).toEqual(['Welcome.md'])
})

it('keeps a file saved while the Welcome is out of the way, and the folder with it', async () => {
const root = await seededVault()
await copyFolderIn(root)
const welcome = path.join(root, 'inbox', 'Welcome.md')
const realRename = fsPromises.rename
const rename = vi.spyOn(fsPromises, 'rename').mockImplementationOnce(async (from, to) => {
await realRename(from, to)
await writeFile(welcome, '# Saved after the move\n')
})
await settleSeededInbox(root)
rename.mockRestore()
expect(await readFile(welcome, 'utf8')).toBe('# Saved after the move\n')
expect(await fsPromises.readdir(path.join(root, 'inbox'))).toEqual(['Welcome.md'])
})

it('keeps a Welcome with comments on it', async () => {
const root = await seededVault()
await writeNoteComments(root, 'inbox/Welcome.md', [
{
id: 'c1',
body: 'mine',
anchorStart: 0,
anchorEnd: 1,
anchorText: '#',
createdAt: 1,
updatedAt: 1
} as never
])
await copyFolderIn(root)
expect(await settleSeededInbox(root)).toBe(false)
expect(await exists(path.join(root, 'inbox', 'Welcome.md'))).toBe(true)
})

it('keeps the Welcome when root mode is chosen with nothing else in the vault', async () => {
const root = await seededVault()
const base = await getVaultSettings(root)
const asRoot = await setVaultSettings(root, { ...base, primaryNotesLocation: 'root' })
expect(await exists(path.join(root, 'inbox', 'Welcome.md'))).toBe(true)
// Switching back in the same breath finds the vault as it was.
await setVaultSettings(root, { ...asRoot, primaryNotesLocation: 'inbox' })
expect(await exists(path.join(root, 'inbox', 'Welcome.md'))).toBe(true)
})

it('lets the Welcome go once a vault that chose root mode gets something else', async () => {
const root = await seededVault()
const base = await getVaultSettings(root)
await setVaultSettings(root, { ...base, primaryNotesLocation: 'root' })
await copyFolderIn(root)
expect(await settleSeededInbox(root)).toBe(true)
expect(await exists(path.join(root, 'inbox'))).toBe(false)
})

it.each([
['an edited Welcome', 'Welcome.md', '# Mine now\n'],
['a note of the same bytes under another name', 'Copy.md', null]
])('never touches %s', async (_label, name, body) => {
const root = await seededVault()
const seeded = await readFile(path.join(root, 'inbox', 'Welcome.md'), 'utf8')
await writeFile(path.join(root, 'inbox', name), body ?? seeded)
if (name !== 'Welcome.md') await rm(path.join(root, 'inbox', 'Welcome.md'))
await copyFolderIn(root)
expect(await settleSeededInbox(root)).toBe(false)
expect(await readFile(path.join(root, 'inbox', name), 'utf8')).toBe(body ?? seeded)
})

it('never touches an untouched Welcome beside another note', async () => {
const root = await seededVault()
await writeFile(path.join(root, 'inbox', 'Mine.md'), 'mine')
await copyFolderIn(root)
expect(await settleSeededInbox(root)).toBe(false)
expect(await exists(path.join(root, 'inbox', 'Welcome.md'))).toBe(true)
expect(await exists(path.join(root, 'inbox', 'Mine.md'))).toBe(true)
})

it('does nothing while the layout still reads as inbox mode', async () => {
const root = await seededVault()
expect(await settleSeededInbox(root)).toBe(false)
expect(await exists(path.join(root, 'inbox', 'Welcome.md'))).toBe(true)
})

it('does nothing in a vault that states its layout', async () => {
const root = await seededVault()
const base = await getVaultSettings(root)
await setVaultSettings(root, { ...base, primaryNotesLocation: 'inbox' })
await copyFolderIn(root)
expect(await settleSeededInbox(root)).toBe(false)
expect(await exists(path.join(root, 'inbox', 'Welcome.md'))).toBe(true)
expect(await rootContentHiddenByInboxMode(root)).toBe(true)
})

it('leaves a folder the inbox was remapped to', async () => {
const root = await makeTempDir('zennotes-vault-remapped-')
await mkdir(path.join(root, '.zennotes'), { recursive: true })
await writeFile(
path.join(root, '.zennotes', 'vault.json'),
JSON.stringify({ systemFolderPaths: { inbox: 'inbox-of-mine' } })
)
await mkdir(path.join(root, 'inbox'), { recursive: true })
await mkdir(path.join(root, 'Projects'), { recursive: true })
expect(await settleSeededInbox(root)).toBe(false)
expect(await exists(path.join(root, 'inbox'))).toBe(true)
})

it('leaves a capitalized Inbox, which is a folder of the owner', async () => {
const root = await makeTempDir('zennotes-vault-capital-')
await mkdir(path.join(root, 'Inbox'), { recursive: true })
await mkdir(path.join(root, 'Projects'), { recursive: true })
expect(await settleSeededInbox(root)).toBe(false)
expect(await exists(path.join(root, 'Inbox'))).toBe(true)
})

it('switching a stated vault to root mode takes the seed-only inbox with it', async () => {
const root = await seededVault()
const base = await getVaultSettings(root)
const stated = await setVaultSettings(root, { ...base, primaryNotesLocation: 'inbox' })
await copyFolderIn(root)
await setVaultSettings(root, { ...stated, primaryNotesLocation: 'root' })
expect(await exists(path.join(root, 'inbox'))).toBe(false)
expect(await rootContentHiddenByInboxMode(root)).toBe(false)
})

it('switching to root mode keeps an inbox with an edited Welcome', async () => {
const root = await seededVault()
const base = await getVaultSettings(root)
const stated = await setVaultSettings(root, { ...base, primaryNotesLocation: 'inbox' })
await writeFile(path.join(root, 'inbox', 'Welcome.md'), '# Mine now\n')
await setVaultSettings(root, { ...stated, primaryNotesLocation: 'root' })
expect(await readFile(path.join(root, 'inbox', 'Welcome.md'), 'utf8')).toBe('# Mine now\n')
})
})

describe('daily-notes task settings round-trip (#288)', () => {
it('persists the Harper dictionary and ignored suggestions through set/get', async () => {
const root = await makeTempDir('zennotes-vault-harper-')
Expand Down
Loading
Loading