Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 29 additions & 2 deletions src/adapters/groupmind.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@ export const groupmindAdapter = {
});
const data = JSON.parse(result);
const msgs = data.messages || (Array.isArray(data) ? data : []);
// Resolve reply targets from the same batch: a fresh reply's target is
// almost always within the last `limit` messages. Without this the
// reply_to id survives but means nothing to a reader of the line.
// (Aug 27 2026: petrus's "spec this" reply was interpreted by guess
// because every agent-facing surface dropped the reply target.)
const byId = new Map(msgs.map((m) => [m.id, m]));
for (const m of msgs) {
m._room = room;
if (m.reply_to && byId.has(m.reply_to)) {
const t = byId.get(m.reply_to);
m._replyTarget = { from: t.from || t.sender || '?', body: (t.body || '').slice(0, 120) };
}
}
all.push(...msgs);
} catch (e) {
Expand Down Expand Up @@ -60,7 +70,13 @@ export const groupmindAdapter = {
timestamp: ts,
room,
actor: { login: sender },
payload: { body, room }
payload: {
body,
room,
// A reply's meaning lives in its target - carry it, never drop it.
reply_to: msg.reply_to || null,
reply_target: msg._replyTarget || null
Comment on lines +77 to +78

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the GroupMind adapter imported by the CLI

When users run ide-agent-kit platform watch, this reply metadata and formatting never execute: bin/cli.mjs imports src/team-relay/adapters/groupmind.mjs, which still has the old implementation, while a repo-wide import search finds this changed adapter used only by test/unified-poller.test.mjs. Consequently, the production poller continues presenting replies as freestanding messages even though the new tests pass; apply the change to the team-relay adapter used by the CLI (and test that module directly).

Useful? React with 👍 / 👎.

}
};
},

Expand All @@ -69,6 +85,17 @@ export const groupmindAdapter = {
const sender = event.actor?.login || '?';
const room = event.room || '';
const body = (event.payload?.body || '').replace(/\n/g, ' ').slice(0, 200);
return `[${ts}] [${room}] ${sender}: ${body}`;
const line = `[${ts}] [${room}] ${sender}: ${body}`;
const t = event.payload?.reply_target;
if (t) {
const snippet = (t.body || '').replace(/\n/g, ' ').slice(0, 100);
return `${line}\n ⤷ in reply to ${t.from}: "${snippet}"`;
}
if (event.payload?.reply_to) {
// Target not in the fetch window - still say it IS a reply so nobody
// interprets it as a freestanding statement.
return `${line}\n ⤷ a reply (target ${event.payload.reply_to} not in recent window)`;
}
return line;
}
};
37 changes: 37 additions & 0 deletions test/unified-poller.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,40 @@ describe('common/event-queue', () => {
assert.equal(typeof appendEvents, 'function');
});
});

describe('groupmind reply targets', () => {
// A reply's meaning lives in its target (Aug 27 2026: "spec this" was
// interpreted by guess because every agent surface dropped reply_to).
const target = { id: 'aaa', from: '@claudeMB', body: 'the AgentOS fleet message', created_at: '2026-08-27T08:06:00Z' };
const reply = { id: 'bbb', from: 'petrus', body: 'Great! Please spec this.', reply_to: 'aaa', created_at: '2026-08-27T08:41:00Z', _room: 'thinkoff-development' };

it('normalize carries reply_to and resolved reply_target', () => {
const withTarget = { ...reply, _replyTarget: { from: target.from, body: target.body } };
const ev = groupmindAdapter.normalize(withTarget, { poller: { handle: '@test' } });
assert.equal(ev.payload.reply_to, 'aaa');
assert.equal(ev.payload.reply_target.from, '@claudeMB');
});

it('formatLine shows the resolved reply target', () => {
const withTarget = { ...reply, _replyTarget: { from: target.from, body: target.body } };
const ev = groupmindAdapter.normalize(withTarget, { poller: { handle: '@test' } });
const line = groupmindAdapter.formatLine(ev);
assert.ok(line.includes('in reply to @claudeMB'), line);
assert.ok(line.includes('the AgentOS fleet message'), line);
});

it('formatLine marks an unresolved reply as a reply, never freestanding', () => {
const ev = groupmindAdapter.normalize(reply, { poller: { handle: '@test' } });
const line = groupmindAdapter.formatLine(ev);
assert.ok(line.includes('a reply'), line);
assert.ok(line.includes('bbb') === false, 'target id, not own id');
assert.ok(line.includes('aaa'), line);
});

it('non-replies keep the plain single-line format', () => {
const ev = groupmindAdapter.normalize(target, { poller: { handle: '@test' } });
const line = groupmindAdapter.formatLine(ev);
assert.ok(!line.includes('reply'), line);
assert.ok(!line.includes('\n'), line);
});
});
Loading