composition-settled.ts 954 B

123456789101112131415161718192021222324
  1. import type { Context } from 'cordis'
  2. /**
  3. * Marker the shipped-composition smoke gates its first prompt on. The TUI renders as soon as
  4. * its own fiber starts, so a prompt typed at the banner can reach the loop while
  5. * later rows — tool plugins, persistence — are still activating, and would
  6. * assemble a partial catalog. Waiting for this line makes the turn observe the
  7. * settled tree.
  8. */
  9. export const COMPOSITION_SETTLED_MARKER = 'COMPOSITION_TREE_SETTLED'
  10. export const name = 'composition-settled'
  11. /**
  12. * Announce settled Loader activation on the terminal byte stream, after every
  13. * entry in the booted tree has started. The write is detached: awaiting the
  14. * Loader from inside an entry would wait on this entry's own activation.
  15. * @param ctx - the loader-mounted plugin context.
  16. */
  17. export function apply(ctx: Context): void {
  18. void ctx.loader.await().then(() => {
  19. process.stdout.write(`\n${COMPOSITION_SETTLED_MARKER}\n`)
  20. })
  21. }