Skip to content

Commit

Permalink
Merge pull request #917 from WolframResearch/bugfix/blank-NA-window-a…
Browse files Browse the repository at this point in the history
…fter-loading-a-chat

Bugfix: Fixed an issue (hopefully) where chat window could sometimes be blank after loading a chat
  • Loading branch information
rhennigan authored Nov 14, 2024
2 parents 543d796 + 49032a9 commit 8eaebb6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Source/Chatbook/ChatModes/UI.wl
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,7 @@ loadConversation // beginDefinition;

loadConversation[ nbo_NotebookObject, id_ ] := Enclose[
Module[ { loaded, uuid, title, messages, cells, cellObjects },

loaded = ConfirmBy[ LoadChat @ id, AssociationQ, "Loaded" ];
uuid = ConfirmBy[ loaded[ "ConversationUUID" ], StringQ, "UUID" ];
title = ConfirmBy[ loaded[ "ConversationTitle" ], StringQ, "Title" ];
Expand All @@ -1710,9 +1711,15 @@ loadConversation[ nbo_NotebookObject, id_ ] := Enclose[
cellObjects = ConfirmMatch[ Cells @ nbo, { ___CellObject }, "CellObjects" ];
ConfirmMatch[ NotebookDelete @ cellObjects, { Null... }, "Delete" ];
NotebookDelete @ First[ Cells[ nbo, AttachedCell -> True, CellStyle -> "ChatInputField" ], $Failed ];
SelectionMove[ nbo, Before, Notebook, AutoScroll -> True ];
ConfirmMatch[ NotebookWrite[ nbo, cells, AutoScroll -> False ], Null, "Write" ];
If[ Cells @ nbo === { }, NotebookWrite[ nbo, cells, AutoScroll -> False ] ];

WithCleanup[
CurrentValue[ nbo, Selectable ] = True,
SelectionMove[ nbo, Before, Notebook, AutoScroll -> True ];
ConfirmMatch[ NotebookWrite[ nbo, cells, AutoScroll -> False ], Null, "Write" ];
If[ Cells @ nbo === { }, NotebookWrite[ nbo, cells, AutoScroll -> False ] ],
CurrentValue[ nbo, Selectable ] = Inherited
];

ChatbookAction[ "AttachWorkspaceChatInput", nbo ];
CurrentChatSettings[ nbo, "ConversationUUID" ] = uuid;
CurrentValue[ nbo, { TaggingRules, "ConversationTitle" } ] = title;
Expand Down

0 comments on commit 8eaebb6

Please sign in to comment.