fix: bound the Discord table conversion input and keep received files off the watcher (release review, #741)

A table costs its widest cell times its rows, so one wide cell in an agent's last
message built a 202 MB string on the event loop although only 8 posts can ever go
out. Only what can be posted is converted now. A file a person sent from Discord
also fired attachment:detected as if the agent had produced it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-11-04 17:29:08 +01:00
1 parent 4276b53a8f
commit e68afdd2ac
5 files changed
+32 -7

No files matched your search

+12
View File
@@ -638,6 +638,18 @@ describe('DiscordBridge', () => {
b.stop();
});
it('converts only what can be posted, so one very wide table cell cannot stall the server', async () => {
const b = bridge();
const wide = ['| a |', '|---|', `| ${'x'.repeat(1024 * 1024)} |`, ...Array(190).fill('| y |')].join('\n');
const t0 = Date.now();
await b.notify({ ...MSG, event: 'hook:idle_prompt', fullText: async () => ({ text: wide, version: 'turn-1' }) });
expect(Date.now() - t0).toBeLessThan(500);
const said = posts.filter((p) => p.path.endsWith('/messages')).map((p) => String(p.body?.content));
expect(said.length).toBeLessThanOrEqual(9); // the title post plus at most 8 parts
expect(said.at(-1)).toContain('continues in the tab');
b.stop();
});
it('does not post the same message twice when two alerts for one tab overlap', async () => {
let release!: () => void;
const gate = new Promise<void>((r) => (release = r));
+1
View File
@@ -97,6 +97,7 @@ describe('ImageWatcher', () => {
watcher.watchSession('session-1', '/home/user/project');
const [, opts] = vi.mocked(watch).mock.calls.at(-1) as unknown as [string, { ignored: (p: string) => boolean }];
expect(opts.ignored('/home/user/project/.codeman-uploads/paste-1-ab.pdf')).toBe(true);
expect(opts.ignored('/home/user/project/.codeman-discord/1234-report.pdf')).toBe(true);
expect(opts.ignored('/home/user/project/.claude-images/paste-1-ab.png')).toBe(true);
expect(opts.ignored('/home/user/project/docs/report.pdf')).toBe(false);
});