Skip to content

Commit 9823892

Browse files
committed
feat(mention): add support for subagents mention also
Since subagents also create a child sessions I commented notifications about discarding message/parts.
1 parent 68c9ab9 commit 9823892

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lua/opencode/ui/formatter.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ function M._format_user_prompt(output, text, message)
335335
if part.source and part.source.text then
336336
table.insert(mentions, part.source.text)
337337
end
338+
elseif part.type == 'agent' then
339+
if part.source then
340+
table.insert(mentions, part.source)
341+
end
338342
end
339343
end
340344
end

lua/opencode/ui/renderer.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ function M.on_message_updated(message, revert_index)
365365
end
366366

367367
if state.active_session.id ~= message.info.sessionID then
368-
vim.notify('Session id does not match, discarding message: ' .. vim.inspect(message), vim.log.levels.WARN)
368+
---@TODO This is probably a child session message, handle differently?
369+
-- vim.notify('Session id does not match, discarding message: ' .. vim.inspect(message), vim.log.levels.WARN)
369370
return
370371
end
371372

@@ -427,7 +428,8 @@ function M.on_part_updated(properties, revert_index)
427428
end
428429

429430
if state.active_session.id ~= part.sessionID then
430-
vim.notify('Session id does not match, discarding part: ' .. vim.inspect(part), vim.log.levels.WARN)
431+
---@TODO This is probably a child session part, handle differently?
432+
-- vim.notify('Session id does not match, discarding part: ' .. vim.inspect(part), vim.log.levels.WARN)
431433
return
432434
end
433435

@@ -477,7 +479,7 @@ function M.on_part_updated(properties, revert_index)
477479
M._replace_part_in_buffer(part.id, formatted)
478480
end
479481

480-
if part.type == 'file' and part.source and part.source.text then
482+
if (part.type == 'file' or part.type == 'agent') and part.source then
481483
-- we have a mention, we need to rerender the early part to highlight
482484
-- the mention.
483485
local text_part_id = M._find_text_part_for_message(message)

0 commit comments

Comments
 (0)