import { RefreshCwIcon } from "lucide-react"; import { Button } from "../../ui/button"; import { cn } from "../lib/utils"; import type { PersonalResourceAttachmentController, PersonalResourceNotice, } from "../lib/use-personal-resource-attachment"; const noticeMessages: Record = { source_changed: "Access to the selected personal resource changed. Choose an available resource before submitting.", reloading: "Session authority changed. Reloading personal resources before retrying.", reload_failed: "Session authority could not be refreshed. Retry before sending again.", reloaded: "Session authority changed. Personal resources were reloaded before retrying.", }; export function PersonalResourceAttachmentControl(props: { controller: PersonalResourceAttachmentController; disabled?: boolean | undefined; compact?: boolean | undefined; }) { const { controller } = props; // Healthy selections are already described inside their pickers. Keep the // composer-top surface for transient or actionable status only. const hasVisibleStatus = controller.loading || controller.notice !== null || controller.error !== null || controller.truncated; if (!controller.eligible || !hasVisibleStatus) { return null; } const disabled = props.disabled || controller.loading || controller.refreshing; return (
{controller.loading ? (

Loading selected personal resources…

) : null} {controller.notice ? (

{noticeMessages[controller.notice]}

) : null} {controller.error ? (
The selected personal resource is unavailable. Retry, or pick another environment or machine.
) : null} {controller.truncated ? (

Showing the first 400 personal resources of each supported type.

) : null}
); }