fix(desktop): hide a persisted Discord triggering note in user bubbles
Rows written before the gateway fix still carry the `[Triggering message id: …]` note as the first line of `content`. `displayContentForMessage` already projects user rows for display (skill invocations, attached context); strip that one gateway envelope there as well — presentation only, and only the note: the `[Replying to: "…"]` pointer next to it is kept, and assistant rows are untouched. Part of #114719
This commit is contained in:
@@ -183,6 +183,22 @@ describe('toChatMessages', () => {
|
||||
expect(chatMessageText(message)).toBe('@file:tsconfig.tsbuildinfo\n\nwhat is this file')
|
||||
})
|
||||
|
||||
it('hides a persisted Discord triggering-message note but keeps the reply pointer (#114719)', () => {
|
||||
const note =
|
||||
'[Triggering message id: `1550380365858865156` — use as `message_id` for reply/react/pin via the discord tools.]'
|
||||
|
||||
const [plain, , replied, assistant] = toChatMessages([
|
||||
{ role: 'user', content: `${note}\n\nCreate a project plan for Q4`, timestamp: 1 },
|
||||
{ role: 'assistant', content: 'ok', timestamp: 2 },
|
||||
{ role: 'user', content: `[Replying to: "Create a project plan for Q4"]\n\n${note}\n\nyes do that`, timestamp: 3 },
|
||||
{ role: 'assistant', content: note, timestamp: 4 }
|
||||
])
|
||||
|
||||
expect(chatMessageText(plain)).toBe('Create a project plan for Q4')
|
||||
expect(chatMessageText(replied)).toBe('[Replying to: "Create a project plan for Q4"]\n\nyes do that')
|
||||
expect(chatMessageText(assistant)).toBe(note)
|
||||
})
|
||||
|
||||
it('renders MEDIA tags as assistant attachment links', () => {
|
||||
const [message] = toChatMessages([
|
||||
{
|
||||
|
||||
@@ -19,6 +19,12 @@ const ATTACHED_CONTEXT_MARKER_RE = /(?:^|\n)--- Attached Context ---\s*\n/
|
||||
const CONTEXT_WARNINGS_MARKER_RE = /(?:^|\n)--- Context Warnings ---[\s\S]*$/
|
||||
const CONTEXT_REF_RE = /@(file|folder|url|image|tool|terminal):(?:"[^"\n]+"|'[^'\n]+'|`[^`\n]+`|\S+)/g
|
||||
|
||||
// Gateway routing note for Discord turns (gateway/run_inbound.py::discord_triggering_note).
|
||||
// Current gateways persist the authored text; this heals rows written before that fix. Only
|
||||
// the note is model-facing — the `[Replying to: …]` pointer next to it is kept.
|
||||
const DISCORD_TRIGGERING_NOTE_RE =
|
||||
/(^|\n)\[Triggering message id: `[^`\n]*` — use as `message_id` for reply\/react\/pin via the discord tools\.\]\n*/
|
||||
|
||||
/**
|
||||
* Reply text from a Responses-API `codex_message_items` sidecar (#68321), for rows
|
||||
* whose `content` persisted empty. `commentary` / `analysis` items are mid-turn
|
||||
@@ -88,12 +94,14 @@ function codexMessageItemText(message: SessionMessage): string {
|
||||
}
|
||||
|
||||
function displayContentForMessage(role: SessionMessage['role'], content: unknown): string {
|
||||
const textContent = textFromUnknown(content)
|
||||
const rawText = textFromUnknown(content)
|
||||
|
||||
if (role !== 'user') {
|
||||
return textContent
|
||||
return rawText
|
||||
}
|
||||
|
||||
const textContent = rawText.replace(DISCORD_TRIGGERING_NOTE_RE, '$1')
|
||||
|
||||
// A `/skill` turn is stored expanded (the whole skill body). Current
|
||||
// gateways project it to the invocation before it ever reaches us; this is
|
||||
// the fallback for an older backend that still ships the raw payload.
|
||||
|
||||
Reference in New Issue
Block a user