   ## Image gets unnaturally folded if it's referenced at least once
   ## and doesn't have any children (don't want to hide children, and this
   ## can also lead to infinite loop if children has the image reference).
-  messageFolded.set id, true if images[id].naturallyFolded or
+  newDefault = images[id].naturallyFolded or
     (not images[id].children and
      (images[id].count > 0 or
       (imagesInternal[images[id].file]? and
        imagesInternal[images[id].file].count > 0)))
+  if newDefault != defaultFolded.get id
+    defaultFolded.set id, newDefault
+    messageFolded.set id, newDefault
   ## No longer care about this image if it's not referenced and doesn't have
   ## a rendered template.
   if images[id].count == 0 and id not of id2template

  @editBody = new ReactiveVar null
  @lastTitle = null
  @savedTitles = []
  @autorun =>
    data = Template.currentData()
    return unless data?


messageRaw = new ReactiveDict
export messageFolded = new ReactiveDict
defaultFolded = new ReactiveDict
messageHistory = new ReactiveDict
messageKeyboard = new ReactiveDict
messagePreview = new ReactiveDict
