Skip to content

Conversation

@sellout
Copy link
Contributor

@sellout sellout commented Aug 5, 2025

Overview

The frontmatter supports various settings, like autoupdate (which causes all unison code blocks to update the codebase, without needing to do so in a ucm block) and type which is an aggregate setting (e.g., tutorial, will enable autoupdate and also default unison code blocks to :hide instead of :show).

This is a step toward #5792.

Implementation notes

This makes a few adjacent changes:

  • There is now a :show info tag (alongside :hide and :hide-all). This is normally the default (which is why it wasn’t needed before), but now type: tutorial in the frontmatter will make :hide the default for unison code blocks.

  • docs/branchless.md has had its leading horizontal rules changed from 3 to 5 hyphens, to avoid triggering the frontmatter parser. 5 hyphens is what cmark outputs anyway, so it’s slightly more consistent, too.

  • The output of .github/ISSUE_TEMPLATE/bug_report.md had previously incorrectly included the frontmatter (interpreting the separators as horizontal rules). Now, that frontmatter is removed (although it could alternatively be preserved if we decide to preserve unknown frontmatter contents).

Test coverage

There are new transcripts covering various frontmatter settings.

Loose ends

One major loose end: two of the new transcripts cause a CI failure (due to diffing the transcript outputs), because the output includes a path to a temporary directory, which changes on every run. Do we have any way to manage that currently … or any suggestions on how we should?

  There's nothing for me to add right now.

  Hint: I'm currently watching for definitions in .u files under
        the
        /private/var/folders/l6/2mfycgzj7r1gm9kp1ck8btb00000gn/T/transcript36689
        directory. Make sure you've updated something there
        before using the `update` command, or use `load` to load
        a file explicitly.

And one minor loose end: since the getHidden behavior is represented as a function (to be able to change the handling only for certain stanzas), we can’t represent it in YAML. So it’s not configurable directly, but only as part of a transcript type (like “tutorial”).

@sellout sellout requested a review from aryairani August 5, 2025 18:41
sellout added 2 commits August 5, 2025 12:45
This adds a set of behaviors (currently `autoupdate` and `getHidden`) as
well as a transcript `type` that allows setting multiple behaviors at
once (which can then be overridden).

This also adds a `:show`  info tag, which can be used to override the
default `:hide` that’s enabled by the tutorial type.
@sellout sellout force-pushed the transcript-autoupdate branch from 929a259 to cd70a7b Compare August 5, 2025 18:59
sellout added 2 commits August 5, 2025 13:06
This makes two additional changes:

