@agimon-ai/po-web-components 0.0.0-alpha.125 → 0.0.0-alpha.127

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ import { TLiteral } from "../../../../../../node_modules/.pnpm/typebox@1.4.2/nod
6
6
  import { TString } from "../../../../../../node_modules/.pnpm/typebox@1.4.2/node_modules/typebox/build/type/types/string.mjs";
7
7
  import { TUnion } from "../../../../../../node_modules/.pnpm/typebox@1.4.2/node_modules/typebox/build/type/types/union.mjs";
8
8
  import { TRecord } from "../../../../../../node_modules/.pnpm/typebox@1.4.2/node_modules/typebox/build/type/types/record.mjs";
9
+ import { TOptional } from "../../../../../../node_modules/.pnpm/typebox@1.4.2/node_modules/typebox/build/type/types/_optional.mjs";
9
10
  import { Static } from "../../../../../../node_modules/.pnpm/typebox@1.4.2/node_modules/typebox/build/type/types/static.mjs";
10
11
  import { PoHubSessionUsage } from "./hubChannel.mjs";
11
12
  //#region ../po-core/dist/src/schemas/workflow.d.mts
@@ -43,7 +44,7 @@ export type PoWorkflowAssignments = Static<typeof PoWorkflowAssignmentsSchema>;
43
44
  export declare const PoWorkflowIdentityDiscoverySchema: TObject<{
44
45
  scope: TObject<{
45
46
  workspaceId: TString;
46
- product: TString;
47
+ product: TOptional<TString>;
47
48
  revision: TString;
48
49
  }>;
49
50
  candidates: TArray<TObject<{
@@ -72,7 +73,7 @@ export declare const PoWorkflowAllocationSchema: TObject<{
72
73
  }>;
73
74
  scope: TObject<{
74
75
  workspaceId: TString;
75
- product: TString;
76
+ product: TOptional<TString>;
76
77
  revision: TString;
77
78
  }>;
78
79
  assignments: TRecord<"^.*$", TString>;
@@ -107,7 +108,7 @@ export declare const PoWorkflowExpectedIdentitySchema: TUnion<[TObject<{
107
108
  kind: TLiteral<"profile">;
108
109
  scope: TObject<{
109
110
  workspaceId: TString;
110
- product: TString;
111
+ product: TOptional<TString>;
111
112
  revision: TString;
112
113
  }>;
113
114
  definitionRevision: TString;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.mts","names":["Type.TString","Type.TObject","Type.TArray","Type.TLiteral","Type.TUnion","Type.TRecord","Type.TBoolean"],"sources":["../../../../../../../../po-core/dist/src/schemas/workflow.d.mts"],"mappings":";;;;;;;;;;;;qBAYqB,+BAA+BC;EAClD,QAAQD;EACR,KAAKA;;YAEK,0BAA0B,cAAc;;qBAE/B,wBAAwBC;EAC3C,OAAOD;EACP,gBAAgBA;EAChB,QAAQA;EACR,mBAAmBA;;YAET,mBAAmB,cAAc;;qBAQxB,sCAAsCC;EACzD,YAAYA;IACV,QAAQD;IACR,KAAKA;;EAEP,UAAUA;EACV,OAAOE,OAAYF;EACnB,QAAQE,OAAYD;IAClB,MAAMG,QAAaD,iBAAsBA,mBAAwBA;IACjE,KAAKH;IACL,OAAOE,OAAYF;;;YAGX,iCAAiC,cAAc;qBACtC,6BAA6BK,gBAAqBL;YAC3D,wBAAwB,cAAc;qBAgB7B,mCAAmCC;EACtD,OAAOA;IACL,aAAaD;IACb,SAASA;IACT,UAAUA;;EAEZ,YAAYE,OAAYD;IACtB,KAAKD;IACL,OAAOA;IACP,OAAOE,OAAYF;IACnB,iBAAiBM;;;YAGT,8BAA8B,cAAc;;qBAuBnC,4BAA4BL;EAC/C,SAASE;EACT,cAAcF;IACZ,YAAYA;MACV,QAAQD;MACR,KAAKA;;IAEP,UAAUA;IACV,OAAOE,OAAYF;IACnB,QAAQE,OAAYD;MAClB,MAAMG,QAAaD,iBAAsBA,mBAAwBA;MACjE,KAAKH;MACL,OAAOE,OAAYF;;;EAGvB,OAAOC;IACL,aAAaD;IACb,SAASA;IACT,UAAUA;;EAEZ,aAAaK,gBAAqBL;EAClC,UAAUE,OAAYD;IACpB,KAAKD;IACL,SAASA;IACT,eAAeA;IACf,cAAcA;IACd,UAAUC;MACR,UAAUD;MACV,gBAAgBA;MAChB,WAAWA;MACX,eAAeA;;;;YAIT,uBAAuB,cAAc;;qBAE5B,k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WACA;WACA;WACA;;WAEA;WACA;WACA;WACA;;;;;;;iBAOM;;EAEf,UAAU,cAAc,iCAAiC,QAAQ;;EAEjE,UAAU,SAAS,8BAA8B,QAAQ;;EAEzD,sBAAsB,YAAY,uBAAuB,QAAQ;;EAEjE,QAAQ,SAAS,4BAA4B,QAAQ;;EAErD,WAAW,SAAS,4BAA4B,QAAQ;;;iBAGzC;EACf,YAAY,UAAU,6BAA6B;;;YAGzC;IACR,sBAAsB;IACtB,kCAAkC;IAClC,oBAAoB;IACpB,uBAAuB;IACvB,0BAA0B;IAC1B,wBAAwB;IACxB,iCAAiC"}
1
+ {"version":3,"file":"workflow.d.mts","names":["Type.TString","Type.TObject","Type.TArray","Type.TLiteral","Type.TUnion","Type.TRecord","Type.TOptional","Type.TBoolean"],"sources":["../../../../../../../../po-core/dist/src/schemas/workflow.d.mts"],"mappings":";;;;;;;;;;;;;qBAYqB,+BAA+BC;EAClD,QAAQD;EACR,KAAKA;;YAEK,0BAA0B,cAAc;;qBAE/B,wBAAwBC;EAC3C,OAAOD;EACP,gBAAgBA;EAChB,QAAQA;EACR,mBAAmBA;;YAET,mBAAmB,cAAc;;qBAQxB,sCAAsCC;EACzD,YAAYA;IACV,QAAQD;IACR,KAAKA;;EAEP,UAAUA;EACV,OAAOE,OAAYF;EACnB,QAAQE,OAAYD;IAClB,MAAMG,QAAaD,iBAAsBA,mBAAwBA;IACjE,KAAKH;IACL,OAAOE,OAAYF;;;YAGX,iCAAiC,cAAc;qBACtC,6BAA6BK,gBAAqBL;YAC3D,wBAAwB,cAAc;qBAgB7B,mCAAmCC;EACtD,OAAOA;IACL,aAAaD;IACb,SAASM,UAAeN;IACxB,UAAUA;;EAEZ,YAAYE,OAAYD;IACtB,KAAKD;IACL,OAAOA;IACP,OAAOE,OAAYF;IACnB,iBAAiBO;;;YAGT,8BAA8B,cAAc;;qBAuBnC,4BAA4BN;EAC/C,SAASE;EACT,cAAcF;IACZ,YAAYA;MACV,QAAQD;MACR,KAAKA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IACA,SAAS;MACP,QAAQ;EACZ,aAAa;IACX;MACE,QAAQ;EACZ,aAAa,QAAQ;EACrB,gBAAgB;IACd,SAAS;MACP;MACA;;MAEA;;EAEJ,oBAAoB;IAClB;IACA,WAAW,SAAS;;;EAGtB,mBAAmB;IACjB;MACE;IACF;IACA,WAAW,SAAS;;;;iBAIP;WACN,KAAK;WACL;WACA;WACA;WACA,QAAQ;WACR,gBAAgB,SAAS;WACzB,iBAAiB,SAAS;WAC1B;;WAEA;WACA,OAAO;WACP,WAAW;;WAEX,WAAW;;WAEX,aAAa;;iBAEP;WACN;;WAEA;;;iBAGM;WACN;WACA;WACA;WACA;;WAEA;WACA;WACA;WACA;;;;;;;iBAOM;;EAEf,UAAU,cAAc,iCAAiC,QAAQ;;EAEjE,UAAU,SAAS,8BAA8B,QAAQ;;EAEzD,sBAAsB,YAAY,uBAAuB,QAAQ;;EAEjE,QAAQ,SAAS,4BAA4B,QAAQ;;EAErD,WAAW,SAAS,4BAA4B,QAAQ;;;iBAGzC;EACf,YAAY,UAAU,6BAA6B;;;YAGzC;IACR,sBAAsB;IACtB,kCAAkC;IAClC,oBAAoB;IACpB,uBAAuB;IACvB,0BAA0B;IAC1B,wBAAwB;IACxB,iCAAiC"}
@@ -6,6 +6,8 @@ export interface ProfilePickerProps {
6
6
  /** `undefined`: not chosen. `null`: explicit No profile. A string: that profile. */
7
7
  value: ProfileChoice;
8
8
  onChange: (choice: ProfileChoice) => void;
9
+ /** Only named profiles, with no default or No profile option. */
10
+ required?: boolean;
9
11
  disabled?: boolean;
10
12
  id?: string;
11
13
  className?: string;
@@ -18,7 +20,7 @@ export interface ProfilePickerProps {
18
20
  * list can still be filling in while the person decides, and a source that
19
21
  * did not load is said plainly instead of leaving the list quietly short.
20
22
  */
21
- export declare function ProfilePicker({ profiles, status, value, onChange, disabled, id, className }: ProfilePickerProps): import("react").JSX.Element;
23
+ export declare function ProfilePicker({ profiles, status, value, onChange, required, disabled, id, className }: ProfilePickerProps): import("react").JSX.Element;
22
24
  /**
23
25
  * Loads the profile list for one target, such as a workspace, and reloads when `key` changes.
24
26
  * Undefined while no loader exists, so a host that offers none shows no picker.
@@ -1 +1 @@
1
- {"version":3,"file":"ProfilePicker.d.mts","names":[],"sources":["../../../../../../src/components/ProfilePicker.tsx"],"mappings":";;iBAsBiB;EACf,mBAAmB;EACnB,QAAQ;;EAER,OAAO;EACP,WAAW,QAAQ;EACnB;EACA;EACA;;;;;;;;;;wBAac,gBAAgB,UAAU,QAAQ,OAAO,UAAU,UAAU,IAAI,aAAa,qCAAkB,IAAA;;;;;;wBAqFhG,kBACd,aACA,QAAQ,QAAQ,gBAAgB;EAC7B,QAAQ;EAAqB,mBAAmB"}
1
+ {"version":3,"file":"ProfilePicker.d.mts","names":[],"sources":["../../../../../../src/components/ProfilePicker.tsx"],"mappings":";;iBAsBiB;EACf,mBAAmB;EACnB,QAAQ;;EAER,OAAO;EACP,WAAW,QAAQ;;EAEnB;EACA;EACA;EACA;;;;;;;;;;wBAac,gBACd,UACA,QACA,OACA,UACA,UACA,UACA,IACA,aACC,qCAAkB,IAAA;;;;;;wBA6FL,kBACd,aACA,QAAQ,QAAQ,gBAAgB;EAC7B,QAAQ;EAAqB,mBAAmB"}
@@ -1,2 +1,2 @@
1
- import{ChevronDownIcon as e}from"../icons/icons.mjs";import{cn as t}from"../lib/cn.mjs";import{AgentAvatar as n}from"./AgentAvatar.mjs";import{Spinner as r}from"./Spinner.mjs";import{Button as i}from"./Button.mjs";import{Popover as a,PopoverTrigger as o}from"./Popover.mjs";import{PickerContent as s}from"./Picker.mjs";import{inlineProfileIcon as c,loadProfileCatalog as l,profileChoiceLabel as u,profileChoiceOf as d,profilePickerItems as f,profileValueOf as p}from"../lib/profilePicker.mjs";import{jsx as m,jsxs as h}from"react/jsx-runtime";import{useEffect as g,useId as _,useRef as v,useState as y}from"react";function b({profiles:l,status:g,value:v,onChange:b,disabled:x,id:S,className:C}){let[w,T]=y(!1),E=_(),D=new Map(l.map(e=>[p(e.name),e])),O=f(l).map(e=>{let t=D.get(e.value);return{...e,...t?{lead:/* @__PURE__ */ m(n,{name:e.title,seed:t.name,image:c(t.identity?.icon),size:`sm`})}:{},props:{"data-testid":`profile-option-${e.value}`}}});return/* @__PURE__ */ h(`div`,{"data-slot":`profile-picker`,"data-testid":`profile-picker`,className:t(`flex flex-col gap-1`,C),children:[/* @__PURE__ */ m(`span`,{id:E,className:`text-base font-medium text-po-text`,children:`Profile (optional)`}),/* @__PURE__ */ h(a,{open:w,onOpenChange:T,children:[/* @__PURE__ */ m(o,{asChild:!0,children:/* @__PURE__ */ h(i,{id:S,variant:`outline`,"data-testid":`profile-picker-trigger`,"aria-haspopup":`listbox`,"aria-expanded":w,"aria-labelledby":E,disabled:x,className:`w-full justify-between px-2.5 text-po-text`,children:[/* @__PURE__ */ m(`span`,{className:`truncate`,children:u(v,l)}),g===`loading`?/* @__PURE__ */ m(r,{className:`size-3 shrink-0`}):/* @__PURE__ */ m(e,{className:`size-3.5 shrink-0 opacity-60`})]})}),/* @__PURE__ */ m(s,{side:`bottom`,align:`start`,"data-testid":`profile-picker-list`,title:`Profile`,meta:g===`loading`?`loading`:`${String(l.length)} available`,items:O,value:[p(v)],filterable:O.length>9,filterPlaceholder:`Filter profiles`,className:`w-[min(360px,calc(100vw-24px))]`,onSelect:e=>{b(d(e)),T(!1)}})]}),g===`loading`?/* @__PURE__ */ m(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading profiles…`}):g===`unavailable`?/* @__PURE__ */ h(`p`,{role:`status`,"data-testid":`profile-picker-note`,className:`text-sm text-po-dim`,children:[l.length===0?`Profiles could not be loaded.`:`Some profiles could not be loaded.`,` `,`You can still start a session without one.`]}):null]})}function x(e,t){let[n,r]=y(),i=v(t);g(()=>{i.current=t});let a=t!==void 0;if(g(()=>{if(!a)return;let t=new AbortController;return l(e=>i.current?.(e)??Promise.resolve(void 0),t.signal).then(t=>{t!==void 0&&r({key:e,state:t})}),()=>t.abort()},[e,a]),a)return n?.key===e?n.state:{status:`loading`,profiles:[]}}export{b as ProfilePicker,x as useProfileCatalog};
1
+ import{ChevronDownIcon as e}from"../icons/icons.mjs";import{cn as t}from"../lib/cn.mjs";import{AgentAvatar as n}from"./AgentAvatar.mjs";import{Spinner as r}from"./Spinner.mjs";import{Button as i}from"./Button.mjs";import{Popover as a,PopoverTrigger as o}from"./Popover.mjs";import{PickerContent as s}from"./Picker.mjs";import{inlineProfileIcon as c,loadProfileCatalog as l,profileChoiceLabel as u,profileChoiceOf as d,profilePickerItems as f,profileValueOf as p}from"../lib/profilePicker.mjs";import{jsx as m,jsxs as h}from"react/jsx-runtime";import{useEffect as g,useId as _,useRef as v,useState as y}from"react";function b({profiles:l,status:g,value:v,onChange:b,required:x=!1,disabled:S,id:C,className:w}){let[T,E]=y(!1),D=_(),O=new Map(l.map(e=>[p(e.name),e])),k=f(l).filter(e=>!x||O.has(e.value)).map(e=>{let t=O.get(e.value);return{...e,...t?{lead:/* @__PURE__ */ m(n,{name:e.title,seed:t.name,image:c(t.identity?.icon),size:`sm`})}:{},props:{"data-testid":`profile-option-${e.value}`}}});return/* @__PURE__ */ h(`div`,{"data-slot":`profile-picker`,"data-testid":`profile-picker`,className:t(`flex flex-col gap-1`,w),children:[/* @__PURE__ */ m(`span`,{id:D,className:`text-base font-medium text-po-text`,children:x?`Profile`:`Profile (optional)`}),/* @__PURE__ */ h(a,{open:T,onOpenChange:E,children:[/* @__PURE__ */ m(o,{asChild:!0,children:/* @__PURE__ */ h(i,{id:C,variant:`outline`,"data-testid":`profile-picker-trigger`,"aria-haspopup":`listbox`,"aria-expanded":T,"aria-labelledby":D,disabled:S||x&&l.length===0,className:`w-full justify-between px-2.5 text-po-text`,children:[/* @__PURE__ */ m(`span`,{className:`truncate`,children:x&&typeof v!=`string`?`Choose a profile`:u(v,l)}),g===`loading`?/* @__PURE__ */ m(r,{className:`size-3 shrink-0`}):/* @__PURE__ */ m(e,{className:`size-3.5 shrink-0 opacity-60`})]})}),/* @__PURE__ */ m(s,{side:`bottom`,align:`start`,"data-testid":`profile-picker-list`,title:`Profile`,meta:g===`loading`?`loading`:`${String(l.length)} available`,items:k,value:[p(v)],filterable:k.length>9,filterPlaceholder:`Filter profiles`,className:`w-[min(360px,calc(100vw-24px))]`,onSelect:e=>{b(d(e)),E(!1)}})]}),g===`loading`?/* @__PURE__ */ m(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading profiles…`}):g===`unavailable`?/* @__PURE__ */ h(`p`,{role:`status`,"data-testid":`profile-picker-note`,className:`text-sm text-po-dim`,children:[l.length===0?`Profiles could not be loaded.`:`Some profiles could not be loaded.`,` `,x?null:`You can still start a session without one.`]}):x&&l.length===0?/* @__PURE__ */ m(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`No profiles are available on this computer yet.`}):null]})}function x(e,t){let[n,r]=y(),i=v(t);g(()=>{i.current=t});let a=t!==void 0;if(g(()=>{if(!a)return;let t=new AbortController;return l(e=>i.current?.(e)??Promise.resolve(void 0),t.signal).then(t=>{t!==void 0&&r({key:e,state:t})}),()=>t.abort()},[e,a]),a)return n?.key===e?n.state:{status:`loading`,profiles:[]}}export{b as ProfilePicker,x as useProfileCatalog};
2
2
  //# sourceMappingURL=ProfilePicker.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProfilePicker.mjs","names":["ProfilePicker","open","setOpen","useState","labelId","useId","byValue","profiles","profileValueOf","profile","items","profilePickerItems","item","AgentAvatar","inlineProfileIcon","cn","className","Popover","PopoverTrigger","Button","profileChoiceLabel","value","status","Spinner","ChevronDownIcon","PickerContent","onChange","profileChoiceOf","next","useProfileCatalog","loaded","setLoaded","latest","useRef","load","useEffect","enabled","controller","loadProfileCatalog","signal","state","key"],"sources":["../../../../../../src/components/ProfilePicker.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from 'react';\n\nimport { ChevronDownIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\nimport {\n inlineProfileIcon,\n loadProfileCatalog,\n type ProfileChoice,\n profileChoiceLabel,\n profileChoiceOf,\n type ProfilePickerProfile,\n type ProfilePickerState,\n type ProfilePickerStatus,\n profilePickerItems,\n profileValueOf,\n} from '../lib/profilePicker';\nimport { AgentAvatar } from './AgentAvatar';\nimport { Button } from './Button';\nimport { PickerContent } from './Picker';\nimport { Popover, PopoverTrigger } from './Popover';\nimport { Spinner } from './Spinner';\n\nexport interface ProfilePickerProps {\n profiles: readonly ProfilePickerProfile[];\n status: ProfilePickerStatus;\n /** `undefined`: not chosen. `null`: explicit No profile. A string: that profile. */\n value: ProfileChoice;\n onChange: (choice: ProfileChoice) => void;\n disabled?: boolean;\n id?: string;\n className?: string;\n}\n\nconst UNAVAILABLE_NOTE = 'You can still start a session without one.';\n\n/**\n * Chooses the profile a new session starts with.\n *\n * It never chooses for the person: a launch with nothing picked leaves the\n * workspace default eligible, and No profile is its own explicit row. The\n * list can still be filling in while the person decides, and a source that\n * did not load is said plainly instead of leaving the list quietly short.\n */\nexport function ProfilePicker({ profiles, status, value, onChange, disabled, id, className }: ProfilePickerProps) {\n const [open, setOpen] = useState(false);\n const labelId = useId();\n const byValue = new Map(profiles.map((profile) => [profileValueOf(profile.name), profile]));\n const items = profilePickerItems(profiles).map((item) => {\n const profile = byValue.get(item.value);\n return {\n ...item,\n // A profile's own face: its inline avatar, otherwise initials. The default and No profile rows have none.\n ...(profile\n ? {\n lead: (\n <AgentAvatar\n name={item.title}\n seed={profile.name}\n image={inlineProfileIcon(profile.identity?.icon)}\n size=\"sm\"\n />\n ),\n }\n : {}),\n props: { 'data-testid': `profile-option-${item.value}` },\n };\n });\n return (\n <div data-slot=\"profile-picker\" data-testid=\"profile-picker\" className={cn('flex flex-col gap-1', className)}>\n <span id={labelId} className=\"text-base font-medium text-po-text\">\n Profile (optional)\n </span>\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n id={id}\n variant=\"outline\"\n data-testid=\"profile-picker-trigger\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-labelledby={labelId}\n disabled={disabled}\n className=\"w-full justify-between px-2.5 text-po-text\"\n >\n <span className=\"truncate\">{profileChoiceLabel(value, profiles)}</span>\n {status === 'loading' ? (\n <Spinner className=\"size-3 shrink-0\" />\n ) : (\n <ChevronDownIcon className=\"size-3.5 shrink-0 opacity-60\" />\n )}\n </Button>\n </PopoverTrigger>\n <PickerContent\n side=\"bottom\"\n align=\"start\"\n data-testid=\"profile-picker-list\"\n title=\"Profile\"\n meta={status === 'loading' ? 'loading' : `${String(profiles.length)} available`}\n items={items}\n value={[profileValueOf(value)]}\n filterable={items.length > 9}\n filterPlaceholder=\"Filter profiles\"\n className=\"w-[min(360px,calc(100vw-24px))]\"\n onSelect={(next) => {\n onChange(profileChoiceOf(next));\n setOpen(false);\n }}\n />\n </Popover>\n {status === 'loading' ? (\n <p role=\"status\" className=\"text-sm text-po-dim\">\n Loading profiles…\n </p>\n ) : status === 'unavailable' ? (\n <p role=\"status\" data-testid=\"profile-picker-note\" className=\"text-sm text-po-dim\">\n {profiles.length === 0 ? 'Profiles could not be loaded.' : 'Some profiles could not be loaded.'}{' '}\n {UNAVAILABLE_NOTE}\n </p>\n ) : null}\n </div>\n );\n}\n\n/**\n * Loads the profile list for one target, such as a workspace, and reloads when `key` changes.\n * Undefined while no loader exists, so a host that offers none shows no picker.\n * Never chooses a profile; an unreachable server is \"unavailable\" with nothing listed.\n */\nexport function useProfileCatalog(\n key: string,\n load: ((signal: AbortSignal) => Promise<unknown>) | undefined,\n): { status: ProfilePickerStatus; profiles: readonly ProfilePickerProfile[] } | undefined {\n const [loaded, setLoaded] = useState<{ key: string; state: ProfilePickerState } | undefined>();\n // The newest loader without restarting the request each time a host rebuilds it; declared first so it runs first.\n const latest = useRef(load);\n useEffect(() => {\n latest.current = load;\n });\n const enabled = load !== undefined;\n useEffect(() => {\n if (!enabled) return;\n const controller = new AbortController();\n const request = (signal: AbortSignal): Promise<unknown> => latest.current?.(signal) ?? Promise.resolve(undefined);\n void loadProfileCatalog(request, controller.signal).then((state) => {\n if (state !== undefined) setLoaded({ key, state });\n });\n return () => controller.abort();\n }, [key, enabled]);\n if (!enabled) return undefined;\n return loaded?.key === key ? loaded.state : { status: 'loading', profiles: [] };\n}\n"],"mappings":"smBA2CA,SAAgBA,EAAc,CAAE,WAAU,SAAQ,QAAO,WAAU,WAAU,KAAI,aAAiC,CAChH,GAAM,CAACC,EAAMC,GAAWC,EAAS,EAAK,EAChCC,EAAUC,EAAM,EAChBC,EAAU,IAAI,IAAIC,EAAS,IAAK,GAAY,CAACC,EAAeC,EAAQ,IAAI,EAAGA,CAAO,CAAC,CAAC,EACpFC,EAAQC,EAAmBJ,CAAQ,CAAC,CAAC,IAAK,GAAS,CACvD,IAAME,EAAUH,EAAQ,IAAIM,EAAK,KAAK,EACtC,MAAO,CACL,GAAGA,EAEH,GAAIH,EACA,CACE,KACE,kBAACI,EAAD,CACE,KAAMD,EAAK,MACX,KAAMH,EAAQ,KACd,MAAOK,EAAkBL,EAAQ,UAAU,IAAI,EAC/C,KAAK,IACN,CAAA,CAEL,EACA,CAAC,EACL,MAAO,CAAE,cAAe,kBAAkBG,EAAK,OAAQ,CACzD,CACF,CAAC,EACD,MACE,kBAAC,MAAD,CAAK,YAAU,iBAAiB,cAAY,iBAAiB,UAAWG,EAAG,sBAAuBC,CAAS,EAA3G,SAAA,CACE,kBAAC,OAAD,CAAM,GAAIZ,EAAS,UAAU,qCAAqC,SAAA,oBAE5D,CAAA,EACN,kBAACa,EAAD,CAAe,OAAM,aAAcf,EAAnC,SAAA,CACE,kBAACgB,EAAD,CAAgB,QAAA,GACd,SAAA,kBAACC,EAAD,CACM,KACJ,QAAQ,UACR,cAAY,yBACZ,gBAAc,UACd,gBAAelB,EACf,kBAAiBG,EACP,WACV,UAAU,6CARZ,SAAA,CAUE,kBAAC,OAAD,CAAM,UAAU,WAAY,SAAAgB,EAAmBC,EAAOd,CAAQ,CAAQ,CAAA,EACrEe,IAAW,UACV,k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UAAW,SAAU,CAAC,CAAE,CAChF"}
