Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: preserve IdeaLoom Markdown round trips (#5338)

[._.]/ Adam Eivy3025cef36103
diff --git a/client/src/components/brain/IdeaLoomLists.jsx b/client/src/components/brain/IdeaLoomLists.jsx
index 5e6835e614..5ab3aeecb2 100644
--- a/client/src/components/brain/IdeaLoomLists.jsx
+++ b/client/src/components/brain/IdeaLoomLists.jsx
@@ -138,7 +138,9 @@ export default function IdeaLoomLists() {
if (!result) return;
const counts = result.counts || result;
setExchangeResult(counts);
- toast.success(successMessage);
+ const problems = ['conflicted', 'malformed', 'unavailable', 'failed'].reduce((total, key) => total + (counts[key] || 0), 0);
+ if (problems) toast.error(`${successMessage} with ${problems} issue${problems === 1 ? '' : 's'}`);
+ else toast.success(successMessage);
await load();
};
diff --git a/client/src/components/brain/IdeaLoomLists.test.jsx b/client/src/components/brain/IdeaLoomLists.test.jsx
index 426eff0bc8..2c3d819f16 100644
--- a/client/src/components/brain/IdeaLoomLists.test.jsx
+++ b/client/src/components/brain/IdeaLoomLists.test.jsx
@@ -87,6 +87,16 @@ describe('IdeaLoomLists', () => {
expect(await screen.findByText(/Last exchange: 0 imported · 1 exported/)).toBeTruthy();
});
+ it('reports exchange problems instead of showing a successful completion', async () => {
+ api.getIdeaLoomSettings.mockResolvedValue({ enabled: true, obsidianVaultId: 'vault-1', autoSync: false });
+ api.syncIdeaLoomToObsidian.mockResolvedValue({ counts: { failed: 1 } });
+ renderPanel();
+
+ fireEvent.click(await screen.findByRole('button', { name: 'Export to Obsidian' }));
+ await waitFor(() => expect(toast.error).toHaveBeenCalledWith('IdeaLoom export complete with 1 issue'));
+ expect(toast.success).not.toHaveBeenCalledWith('IdeaLoom export complete');
+ });
+
it('does not report an unread settings fetch as a disabled integration', async () => {
api.getIdeaLoomSettings.mockRejectedValue(new Error('Server unreachable'));
renderPanel();
diff --git a/server/services/idealoomObsidian.js b/server/services/idealoomObsidian.js
index da8e09677f..12ef048302 100644
--- a/server/services/idealoomObsidian.js
+++ b/server/services/idealoomObsidian.js
@@ -121,29 +121,43 @@ const parseBody = (lines) => {
const nextContent = lines[nextContentIndex]?.trim();
// IdeaLoom sometimes uses a literal "Prompt" heading. Do not consume the
// first numbered idea as prompt text in that valid, empty-help shape.
- if (nextContent && !NUMBERED_IDEA_RE.test(nextContent)) {
+ if (nextContent && !nextContent.startsWith('#') && !NUMBERED_IDEA_RE.test(nextContent)) {
prompt = nextContent;
cursor = nextContentIndex + 1;
}
}
- if (!prompt || prompt.startsWith('#')) return { error: 'missing prompt text' };
+ if (!prompt) return { error: 'missing prompt text' };
const helpLines = [];
const ideas = [];
let sawIdea = false;
+ let section = 'legacy';
for (; cursor < lines.length; cursor += 1) {
const line = lines[cursor];
if (!line.trim()) {
if (!sawIdea) helpLines.push('');
continue;
}
- if (/^#{1,6}\s+(help|ideas)\s*:?$/i.test(line.trim())) continue;
+ const heading = line.trim();
+ if (/^#{1,6}\s+help\s*:?$/i.test(heading)) {
+ section = 'help';
+ continue;
+ }
+ if (/^#{1,6}\s+ideas\s*:?$/i.test(heading)) {
+ section = 'ideas';
+ continue;
+ }
const match = NUMBERED_IDEA_RE.exec(line.trim());
+ if (section === 'help') {
+ helpLines.push(line.trim());
+ continue;
+ }
if (!match) {
- if (sawIdea) return { error: `invalid numbered idea at line ${cursor + 1}` };
+ if (sawIdea || section === 'ideas') return { error: `invalid numbered idea at line ${cursor + 1}` };
helpLines.push(line.trim());
continue;
}
+ section = 'ideas';
sawIdea = true;
const expected = ideas.length + 1;
if (Number(match[1]) !== expected || !match[2].trim()) {
@@ -219,9 +233,9 @@ export function renderIdeaLoomMarkdown(list) {
'---',
`# ${String(list.prompt).replace(/[\r\n]+/g, ' ').trim()}`,
];
- if (list.help?.trim()) lines.push('', list.help.trim());
+ if (list.help?.trim()) lines.push('', '## Help', list.help.trim());
if (list.ideas?.length) {
- lines.push('', ...list.ideas.map((idea, index) => `${index + 1}. ${String(idea).replace(/[\r\n]+/g, ' ').trim()}`));
+ lines.push('', '## Ideas', ...list.ideas.map((idea, index) => `${index + 1}. ${String(idea).replace(/[\r\n]+/g, ' ').trim()}`));
}
return `${lines.join('\n')}\n`;
}
@@ -353,7 +367,7 @@ const exportOne = async (vaultId, list) => {
const importedPath = list.sync?.notePath;
let notePath = importedPath || generatedNotePath(list);
let pathResult = await writeNote(vaultId, notePath, content);
- if (!importedPath && pathResult.kind === 'existing') {
+ if (!importedPath && pathResult.kind === 'existing' && pathResult.id !== list.id) {
let suffix = `-${list.id.slice(0, 8)}`;
notePath = generatedNotePath(list, suffix);
pathResult = await writeNote(vaultId, notePath, content);
diff --git a/server/services/idealoomObsidian.test.js b/server/services/idealoomObsidian.test.js
index 017474ef58..c9c52f5440 100644
--- a/server/services/idealoomObsidian.test.js
+++ b/server/services/idealoomObsidian.test.js
@@ -92,6 +92,16 @@ describe('IdeaLoom Markdown contract', () => {
}));
});
+ it('round-trips Markdown-numbered help and prompt text beginning with a hash', () => {
+ const original = list({ prompt: '#1 priority for Q4', help: 'Try these:\n1. warm up\n2. diverge' });
+ const parsed = parseIdeaLoomMarkdown(renderIdeaLoomMarkdown(original));
+
+ expect(parsed).toEqual(expect.objectContaining({
+ ok: true,
+ list: expect.objectContaining({ prompt: original.prompt, help: original.help, ideas: original.ideas }),
+ }));
+ });
+
it('rejects malformed metadata and non-dense numbered ideas', () => {
const rendered = renderIdeaLoomMarkdown(list());
expect(parseIdeaLoomMarkdown(rendered.replace(`id: "${LIST_ID}"`, 'id: "not-a-uuid"')).ok).toBe(false);