status-line.ts 937 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * Status Line Extension
  3. *
  4. * Demonstrates ctx.ui.setStatus() for displaying persistent status text in the footer.
  5. * Shows turn progress with themed colors.
  6. */
  7. import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
  8. export default function (pi: ExtensionAPI) {
  9. let turnCount = 0;
  10. pi.on("session_start", async (_event, ctx) => {
  11. const theme = ctx.ui.theme;
  12. ctx.ui.setStatus("status-demo", theme.fg("dim", "Ready"));
  13. });
  14. pi.on("turn_start", async (_event, ctx) => {
  15. turnCount++;
  16. const theme = ctx.ui.theme;
  17. const spinner = theme.fg("accent", "●");
  18. const text = theme.fg("dim", ` Turn ${turnCount}...`);
  19. ctx.ui.setStatus("status-demo", spinner + text);
  20. });
  21. pi.on("turn_end", async (_event, ctx) => {
  22. const theme = ctx.ui.theme;
  23. const check = theme.fg("success", "✓");
  24. const text = theme.fg("dim", ` Turn ${turnCount} complete`);
  25. ctx.ui.setStatus("status-demo", check + text);
  26. });
  27. }