- Use 5 (instead of 3) `-` for the horizontal rules in
  docs/branchless.md, because opening with `---` triggers the
  frontmatter parser (and
  [cmark](https://hackage.haskell.org/package/cmark-0.6.1) outputs 5 `-`
  in the output anyway).

- The output of .github/ISSUE_TEMPLATE/bug_report.md had previously
  incorrectly included the frontmatter (interpreting the separators as
  horizontal rules). Now that frontmatter is removed (although it could
  alternatively be preserved if we decide to preserve unknown frontmatter contents).
Unfortunately, since the `getHidden` behavior is a function, we can’t
represent it in YAML, so it’s not configurable outside of a transcript
type (like “tutorial”).
@sellout sellout force-pushed the transcript-autoupdate branch from cd70a7b to 8cb361e Compare August 5, 2025 19:06
foo = ()
```

but this should succeed, because the tutorial’s `autoupdate` behavior has been overridden by the explicit `autoupdate` setting.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. So order doesn't matter; it's ok that type: tutorial came after autoupdate: false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right – we don’t currently have anything where that would be helpful. If you’re setting an individual value, it either overrides the type or is useless.

I could see a future where there are more overlapping things, and something like type: [tutorial, verbose] would be different from type: [verbose, tutorial] because tutorial and verbose each set different values for some of the same behaviors.

@aryairani
Copy link
Contributor

aryairani commented Aug 6, 2025

Oh man... Safari threw away my long draft comment when I changed SPA tabs, sad 😞

@aryairani
Copy link
Contributor

aryairani commented Aug 6, 2025

  • docs/branchless.md has had its leading horizontal rules changed from 3 to 5 hyphens, to avoid triggering the frontmatter parser. 5 hyphens is what cmark outputs anyway, so it’s slightly more consistent, too.

I think I sometimes type 3 hyphens... does it give an okay error message if one does that? Otherwise I can learn to not do that.

  • The output of .github/ISSUE_TEMPLATE/bug_report.md had previously incorrectly included the frontmatter (interpreting the separators as horizontal rules). Now, that frontmatter is removed (although it could alternatively be preserved if we decide to preserve unknown frontmatter contents).

I think we probably want to preserve it, in case we're creating markdown output to feed into something else, like a blog? It's not urgent at the moment though.

the output includes a path to a temporary directory, which changes on every run

Yeah this has bitten us before, and I don't remember why it wasn't currently an issue.

One idea off the top of my head would be to add an --redact-watcher-hint or something, which is set to True in bin/transcripts, which gives you:

  There's nothing for me to add right now.

  Hint: I'm currently watching for definitions in .u files under
        the <redacted> directory.  Make sure you've updated something 
         there before using the `update` command, or use `load` to load
        a file explicitly.  

or just redact it when running a transcript, without exposing an explicit option.

And one minor loose end: since the getHidden behavior is represented as a function (to be able to change the handling only for certain stanzas), we can’t represent it in YAML. So it’s not configurable directly, but only as part of a transcript type (like “tutorial”).

I didn't understand what this one refers to?

@sellout
Copy link
Contributor Author

sellout commented Aug 7, 2025

  • docs/branchless.md has had its leading horizontal rules changed from 3 to 5 hyphens, to avoid triggering the frontmatter parser. 5 hyphens is what cmark outputs anyway, so it’s slightly more consistent, too.

I think I sometimes type 3 hyphens... does it give an okay error message if one does that? Otherwise I can learn to not do that.

It’s only a problem if

  1. three hyphens is the first line in the file,
  2. there is another three-hyphen-only line somewhere else in the file, and
  3. what’s in between those two lines parses as YAML.

Otherwise, it’s fine.

If you do hit that particular case (which I’m not sure that docs/branchless.md even does, because I don’t think I had implemented the third condition when I changed that), then that block will just disappear from the output, as the ISSUE_TEMPLATE/bug_report.md case does.

Basically, frontmatter never errors – if it’s not valid YAML, we assume it’s markdown; if it is valid YAML, we either process it as transcript settings or discard it (we’re a bit lax – if you have transcript settings mixed with other stuff, we’ll handle the transcript settings and discard the rest).

I think we probably want to preserve it, in case we're creating markdown output to feed into something else, like a blog? It's not urgent at the moment though.

Yeah, that’s reasonable. I think it’s easy enough to change. We’ll just hold Aeson.Value in the AST, and only use Transcript.Settings locally.

the output includes a path to a temporary directory, which changes on every run

Yeah this has bitten us before, and I don't remember why it wasn't currently an issue.

One idea off the top of my head would be to add an --redact-watcher-hint or something, which is set to True in bin/transcripts, which gives you:

  There's nothing for me to add right now.

  Hint: I'm currently watching for definitions in .u files under
        the <redacted> directory.  Make sure you've updated something 
         there before using the `update` command, or use `load` to load
        a file explicitly.  

or just redact it when running a transcript, without exposing an explicit option.

Yeah, this seems reasonable.

And one minor loose end: since the getHidden behavior is represented as a function (to be able to change the handling only for certain stanzas), we can’t represent it in YAML. So it’s not configurable directly, but only as part of a transcript type (like “tutorial”).

I didn't understand what this one refers to?

So, in the Haskell, we have a type like

data Behaviors = {
  autoupdate :: Bool,
  getHidden :: ProcessedBlock -> Hidden,
}

getHidden takes the current stanza and returns HideOutput/HideAll/Shown. It does it this way because the “tutorial” type only hides output by default on unison blocks, not ucm or api.

Internally, it’s easy to define the Tutorial transcript type with a function that does the right thing.

And while autoupdate is just a bool, so it’s easy to map it to

---
autoupdate: true
---

in the frontmatter, we can’t put

---
getHidden: \stanza -> if type stanza == "unison" then HideOutput else Shown
---

and expect anything reasonable to happen.

So, maybe getHidden should be split into three settings – one for each stanza type … or maybe there’s another solution.

@sellout sellout force-pushed the transcript-autoupdate branch from cd6149d to 4a2fa22 Compare August 8, 2025 19:47
sellout added 3 commits August 8, 2025 17:26
We now preserve all valid JSON frontmatter (except for `null`), so it
can be used for multiple purposes (e.g., a transcript could also be a
Jekyll post).
@sellout sellout force-pushed the transcript-autoupdate branch from 4a2fa22 to cc5ba67 Compare August 9, 2025 05:32
@sellout
Copy link
Contributor Author

sellout commented Aug 9, 2025

the output includes a path to a temporary directory, which changes on every run

Yeah this has bitten us before, and I don't remember why it wasn't currently an issue.

I fixed this, and then when merging trunk, I noticed that @ChrisPenner solved the same issue on the MCP side of things, so I unified the two.

@sellout sellout marked this pull request as ready for review August 9, 2025 05:37
@aryairani
Copy link
Contributor

So, maybe getHidden should be split into three settings – one for each stanza type … or maybe there’s another solution.

Ah, ok I think I get it. Honestly I don't think we'll find we want to configure the defaults all of these; but if we do, then I think splitting it into three settings would make sense.

Auto-hiding the unison block output makes sense to me (at the moment), because it's reasonable to author a transcript where you're implying that all the code type checks at least.

For auto-hiding the ucm block output I guess I'm not sure about. I'm not sure what the point of a transcript that runs a bunch of ucm commands in a throw-away codebase and also doesn't show you the output of the commands would be. I'm not sure there's not a use case for it, but it's not jumping out at me.

And then for auto-hiding api block output, I'd defer to @ChrisPenner, I guess it have to be some transcript where you use API calls to set up a bunch of data before manually :showing something? I'm not sure how often that comes up.

tl;dr: I think this is good as-is for now. (:

labels: bug
name: Bug report
title: ''
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, did it reorder and alphabetize these? I guess that's fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I missed that. I don’t know if yaml supports preserving ordering, but I do know that YAML doesn’t allow ordering to be significant. So, while it would be nice to preserve what people wrote, it isn’t allowed to affect the behavior.

@aryairani aryairani merged commit 3ecad94 into unisonweb:trunk Aug 9, 2025
17 checks passed
@sellout sellout deleted the transcript-autoupdate branch August 9, 2025 17:53
@sellout
Copy link
Contributor Author

sellout commented Aug 9, 2025

So, maybe getHidden should be split into three settings – one for each stanza type … or maybe there’s another solution.

Ah, ok I think I get it. Honestly I don't think we'll find we want to configure the defaults all of these; but if we do, then I think splitting it into three settings would make sense.

Ah, that’s a good point. We could expose a single hide-unison-output: Bool setting or something, and not worry about the other two yet. But yeah, that’s a minor1 change, so fine to defer.

Footnotes

  1. In the SemVer meaning of the word.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants