Skip to content

Commit

Permalink
Merge pull request #252 from WolframResearch/251-chatdriven-notebooks…
Browse files Browse the repository at this point in the history
…-are-broken-in-102

Workaround for invisible empty ChatInput cells that are temporarily created in ChatDriven notebooks
  • Loading branch information
rhennigan authored Jul 18, 2023
2 parents 05b7865 + b7ec4ad commit 3cd031b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Source/Chatbook/FrontEnd.wl
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ currentChatSettings[ cell0_CellObject, key_String ] := Catch @ Enclose[
"ChatCells"
];

(* There are apparently temporary mystery cells that get created that aren't in the root cell list which are
then immediately removed. These inherit the style specified by `DefaultNewCellStyle`. In chat-driven
notebooks, this is set to "ChatInput", which has a dynamic cell dingbat that needs to resolve
`currentChatSettings`. In this case, we have special behavior here to prevent a failure. Since that new
temporary cell doesn't get displayed anyway, we don't need to actually resolve the chat settings for it,
so we just return a default value instead. Yes, this is an ugly hack.
*)
If[ And[ MemberQ[ styles, $$chatInputStyle ], (*It's a "ChatInput" cell*)
! MemberQ[ cells, cell ], (*It's not in the list of cells*)
MatchQ[ CurrentValue[ nbo, DefaultNewCellStyle ], $$chatInputStyle ] (*Due to DefaultNewCellStyle*)
],
Throw @ Lookup[ $defaultChatSettings, key, Inherited ]
];

before = ConfirmMatch[
Replace[ cells, { { a___, cell, ___ } :> { a }, ___ :> $Failed } ],
{ ___CellObject },
Expand Down

0 comments on commit 3cd031b

Please sign in to comment.