tui-config-once-toast.tsx 671 B

12345678910111213141516171819202122232425
  1. import type { TuiPluginModule } from "@opencode-ai/plugin/tui"
  2. let seen = false
  3. const plugin: TuiPluginModule & { id: string } = {
  4. id: "local.config-once-toast",
  5. async tui(api) {
  6. if (seen) return
  7. const cfg = api.state.config
  8. if (cfg.plugin !== undefined && !Array.isArray(cfg.plugin)) {
  9. throw new Error("Invalid config: plugin must be an array")
  10. }
  11. const mdl = typeof cfg.model === "string" && cfg.model.trim() ? cfg.model : "default"
  12. seen = true
  13. api.ui.toast({
  14. title: "Config check",
  15. message: `This is a 1 time toast, validating ur config (model: ${mdl})`,
  16. variant: "info",
  17. })
  18. },
  19. }
  20. export default plugin