Markdown export: move the emoji to the end of the line (#12278)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
Mark Hansen
2025-12-04 10:30:29 +11:00
committed by GitHub
parent a28be4a4e0
commit 1e6243045e
2 changed files with 17 additions and 17 deletions

View File

@@ -478,25 +478,25 @@ describe('chatCommand', () => {
const expectedPath = path.join(process.cwd(), 'my-chat.md');
const [actualPath, actualContent] = mockFs.writeFile.mock.calls[0];
expect(actualPath).toEqual(expectedPath);
const expectedContent = `🧑‍💻 ## USER
const expectedContent = `## USER 🧑‍💻
context
---
## MODEL
## MODEL
context response
---
🧑‍💻 ## USER
## USER 🧑‍💻
Hello
---
## MODEL
## MODEL
Hi there!`;
expect(actualContent).toEqual(expectedContent);
@@ -570,7 +570,7 @@ Hi there!`;
const { role, parts } = mockHistory[index];
const text = parts.map((p) => p.text).join('');
const roleIcon = role === 'user' ? '🧑‍💻' : '✨';
expect(entry).toBe(`${roleIcon} ## ${role.toUpperCase()}\n\n${text}`);
expect(entry).toBe(`## ${role.toUpperCase()} ${roleIcon}\n\n${text}`);
});
});
});
@@ -584,9 +584,9 @@ Hi there!`;
];
const expectedMarkdown =
'🧑‍💻 ## USER\n\nHello\n\n---\n\n' +
'## MODEL\n\nHi there!\n\n---\n\n' +
'🧑‍💻 ## USER\n\nHow are you?';
'## USER 🧑‍💻\n\nHello\n\n---\n\n' +
'## MODEL\n\nHi there!\n\n---\n\n' +
'## USER 🧑‍💻\n\nHow are you?';
const result = serializeHistoryToMarkdown(history);
expect(result).toBe(expectedMarkdown);
@@ -605,19 +605,19 @@ Hi there!`;
{ role: 'user', parts: [{ text: 'How are you?' }] },
];
const expectedMarkdown = `🧑‍💻 ## USER
const expectedMarkdown = `## USER 🧑‍💻
Hello
---
## MODEL
## MODEL
---
🧑‍💻 ## USER
## USER 🧑‍💻
How are you?`;
@@ -655,13 +655,13 @@ How are you?`;
},
];
const expectedMarkdown = `🧑‍💻 ## USER
const expectedMarkdown = `## USER 🧑‍💻
Please call a function.
---
## MODEL
## MODEL
**Tool Command**:
\`\`\`json
@@ -675,7 +675,7 @@ Please call a function.
---
🧑‍💻 ## USER
## USER 🧑‍💻
**Tool Response**:
\`\`\`json
@@ -697,13 +697,13 @@ Please call a function.
{ parts: [{ text: 'Hi there!' }] },
];
const expectedMarkdown = `🧑‍💻 ## USER
const expectedMarkdown = `## USER 🧑‍💻
Hello
---
## MODEL
## MODEL
Hi there!`;

View File

@@ -303,7 +303,7 @@ export function serializeHistoryToMarkdown(history: Content[]): string {
})
.join('') || '';
const roleIcon = item.role === 'user' ? '🧑‍💻' : '✨';
return `${roleIcon} ## ${(item.role || 'model').toUpperCase()}\n\n${text}`;
return `## ${(item.role || 'model').toUpperCase()} ${roleIcon}\n\n${text}`;
})
.join('\n\n---\n\n');
}