Skip to content

Commit f0f371f

Browse files
committed
/routine passes a visible, replaceable target preselection (CL-7356)
CL-7355 already removed every invited-agent guard around routine creation (CL-7357): DefinitionTargetPicker never auto-selects, and the panel opens identically whether invoked from the routines page, the palette, or a chat with no agents — there was nothing left to delete. This wires DefinitionTargetPicker's existing preselectedAssetId prop end to end: ChatWorkspace resolves the active workbench's agent participants (already fetched for the failed-turn model picker) and, only when there is exactly one, hands its definitionAssetId through onCreateRoutineInSpace to RoutinePanelSubject.preselectedAssetId. The picker shows it chosen but never disables changing or clearing it, and only the person's final explicit selection is ever sent to POST /routines — unchanged from CL-7355.
1 parent 5ff394c commit f0f371f

4 files changed

Lines changed: 38 additions & 5 deletions

File tree

‎apps/web/src/pages/chat-page.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,12 @@ export function ChatPage({
306306
// are global-only pages now, reached from the shell rail — no
307307
// per-workbench header button or `/run` command opens a scoped view
308308
// of either here.
309-
onCreateRoutineInSpace={(inSpaceWorkbenchId) =>
310-
openRoutine({ routineId: null, workbenchId: inSpaceWorkbenchId })
309+
onCreateRoutineInSpace={(inSpaceWorkbenchId, preselectedAssetId) =>
310+
openRoutine({
311+
routineId: null,
312+
workbenchId: inSpaceWorkbenchId,
313+
...(preselectedAssetId !== undefined ? { preselectedAssetId } : {}),
314+
})
311315
}
312316
onWorkbenchNotFound={reportWorkbenchNotFound}
313317
onGoToMissionControl={() => navigate(MISSION_CONTROL_PATH)}

‎apps/web/src/shell/canvas-availability.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ export type RoutinePanelSubject = {
6464
* in which case the panel falls back to this workbench's own default
6565
* (Myra) workbench — never mints a new one. */
6666
readonly workbenchId?: string;
67+
/** Seeds the target picker's initial selection (CL-7356) — the
68+
* conversation's own single agent participant's definition asset id,
69+
* when the opener could resolve exactly one. Shown visibly in
70+
* `DefinitionTargetPicker` and freely replaceable/clearable by the
71+
* person; only their final explicit pick is ever sent to the backend.
72+
* Omitted whenever the opener found zero or several candidates, or has
73+
* no conversation to derive one from at all. */
74+
readonly preselectedAssetId?: string;
6775
};
6876

6977
/** Workbench's concrete instantiation of `@corbits/shell-layout`'s generic

‎apps/web/src/shell/routine-panel.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,9 @@ function RoutineEditorPanel({
663663
tenantId={tenantId}
664664
value={targetAssetId}
665665
onChange={pickTarget}
666+
{...(subject.preselectedAssetId !== undefined
667+
? { preselectedAssetId: subject.preselectedAssetId }
668+
: {})}
666669
/>
667670
) : (
668671
<div className="flex flex-col gap-1.5">

‎packages/chat-ui/src/chat-workspace.tsx‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,10 @@ function ChatWorkspaceInner({
694694
* CL-6099) are global-only pages now — reached from the shell rail, not
695695
* a per-workbench header button or composer command.
696696
*/
697-
readonly onCreateRoutineInSpace?: (workbenchId: string) => void;
697+
readonly onCreateRoutineInSpace?: (
698+
workbenchId: string,
699+
preselectedAssetId?: string,
700+
) => void;
698701
/** Fired when the routed workbench 404s — a deleted workbench, or a stale
699702
* Recents entry that outlived it. The host owns Recents (this package
700703
* never touches localStorage), so it's told rather than reaching out. */
@@ -1150,6 +1153,15 @@ function ChatWorkspaceInner({
11501153
: Promise.resolve([]),
11511154
enabled: activeWorkbenchId !== null,
11521155
});
1156+
// `/routine`'s and "New routine in this space"'s optional preselection
1157+
// (CL-7356): exactly one agent participant hands its definition asset id
1158+
// straight to the routine panel's picker, visibly and replaceably — zero
1159+
// or several participants leave the picker with nothing chosen, same as
1160+
// opening it from `/routines` (CL-7357).
1161+
const singleWorkbenchAgentDefinitionAssetId: string | undefined =
1162+
workbenchAgentsQuery.data?.length === 1
1163+
? workbenchAgentsQuery.data[0]?.definitionAssetId
1164+
: undefined;
11531165
const failedTurnRecovery = useMemo((): FailedTurnRecovery => {
11541166
const definitionIdByAddress: Record<string, string> = {};
11551167
for (const agent of workbenchAgentsQuery.data ?? []) {
@@ -1720,7 +1732,10 @@ function ChatWorkspaceInner({
17201732
onCreateRoutineInSpace !== undefined &&
17211733
activeWorkbenchId !== null
17221734
) {
1723-
onCreateRoutineInSpace(activeWorkbenchId);
1735+
onCreateRoutineInSpace(
1736+
activeWorkbenchId,
1737+
singleWorkbenchAgentDefinitionAssetId,
1738+
);
17241739
return;
17251740
}
17261741
toast(CHAT_STRINGS.runRoutineUnavailable);
@@ -1855,7 +1870,10 @@ export function ChatWorkspace({
18551870
tenantId: string,
18561871
) => Promise<readonly BringInMember[]>;
18571872
/** "New routine in this space" — see `ChatWorkspaceInner`'s prop note. */
1858-
readonly onCreateRoutineInSpace?: (workbenchId: string) => void;
1873+
readonly onCreateRoutineInSpace?: (
1874+
workbenchId: string,
1875+
preselectedAssetId?: string,
1876+
) => void;
18591877
/** See `ChatWorkspaceInner`'s prop of the same name. */
18601878
readonly onWorkbenchNotFound?: (workbenchId: string) => void;
18611879
/** See `ChatWorkspaceInner`'s prop of the same name. */

0 commit comments

Comments
 (0)