Skip to content

Commit

Permalink
Bugfix: Allow reformatting raw cell expressions in chat window
Browse files Browse the repository at this point in the history
  • Loading branch information
rhennigan committed Nov 14, 2024
1 parent 543d796 commit bcfb322
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Developer/Resources/WorkspaceStyles.wl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ Cell[
]


(* Ensure that raw cell expressions can be toggled back to formatted view: *)
Cell[
StyleData[ "CellExpression" ],
Selectable -> True
]


Cell[
StyleData[ "WorkspaceChatStyleSheetInformation" ],
TaggingRules -> <| "WorkspaceChatStyleSheetVersion" -> $stylesheetVersion |>
Expand Down
2 changes: 1 addition & 1 deletion FrontEnd/Assets/Extensions/CoreExtensions.nb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Notebook[
Cell["Chatbook Core.nb Extensions", "Title"],
Cell[
StyleData["ChatStyleSheetInformation"],
TaggingRules -> <|"StyleSheetVersion" -> "1.5.2.3940399854"|>
TaggingRules -> <|"StyleSheetVersion" -> "1.5.2.3940575613"|>
],
Cell[
StyleData["NotebookAssistant`Text"],
Expand Down
2 changes: 1 addition & 1 deletion FrontEnd/StyleSheets/Chatbook.nb
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ Notebook[
],
Cell[
StyleData["ChatStyleSheetInformation"],
TaggingRules -> <|"StyleSheetVersion" -> "1.5.2.3940405830"|>
TaggingRules -> <|"StyleSheetVersion" -> "1.5.2.3940575613"|>
],
Cell[
StyleData["NotebookAssistant`Text"],
Expand Down
3 changes: 2 additions & 1 deletion FrontEnd/StyleSheets/Wolfram/WorkspaceChat.nb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ Notebook[
Magnification -> 0.85,
Background -> GrayLevel[1]
],
Cell[StyleData["CellExpression"], Selectable -> True],
Cell[
StyleData["WorkspaceChatStyleSheetInformation"],
TaggingRules -> <|"WorkspaceChatStyleSheetVersion" -> "1.5.2.3940399854"|>
TaggingRules -> <|"WorkspaceChatStyleSheetVersion" -> "1.5.2.3940575613"|>
],
Cell[
StyleData[
Expand Down
10 changes: 9 additions & 1 deletion Source/Chatbook/Serialization.wl
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,15 @@ cellToString[ Cell[ a__, $$subSubItemStyle, b___ ] ] :=
];

(* Cells showing raw data (ctrl-shift-e) *)
cellToString[ Cell[ RawData[ str_String ], ___ ] ] := (needsBasePrompt[ "Notebooks" ]; str);
cellToString[ Cell[ RawData[ str_String ], ___ ] ] :=
Catch @ Module[ { held },
If[ ! TrueQ @ $WorkspaceChat, needsBasePrompt[ "Notebooks" ]; Throw @ str ];
held = Quiet @ ToExpression[ str, InputForm, HoldComplete ];
If[ MatchQ[ held, HoldComplete[ _Cell ] ],
cellToString @@ held,
needsBasePrompt[ "Notebooks" ]; str
]
];

(* Include a stack trace for message cells when available *)
cellToString[ Cell[ a__, "Message", "MSG", b___ ] ] :=
Expand Down

0 comments on commit bcfb322

Please sign in to comment.