toldOf

tcmts.studio.toldOf · #g4odrold · term · runs in the browser

uses tcmts.react.refresh, which uses tcmts.react.router, which uses tcmts.react.createRouter, which uses IntersectionObserver

What a tcm command the studio ran said, as a toast (its first line, or what refused it), and the page made again.

import { refresh } from "#codebase/tcmts/react";
import { toasts } from "#codebase/tcmts/share";

export async function toldOf(run: Promise<string>, done: string, failed: string): Promise<boolean> {
  try {
    const said = await run;
    toasts.add(
      { title: done, description: said.split("\n").filter(Boolean).at(-1), tone: "ok" },
      { timeout: 5000 },
    );
    refresh();
    return true;
  } catch (e) {
    toasts.add(
      { title: failed, description: (e as Error).message, tone: "bad" },
      { timeout: 9000 },
    );
    return false;
  }
}

uses

used by