dialog-agent.tsx 734 B

12345678910111213141516171819202122232425262728293031
  1. import { createMemo } from "solid-js"
  2. import { useLocal } from "@tui/context/local"
  3. import { DialogSelect } from "@tui/ui/dialog-select"
  4. import { useDialog } from "@tui/ui/dialog"
  5. export function DialogAgent() {
  6. const local = useLocal()
  7. const dialog = useDialog()
  8. const options = createMemo(() =>
  9. local.agent.list().map((item) => {
  10. return {
  11. value: item.name,
  12. title: item.name,
  13. description: item.native ? "native" : item.description,
  14. }
  15. }),
  16. )
  17. return (
  18. <DialogSelect
  19. title="Select agent"
  20. current={local.agent.current().name}
  21. options={options()}
  22. onSelect={(option) => {
  23. local.agent.set(option.value)
  24. dialog.clear()
  25. }}
  26. />
  27. )
  28. }