fix(ui): null-guard agent access and refocus input after token insert

AgentMap.Instance() and AgentChatLog.Instance() can return null during
zone transitions. Capture pointers into locals and short-circuit the
FlagMarkerCount/LinkedItem deref when null so the entries are correctly
greyed out without faulting. Add Activate/ActivatePos after each append
so the input box regains focus and the caret lands after the token,
matching the SymbolPicker and AutoComplete insert paths.
This commit is contained in:
2026-05-21 18:15:12 +02:00
parent 80699b27e4
commit ce7dda9e48
+13 -2
View File
@@ -1130,18 +1130,29 @@ public sealed class ChatLogWindow : Window
// so the inserted token cannot expand to nothing.
unsafe
{
var flagSet = AgentMap.Instance()->FlagMarkerCount > 0;
// Null-check before deref: pointers can be null during zone transitions.
var agentMap = AgentMap.Instance();
var flagSet = agentMap != null && agentMap->FlagMarkerCount > 0;
using (ImRaii.Disabled(!flagSet))
{
if (ImGui.Selectable(HellionStrings.ChatLog_Insert_MapFlag))
{
Chat += "<flag>";
Activate = true;
ActivatePos = Chat.Length;
}
}
var itemSet = AgentChatLog.Instance()->LinkedItem.ItemId != 0;
var agentChat = AgentChatLog.Instance();
var itemSet = agentChat != null && agentChat->LinkedItem.ItemId != 0;
using (ImRaii.Disabled(!itemSet))
{
if (ImGui.Selectable(HellionStrings.ChatLog_Insert_ItemLink))
{
Chat += "<item>";
Activate = true;
ActivatePos = Chat.Length;
}
}
}
}