prompt-footer.test.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /** @jsxImportSource @opentui/solid */
  2. import { expect, test } from "bun:test"
  3. import { RGBA } from "@opentui/core"
  4. import { testRender } from "@opentui/solid"
  5. import type { Context } from "@opencode-ai/plugin/tui/context"
  6. import { PromptFooter } from "../../src/feature-plugins/prompt/footer"
  7. test("prompt footer separates simultaneous subagent, shell, and usage status", async () => {
  8. const color = RGBA.fromInts(200, 200, 200)
  9. const context = {
  10. location: { directory: "/workspace" },
  11. theme: { text: { default: color, subdued: color } },
  12. keymap: {
  13. shortcuts: (id: string) =>
  14. id === "session.child.first" ? ["ctrl+j"] : id === "command.palette.show" ? ["ctrl+p"] : [],
  15. },
  16. data: {
  17. session: {
  18. family: () => ["session", "child"],
  19. status: (id: string) => (id === "child" ? "running" : "idle"),
  20. get: () => ({ id: "session", location: { directory: "/workspace" } }),
  21. cost: () => 1,
  22. message: { list: () => [] },
  23. },
  24. shell: {
  25. list: () => [{ metadata: { sessionID: "session" } }],
  26. },
  27. location: {
  28. model: { list: () => [] },
  29. },
  30. },
  31. } as unknown as Context
  32. const app = await testRender(() => <PromptFooter context={context} sessionID="session" mode="normal" />, {
  33. width: 80,
  34. height: 2,
  35. })
  36. try {
  37. await app.renderOnce()
  38. expect(app.captureCharFrame()).toContain("ctrl+j 1 subagent · 1 shell · $1.00")
  39. expect(app.captureCharFrame()).toContain("ctrl+p commands")
  40. } finally {
  41. app.renderer.destroy()
  42. }
  43. })