1
+ {"version":3,"file":"ProfilePicker.mjs","names":["ProfilePicker","open","setOpen","useState","labelId","useId","byValue","profiles","profileValueOf","profile","items","profilePickerItems","required","item","AgentAvatar","inlineProfileIcon","cn","className","Popover","PopoverTrigger","Button","disabled","value","profileChoiceLabel","status","Spinner","ChevronDownIcon","PickerContent","onChange","profileChoiceOf","next","useProfileCatalog","loaded","setLoaded","latest","useRef","load","useEffect","enabled","controller","loadProfileCatalog","signal","state","key"],"sources":["../../../../../../src/components/ProfilePicker.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from 'react';\n\nimport { ChevronDownIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\nimport {\n inlineProfileIcon,\n loadProfileCatalog,\n type ProfileChoice,\n profileChoiceLabel,\n profileChoiceOf,\n type ProfilePickerProfile,\n type ProfilePickerState,\n type ProfilePickerStatus,\n profilePickerItems,\n profileValueOf,\n} from '../lib/profilePicker';\nimport { AgentAvatar } from './AgentAvatar';\nimport { Button } from './Button';\nimport { PickerContent } from './Picker';\nimport { Popover, PopoverTrigger } from './Popover';\nimport { Spinner } from './Spinner';\n\nexport interface ProfilePickerProps {\n profiles: readonly ProfilePickerProfile[];\n status: ProfilePickerStatus;\n /** `undefined`: not chosen. `null`: explicit No profile. A string: that profile. */\n value: ProfileChoice;\n onChange: (choice: ProfileChoice) => void;\n /** Only named profiles, with no default or No profile option. */\n required?: boolean;\n disabled?: boolean;\n id?: string;\n className?: string;\n}\n\nconst UNAVAILABLE_NOTE = 'You can still start a session without one.';\n\n/**\n * Chooses the profile a new session starts with.\n *\n * It never chooses for the person: a launch with nothing picked leaves the\n * workspace default eligible, and No profile is its own explicit row. The\n * list can still be filling in while the person decides, and a source that\n * did not load is said plainly instead of leaving the list quietly short.\n */\nexport function ProfilePicker({\n profiles,\n status,\n value,\n onChange,\n required = false,\n disabled,\n id,\n className,\n}: ProfilePickerProps) {\n const [open, setOpen] = useState(false);\n const labelId = useId();\n const byValue = new Map(profiles.map((profile) => [profileValueOf(profile.name), profile]));\n const items = profilePickerItems(profiles)\n .filter((item) => !required || byValue.has(item.value))\n .map((item) => {\n const profile = byValue.get(item.value);\n return {\n ...item,\n // A profile's own face: its inline avatar, otherwise initials. The default and No profile rows have none.\n ...(profile\n ? {\n lead: (\n <AgentAvatar\n name={item.title}\n seed={profile.name}\n image={inlineProfileIcon(profile.identity?.icon)}\n size=\"sm\"\n />\n ),\n }\n : {}),\n props: { 'data-testid': `profile-option-${item.value}` },\n };\n });\n return (\n <div data-slot=\"profile-picker\" data-testid=\"profile-picker\" className={cn('flex flex-col gap-1', className)}>\n <span id={labelId} className=\"text-base font-medium text-po-text\">\n {required ? 'Profile' : 'Profile (optional)'}\n </span>\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n id={id}\n variant=\"outline\"\n data-testid=\"profile-picker-trigger\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-labelledby={labelId}\n disabled={disabled || (required && profiles.length === 0)}\n className=\"w-full justify-between px-2.5 text-po-text\"\n >\n <span className=\"truncate\">\n {required && typeof value !== 'string' ? 'Choose a profile' : profileChoiceLabel(value, profiles)}\n </span>\n {status === 'loading' ? (\n <Spinner className=\"size-3 shrink-0\" />\n ) : (\n <ChevronDownIcon className=\"size-3.5 shrink-0 opacity-60\" />\n )}\n </Button>\n </PopoverTrigger>\n <PickerContent\n side=\"bottom\"\n align=\"start\"\n data-testid=\"profile-picker-list\"\n title=\"Profile\"\n meta={status === 'loading' ? 'loading' : `${String(profiles.length)} available`}\n items={items}\n value={[profileValueOf(value)]}\n filterable={items.length > 9}\n filterPlaceholder=\"Filter profiles\"\n className=\"w-[min(360px,calc(100vw-24px))]\"\n onSelect={(next) => {\n onChange(profileChoiceOf(next));\n setOpen(false);\n }}\n />\n </Popover>\n {status === 'loading' ? (\n <p role=\"status\" className=\"text-sm text-po-dim\">\n Loading profiles…\n </p>\n ) : status === 'unavailable' ? (\n <p role=\"status\" data-testid=\"profile-picker-note\" className=\"text-sm text-po-dim\">\n {profiles.length === 0 ? 'Profiles could not be loaded.' : 'Some profiles could not be loaded.'}{' '}\n {required ? null : UNAVAILABLE_NOTE}\n </p>\n ) : required && profiles.length === 0 ? (\n <p role=\"status\" className=\"text-sm text-po-dim\">\n No profiles are available on this computer yet.\n </p>\n ) : null}\n </div>\n );\n}\n\n/**\n * Loads the profile list for one target, such as a workspace, and reloads when `key` changes.\n * Undefined while no loader exists, so a host that offers none shows no picker.\n * Never chooses a profile; an unreachable server is \"unavailable\" with nothing listed.\n */\nexport function useProfileCatalog(\n key: string,\n load: ((signal: AbortSignal) => Promise<unknown>) | undefined,\n): { status: ProfilePickerStatus; profiles: readonly ProfilePickerProfile[] } | undefined {\n const [loaded, setLoaded] = useState<{ key: string; state: ProfilePickerState } | undefined>();\n // The newest loader without restarting the request each time a host rebuilds it; declared first so it runs first.\n const latest = useRef(load);\n useEffect(() => {\n latest.current = load;\n });\n const enabled = load !== undefined;\n useEffect(() => {\n if (!enabled) return;\n const controller = new AbortController();\n const request = (signal: AbortSignal): Promise<unknown> => latest.current?.(signal) ?? Promise.resolve(undefined);\n void loadProfileCatalog(request, controller.signal).then((state) => {\n if (state !== undefined) setLoaded({ key, state });\n });\n return () => controller.abort();\n }, [key, enabled]);\n if (!enabled) return undefined;\n return loaded?.key === key ? loaded.state : { status: 'loading', profiles: [] };\n}\n"],"mappings":"smBA6CA,SAAgBA,EAAc,CAC5B,WACA,SACA,QACA,WACA,WAAW,GACX,WACA,KACA,aACqB,CACrB,GAAM,CAACC,EAAMC,GAAWC,EAAS,EAAK,EAChCC,EAAUC,EAAM,EAChBC,EAAU,IAAI,IAAIC,EAAS,IAAK,GAAY,CAACC,EAAeC,EAAQ,IAAI,EAAGA,CAAO,CAAC,CAAC,EACpFC,EAAQC,EAAmBJ,CAAQ,CAAC,CACvC,OAAQ,GAAS,CAACK,GAAYN,EAAQ,IAAIO,EAAK,KAAK,CAAC,CA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BkB,EAASC,EAAgBC,CAAI,CAAC,EAC9B5B,EAAQ,EAAK,CACf,CACD,CAAA,CACM,IACRsB,IAAW,UACV,kBAAC,IAAD,CAAG,KAAK,SAAS,UAAU,sBAAsB,SAAA,mBAE9C,CAAA,EACDA,IAAW,cACb,kBAAC,IAAD,CAAG,KAAK,SAAS,cAAY,sBAAsB,UAAU,sBAA7D,SAAA,CACGjB,EAAS,SAAW,EAAI,gCAAkC,qCAAsC,IAChGK,EAAW,KAAO,4CAClB,CACD,CAAA,EAAAA,GAAYL,EAAS,SAAW,EAClC,kBAAC,IAAD,CAAG,KAAK,SAAS,UAAU,sBAAsB,SAAA,iDAE9C,CAAA,EACD,IACD,GAET,CAOA,SAAgBwB,EACd,EACA,EACwF,CACxF,GAAM,CAACC,EAAQC,GAAa9B,EAAiE,EAEvF+B,EAASC,EAAOC,CAAI,EAC1BC,MAAgB,CACd,EAAO,QAAUD,CACnB,CAAC,EACD,IAAME,EAAUF,IAAS,IAAA,GAUzB,GATAC,MAAgB,CACd,GAAI,CAACC,EAAS,OACd,IAAMC,EAAa,IAAI,gBAKvB,OAHAC,EADiB,GAA0CN,EAAO,UAAUO,CAAM,GAAK,QAAQ,QAAQ,IAAA,EAAS,EAC/EF,EAAW,MAAM,CAAC,CAAC,KAAM,GAAU,CAC9DG,IAAU,IAAA,IAAWT,EAAU,CAAE,MAAK,OAAM,CAAC,CACnD,CAAC,MACYM,EAAW,MAAM,CAChC,EAAG,CAACI,EAAKL,CAAO,CAAC,EACZA,EACL,OAAON,GAAQ,MAAQW,EAAMX,EAAO,MAAQ,CAAE,OAAQ,UAAW,SAAU,CAAC,CAAE,CAChF"}
@@ -1,2 +1,2 @@
1
- require("../icons/icons.cjs");const e=require("../lib/cn.cjs"),t=require("./AgentAvatar.cjs"),n=require("./Spinner.cjs"),r=require("./Button.cjs"),i=require("./Popover.cjs"),a=require("./Picker.cjs"),o=require("../lib/profilePicker.cjs");let s=require("react/jsx-runtime"),c=require("react"),l=require("lucide-react");function u({profiles:u,status:d,value:f,onChange:p,disabled:m,id:h,className:g}){let[_,v]=(0,c.useState)(!1),y=(0,c.useId)(),b=new Map(u.map(e=>[o.profileValueOf(e.name),e])),x=o.profilePickerItems(u).map(e=>{let n=b.get(e.value);return{...e,...n?{lead:/* @__PURE__ */ (0,s.jsx)(t.AgentAvatar,{name:e.title,seed:n.name,image:o.inlineProfileIcon(n.identity?.icon),size:`sm`})}:{},props:{"data-testid":`profile-option-${e.value}`}}});return/* @__PURE__ */ (0,s.jsxs)(`div`,{"data-slot":`profile-picker`,"data-testid":`profile-picker`,className:e.cn(`flex flex-col gap-1`,g),children:[/* @__PURE__ */ (0,s.jsx)(`span`,{id:y,className:`text-base font-medium text-po-text`,children:`Profile (optional)`}),/* @__PURE__ */ (0,s.jsxs)(i.Popover,{open:_,onOpenChange:v,children:[/* @__PURE__ */ (0,s.jsx)(i.PopoverTrigger,{asChild:!0,children:/* @__PURE__ */ (0,s.jsxs)(r.Button,{id:h,variant:`outline`,"data-testid":`profile-picker-trigger`,"aria-haspopup":`listbox`,"aria-expanded":_,"aria-labelledby":y,disabled:m,className:`w-full justify-between px-2.5 text-po-text`,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:`truncate`,children:o.profileChoiceLabel(f,u)}),d===`loading`?/* @__PURE__ */ (0,s.jsx)(n.Spinner,{className:`size-3 shrink-0`}):/* @__PURE__ */ (0,s.jsx)(l.ChevronDown,{className:`size-3.5 shrink-0 opacity-60`})]})}),/* @__PURE__ */ (0,s.jsx)(a.PickerContent,{side:`bottom`,align:`start`,"data-testid":`profile-picker-list`,title:`Profile`,meta:d===`loading`?`loading`:`${String(u.length)} available`,items:x,value:[o.profileValueOf(f)],filterable:x.length>9,filterPlaceholder:`Filter profiles`,className:`w-[min(360px,calc(100vw-24px))]`,onSelect:e=>{p(o.profileChoiceOf(e)),v(!1)}})]}),d===`loading`?/* @__PURE__ */ (0,s.jsx)(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading profiles…`}):d===`unavailable`?/* @__PURE__ */ (0,s.jsxs)(`p`,{role:`status`,"data-testid":`profile-picker-note`,className:`text-sm text-po-dim`,children:[u.length===0?`Profiles could not be loaded.`:`Some profiles could not be loaded.`,` `,`You can still start a session without one.`]}):null]})}function d(e,t){let[n,r]=(0,c.useState)(),i=(0,c.useRef)(t);(0,c.useEffect)(()=>{i.current=t});let a=t!==void 0;if((0,c.useEffect)(()=>{if(!a)return;let t=new AbortController;return o.loadProfileCatalog(e=>i.current?.(e)??Promise.resolve(void 0),t.signal).then(t=>{t!==void 0&&r({key:e,state:t})}),()=>t.abort()},[e,a]),a)return n?.key===e?n.state:{status:`loading`,profiles:[]}}exports.ProfilePicker=u,exports.useProfileCatalog=d;
1
+ require("../icons/icons.cjs");const e=require("../lib/cn.cjs"),t=require("./AgentAvatar.cjs"),n=require("./Spinner.cjs"),r=require("./Button.cjs"),i=require("./Popover.cjs"),a=require("./Picker.cjs"),o=require("../lib/profilePicker.cjs");let s=require("react/jsx-runtime"),c=require("react"),l=require("lucide-react");function u({profiles:u,status:d,value:f,onChange:p,required:m=!1,disabled:h,id:g,className:_}){let[v,y]=(0,c.useState)(!1),b=(0,c.useId)(),x=new Map(u.map(e=>[o.profileValueOf(e.name),e])),S=o.profilePickerItems(u).filter(e=>!m||x.has(e.value)).map(e=>{let n=x.get(e.value);return{...e,...n?{lead:/* @__PURE__ */ (0,s.jsx)(t.AgentAvatar,{name:e.title,seed:n.name,image:o.inlineProfileIcon(n.identity?.icon),size:`sm`})}:{},props:{"data-testid":`profile-option-${e.value}`}}});return/* @__PURE__ */ (0,s.jsxs)(`div`,{"data-slot":`profile-picker`,"data-testid":`profile-picker`,className:e.cn(`flex flex-col gap-1`,_),children:[/* @__PURE__ */ (0,s.jsx)(`span`,{id:b,className:`text-base font-medium text-po-text`,children:m?`Profile`:`Profile (optional)`}),/* @__PURE__ */ (0,s.jsxs)(i.Popover,{open:v,onOpenChange:y,children:[/* @__PURE__ */ (0,s.jsx)(i.PopoverTrigger,{asChild:!0,children:/* @__PURE__ */ (0,s.jsxs)(r.Button,{id:g,variant:`outline`,"data-testid":`profile-picker-trigger`,"aria-haspopup":`listbox`,"aria-expanded":v,"aria-labelledby":b,disabled:h||m&&u.length===0,className:`w-full justify-between px-2.5 text-po-text`,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:`truncate`,children:m&&typeof f!=`string`?`Choose a profile`:o.profileChoiceLabel(f,u)}),d===`loading`?/* @__PURE__ */ (0,s.jsx)(n.Spinner,{className:`size-3 shrink-0`}):/* @__PURE__ */ (0,s.jsx)(l.ChevronDown,{className:`size-3.5 shrink-0 opacity-60`})]})}),/* @__PURE__ */ (0,s.jsx)(a.PickerContent,{side:`bottom`,align:`start`,"data-testid":`profile-picker-list`,title:`Profile`,meta:d===`loading`?`loading`:`${String(u.length)} available`,items:S,value:[o.profileValueOf(f)],filterable:S.length>9,filterPlaceholder:`Filter profiles`,className:`w-[min(360px,calc(100vw-24px))]`,onSelect:e=>{p(o.profileChoiceOf(e)),y(!1)}})]}),d===`loading`?/* @__PURE__ */ (0,s.jsx)(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading profiles…`}):d===`unavailable`?/* @__PURE__ */ (0,s.jsxs)(`p`,{role:`status`,"data-testid":`profile-picker-note`,className:`text-sm text-po-dim`,children:[u.length===0?`Profiles could not be loaded.`:`Some profiles could not be loaded.`,` `,m?null:`You can still start a session without one.`]}):m&&u.length===0?/* @__PURE__ */ (0,s.jsx)(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`No profiles are available on this computer yet.`}):null]})}function d(e,t){let[n,r]=(0,c.useState)(),i=(0,c.useRef)(t);(0,c.useEffect)(()=>{i.current=t});let a=t!==void 0;if((0,c.useEffect)(()=>{if(!a)return;let t=new AbortController;return o.loadProfileCatalog(e=>i.current?.(e)??Promise.resolve(void 0),t.signal).then(t=>{t!==void 0&&r({key:e,state:t})}),()=>t.abort()},[e,a]),a)return n?.key===e?n.state:{status:`loading`,profiles:[]}}exports.ProfilePicker=u,exports.useProfileCatalog=d;
2
2
  //# sourceMappingURL=ProfilePicker.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProfilePicker.cjs","names":["useState","useId","profileValueOf","profilePickerItems","AgentAvatar","inlineProfileIcon","cn","Popover","PopoverTrigger","Button","profileChoiceLabel","Spinner","ChevronDownIcon","PickerContent","profileChoiceOf","useRef","loadProfileCatalog","require_cn","require_AgentAvatar","require_Spinner","require_Button","require_Popover","require_Picker","require_profilePicker","react_jsx_runtime","react","lucide_react","ProfilePicker","open","setOpen","labelId","byValue","profiles","profile","items","item","className","value","status","onChange","next","useProfileCatalog","loaded","setLoaded","latest","load","enabled","controller","signal","state","key"],"sources":["../../../src/components/ProfilePicker.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from 'react';\n\nimport { ChevronDownIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\nimport {\n inlineProfileIcon,\n loadProfileCatalog,\n type ProfileChoice,\n profileChoiceLabel,\n profileChoiceOf,\n type ProfilePickerProfile,\n type ProfilePickerState,\n type ProfilePickerStatus,\n profilePickerItems,\n profileValueOf,\n} from '../lib/profilePicker';\nimport { AgentAvatar } from './AgentAvatar';\nimport { Button } from './Button';\nimport { PickerContent } from './Picker';\nimport { Popover, PopoverTrigger } from './Popover';\nimport { Spinner } from './Spinner';\n\nexport interface ProfilePickerProps {\n profiles: readonly ProfilePickerProfile[];\n status: ProfilePickerStatus;\n /** `undefined`: not chosen. `null`: explicit No profile. A string: that profile. */\n value: ProfileChoice;\n onChange: (choice: ProfileChoice) => void;\n disabled?: boolean;\n id?: string;\n className?: string;\n}\n\nconst UNAVAILABLE_NOTE = 'You can still start a session without one.';\n\n/**\n * Chooses the profile a new session starts with.\n *\n * It never chooses for the person: a launch with nothing picked leaves the\n * workspace default eligible, and No profile is its own explicit row. The\n * list can still be filling in while the person decides, and a source that\n * did not load is said plainly instead of leaving the list quietly short.\n */\nexport function ProfilePicker({ profiles, status, value, onChange, disabled, id, className }: ProfilePickerProps) {\n const [open, setOpen] = useState(false);\n const labelId = useId();\n const byValue = new Map(profiles.map((profile) => [profileValueOf(profile.name), profile]));\n const items = profilePickerItems(profiles).map((item) => {\n const profile = byValue.get(item.value);\n return {\n ...item,\n // A profile's own face: its inline avatar, otherwise initials. The default and No profile rows have none.\n ...(profile\n ? {\n lead: (\n <AgentAvatar\n name={item.title}\n seed={profile.name}\n image={inlineProfileIcon(profile.identity?.icon)}\n size=\"sm\"\n />\n ),\n }\n : {}),\n props: { 'data-testid': `profile-option-${item.value}` },\n };\n });\n return (\n <div data-slot=\"profile-picker\" data-testid=\"profile-picker\" className={cn('flex flex-col gap-1', className)}>\n <span id={labelId} className=\"text-base font-medium text-po-text\">\n Profile (optional)\n </span>\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n id={id}\n variant=\"outline\"\n data-testid=\"profile-picker-trigger\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-labelledby={labelId}\n disabled={disabled}\n className=\"w-full justify-between px-2.5 text-po-text\"\n >\n <span className=\"truncate\">{profileChoiceLabel(value, profiles)}</span>\n {status === 'loading' ? (\n <Spinner className=\"size-3 shrink-0\" />\n ) : (\n <ChevronDownIcon className=\"size-3.5 shrink-0 opacity-60\" />\n )}\n </Button>\n </PopoverTrigger>\n <PickerContent\n side=\"bottom\"\n align=\"start\"\n data-testid=\"profile-picker-list\"\n title=\"Profile\"\n meta={status === 'loading' ? 'loading' : `${String(profiles.length)} available`}\n items={items}\n value={[profileValueOf(value)]}\n filterable={items.length > 9}\n filterPlaceholder=\"Filter profiles\"\n className=\"w-[min(360px,calc(100vw-24px))]\"\n onSelect={(next) => {\n onChange(profileChoiceOf(next));\n setOpen(false);\n }}\n />\n </Popover>\n {status === 'loading' ? (\n <p role=\"status\" className=\"text-sm text-po-dim\">\n Loading profiles…\n </p>\n ) : status === 'unavailable' ? (\n <p role=\"status\" data-testid=\"profile-picker-note\" className=\"text-sm text-po-dim\">\n {profiles.length === 0 ? 'Profiles could not be loaded.' : 'Some profiles could not be loaded.'}{' '}\n {UNAVAILABLE_NOTE}\n </p>\n ) : null}\n </div>\n );\n}\n\n/**\n * Loads the profile list for one target, such as a workspace, and reloads when `key` changes.\n * Undefined while no loader exists, so a host that offers none shows no picker.\n * Never chooses a profile; an unreachable server is \"unavailable\" with nothing listed.\n */\nexport function useProfileCatalog(\n key: string,\n load: ((signal: AbortSignal) => Promise<unknown>) | undefined,\n): { status: ProfilePickerStatus; profiles: readonly ProfilePickerProfile[] } | undefined {\n const [loaded, setLoaded] = useState<{ key: string; state: ProfilePickerState } | undefined>();\n // The newest loader without restarting the request each time a host rebuilds it; declared first so it runs first.\n const latest = useRef(load);\n useEffect(() => {\n latest.current = load;\n });\n const enabled = load !== undefined;\n useEffect(() => {\n if (!enabled) return;\n const controller = new AbortController();\n const request = (signal: AbortSignal): Promise<unknown> => latest.current?.(signal) ?? Promise.resolve(undefined);\n void loadProfileCatalog(request, controller.signal).then((state) => {\n if (state !== undefined) setLoaded({ key, state });\n });\n return () => controller.abort();\n }, [key, enabled]);\n if (!enabled) return undefined;\n return loaded?.key === key ? loaded.state : { status: 'loading', profiles: [] };\n}\n"],"mappings":"8TA2CA,SAAgB2B,EAAc,CAAE,WAAU,SAAQ,QAAO,WAAU,WAAU,KAAI,aAAiC,CAChH,GAAM,CAACC,EAAMC,IAAA,EAAW7B,EAAAA,SAAAA,CAAS,EAAK,EAChC8B,GAAA,EAAU7B,EAAAA,MAAAA,CAAM,EAChB8B,EAAU,IAAI,IAAIC,EAAS,IAAK,GAAY,CAAC9B,EAAAA,eAAe+B,EAAQ,IAAI,EAAGA,CAAO,CAAC,CAAC,EACpFC,EAAQ/B,EAAAA,mBAAmB6B,CAAQ,CAAC,CAAC,IAAK,GAAS,CACvD,IAAMC,EAAUF,EAAQ,IAAII,EAAK,KAAK,EACtC,MAAO,CACL,GAAGA,EAEH,GAAIF,EACA,CACE,KACE,iBAA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ePicker.cjs","names":["useState","useId","profileValueOf","profilePickerItems","AgentAvatar","inlineProfileIcon","cn","Popover","PopoverTrigger","Button","profileChoiceLabel","Spinner","ChevronDownIcon","PickerContent","profileChoiceOf","useRef","loadProfileCatalog","require_cn","require_AgentAvatar","require_Spinner","require_Button","require_Popover","require_Picker","require_profilePicker","react_jsx_runtime","react","lucide_react","ProfilePicker","open","setOpen","labelId","byValue","profiles","profile","items","required","item","className","disabled","value","status","onChange","next","useProfileCatalog","loaded","setLoaded","latest","load","enabled","controller","signal","state","key"],"sources":["../../../src/components/ProfilePicker.tsx"],"sourcesContent":["import { useEffect, useId, useRef, useState } from 'react';\n\nimport { ChevronDownIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\nimport {\n inlineProfileIcon,\n loadProfileCatalog,\n type ProfileChoice,\n profileChoiceLabel,\n profileChoiceOf,\n type ProfilePickerProfile,\n type ProfilePickerState,\n type ProfilePickerStatus,\n profilePickerItems,\n profileValueOf,\n} from '../lib/profilePicker';\nimport { AgentAvatar } from './AgentAvatar';\nimport { Button } from './Button';\nimport { PickerContent } from './Picker';\nimport { Popover, PopoverTrigger } from './Popover';\nimport { Spinner } from './Spinner';\n\nexport interface ProfilePickerProps {\n profiles: readonly ProfilePickerProfile[];\n status: ProfilePickerStatus;\n /** `undefined`: not chosen. `null`: explicit No profile. A string: that profile. */\n value: ProfileChoice;\n onChange: (choice: ProfileChoice) => void;\n /** Only named profiles, with no default or No profile option. */\n required?: boolean;\n disabled?: boolean;\n id?: string;\n className?: string;\n}\n\nconst UNAVAILABLE_NOTE = 'You can still start a session without one.';\n\n/**\n * Chooses the profile a new session starts with.\n *\n * It never chooses for the person: a launch with nothing picked leaves the\n * workspace default eligible, and No profile is its own explicit row. The\n * list can still be filling in while the person decides, and a source that\n * did not load is said plainly instead of leaving the list quietly short.\n */\nexport function ProfilePicker({\n profiles,\n status,\n value,\n onChange,\n required = false,\n disabled,\n id,\n className,\n}: ProfilePickerProps) {\n const [open, setOpen] = useState(false);\n const labelId = useId();\n const byValue = new Map(profiles.map((profile) => [profileValueOf(profile.name), profile]));\n const items = profilePickerItems(profiles)\n .filter((item) => !required || byValue.has(item.value))\n .map((item) => {\n const profile = byValue.get(item.value);\n return {\n ...item,\n // A profile's own face: its inline avatar, otherwise initials. The default and No profile rows have none.\n ...(profile\n ? {\n lead: (\n <AgentAvatar\n name={item.title}\n seed={profile.name}\n image={inlineProfileIcon(profile.identity?.icon)}\n size=\"sm\"\n />\n ),\n }\n : {}),\n props: { 'data-testid': `profile-option-${item.value}` },\n };\n });\n return (\n <div data-slot=\"profile-picker\" data-testid=\"profile-picker\" className={cn('flex flex-col gap-1', className)}>\n <span id={labelId} className=\"text-base font-medium text-po-text\">\n {required ? 'Profile' : 'Profile (optional)'}\n </span>\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n id={id}\n variant=\"outline\"\n data-testid=\"profile-picker-trigger\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-labelledby={labelId}\n disabled={disabled || (required && profiles.length === 0)}\n className=\"w-full justify-between px-2.5 text-po-text\"\n >\n <span className=\"truncate\">\n {required && typeof value !== 'string' ? 'Choose a profile' : profileChoiceLabel(value, profiles)}\n </span>\n {status === 'loading' ? (\n <Spinner className=\"size-3 shrink-0\" />\n ) : (\n <ChevronDownIcon className=\"size-3.5 shrink-0 opacity-60\" />\n )}\n </Button>\n </PopoverTrigger>\n <PickerContent\n side=\"bottom\"\n align=\"start\"\n data-testid=\"profile-picker-list\"\n title=\"Profile\"\n meta={status === 'loading' ? 'loading' : `${String(profiles.length)} available`}\n items={items}\n value={[profileValueOf(value)]}\n filterable={items.length > 9}\n filterPlaceholder=\"Filter profiles\"\n className=\"w-[min(360px,calc(100vw-24px))]\"\n onSelect={(next) => {\n onChange(profileChoiceOf(next));\n setOpen(false);\n }}\n />\n </Popover>\n {status === 'loading' ? (\n <p role=\"status\" className=\"text-sm text-po-dim\">\n Loading profiles…\n </p>\n ) : status === 'unavailable' ? (\n <p role=\"status\" data-testid=\"profile-picker-note\" className=\"text-sm text-po-dim\">\n {profiles.length === 0 ? 'Profiles could not be loaded.' : 'Some profiles could not be loaded.'}{' '}\n {required ? null : UNAVAILABLE_NOTE}\n </p>\n ) : required && profiles.length === 0 ? (\n <p role=\"status\" className=\"text-sm text-po-dim\">\n No profiles are available on this computer yet.\n </p>\n ) : null}\n </div>\n );\n}\n\n/**\n * Loads the profile list for one target, such as a workspace, and reloads when `key` changes.\n * Undefined while no loader exists, so a host that offers none shows no picker.\n * Never chooses a profile; an unreachable server is \"unavailable\" with nothing listed.\n */\nexport function useProfileCatalog(\n key: string,\n load: ((signal: AbortSignal) => Promise<unknown>) | undefined,\n): { status: ProfilePickerStatus; profiles: readonly ProfilePickerProfile[] } | undefined {\n const [loaded, setLoaded] = useState<{ key: string; state: ProfilePickerState } | undefined>();\n // The newest loader without restarting the request each time a host rebuilds it; declared first so it runs first.\n const latest = useRef(load);\n useEffect(() => {\n latest.current = load;\n });\n const enabled = load !== undefined;\n useEffect(() => {\n if (!enabled) return;\n const controller = new AbortController();\n const request = (signal: AbortSignal): Promise<unknown> => latest.current?.(signal) ?? Promise.resolve(undefined);\n void loadProfileCatalog(request, controller.signal).then((state) => {\n if (state !== undefined) setLoaded({ key, state });\n });\n return () => controller.abort();\n }, [key, enabled]);\n if (!enabled) return undefined;\n return loaded?.key === key ? loaded.state : { status: 'loading', profiles: [] };\n}\n"],"mappings":"8TA6CA,SAAgB2B,EAAc,CAC5B,WACA,SACA,QACA,WACA,WAAW,GACX,WACA,KACA,aACqB,CACrB,GAAM,CAACC,EAAMC,IAAA,EAAW7B,EAAAA,SAAAA,CAAS,EAAK,EAChC8B,GAAA,EAAU7B,EAAAA,MAAAA,CAAM,EAChB8B,EAAU,IAAI,IAAIC,EAAS,IAAK,GAAY,CAAC9B,EAAAA,eAAe+B,EAAQ,IAAI,EAAGA,CAAO,CAAC,CAAC,EACpFC,EAAQ/B,EAAAA,mBAAmB6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,KAAgB,CACd,GAAI,CAACuB,EAAS,OACd,IAAMC,EAAa,IAAI,gBAKvB,OAHA1B,EAAKP,mBADY,GAA0C8B,EAAO,UAAUI,CAAM,GAAK,QAAQ,QAAQ,IAAA,EAAS,EAC/ED,EAAW,MAAM,CAAC,CAAC,KAAM,GAAU,CAC9DE,IAAU,IAAA,IAAWN,EAAU,CAAE,MAAK,OAAM,CAAC,CACnD,CAAC,MACYI,EAAW,MAAM,CAChC,EAAG,CAACG,EAAKJ,CAAO,CAAC,EACZA,EACL,OAAOJ,GAAQ,MAAQQ,EAAMR,EAAO,MAAQ,CAAE,OAAQ,UAAW,SAAU,CAAC,CAAE,CAChF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-web-components",
3
- "version": "0.0.0-alpha.125",
3
+ "version": "0.0.0-alpha.127",
4
4
  "description": "Shared web components and theme tokens for the Po cockpit and its web plugins: shadcn-style primitives on Radix, tuned to the Po palette, with runtime theme configs.",
5
5
  "keywords": [
6
6
  "ai",
@@ -117,8 +117,8 @@
117
117
  "tailwind-merge": "3.7.0"
118
118
  },
119
119
  "devDependencies": {
120
- "@agimon-ai/po-core": "0.0.0-alpha.125",
121
- "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.125",
120
+ "@agimon-ai/po-core": "0.0.0-alpha.127",
121
+ "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.127",
122
122
  "@types/node": "26.6.5",
123
123
  "@types/react": "19.3.0",
124
124
  "@types/react-dom": "19.3.0",