Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ jobs:
app/tests/home-screen-connect-browser.test.tsx
app/tests/long-names-layout.test.tsx
app/tests/long-turn-reopen.test.tsx
app/tests/make-artifact-browser.test.tsx
app/tests/member-rows-long-names.test.tsx
app/tests/model-picker-touch.test.tsx
app/tests/move-to-cloud-settings.test.tsx
Expand Down
86 changes: 85 additions & 1 deletion app/src/components/channels/chat-transcript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,18 @@ import {
import { splitChatOrigin } from "./chat-origin";
import type { QueuedMessage } from "./composer";
import { transcriptColumn } from "./conversation-columns";
import { makeArtifactAsks } from "./drawn-answers";
import { FileTypeIcon } from "./file-icon";
import { FollowScroll, RESUME_PX, useFollowIntent } from "./follow-intent";
import { LateRenderersContext, LateRenderersWatch } from "./late-renderers";
import { usePacedReveal } from "./paced-reveal";
import { latestPlanPerTurn } from "./plan-turns";
import { ResearchResults } from "./research-results";
import { TeamBotConsentCard } from "./team-bot-consent";
import { ReplyToolbar } from "./telemetry-assistant-message";
import {
MakeArtifactToolbar,
ReplyToolbar,
} from "./telemetry-assistant-message";
import {
ActivityAppMarks,
attachmentReadName,
Expand Down Expand Up @@ -286,6 +290,12 @@ type ChatTranscriptProps = {
* a turn that ended for a reason carrying on would not fix (a refusal, a Bot no longer shared).
*/
onCarryOn?: () => void;
/**
* Send the Bot the person's ask to keep one drawn answer as an artifact, drawn as "Make this an
* artifact" under each answer the Bot drew (`drawn-answers.ts`). Absent where nothing can be
* sent: no button is drawn.
*/
onMakeArtifact?: (ask: string) => void;
/**
* The person dismissed `stopped` for this turn: it is not drawn, though the turn is still the one
* that stopped (its work stays unfolded, as it was under the notice).
Expand All @@ -310,6 +320,7 @@ type ChatTranscriptProps = {
/** One shared empty array, so a screen without a queue does not hand down a new one per render. */
const EMPTY_QUEUE: readonly QueuedMessage[] = [];
const NO_REFUSALS: ReadonlyMap<string, string> = new Map();
const NO_ARTIFACT_ASKS: ReadonlyMap<string, string> = new Map();

/*
* HELD, NOT INERT, AND PER ROW. A read-only row has to stop every press in it, including ones no
Expand Down Expand Up @@ -1445,6 +1456,45 @@ const TranscriptMessage = memo(function TranscriptMessage({
);
});

/**
* "Make this an artifact" under an answer the Bot drew, sending the person's ask for it.
*
* Laid out as the toolbar under a reply is, a little closer to what it is under: a drawn answer
* ends in its own frame, not in a last line of words. The newest drawn answer's stays shown, as the
* newest reply's Copy does; an earlier one's shows on hover, so a conversation of charts is not a
* column of buttons.
*
* Its room is kept while the turn is still going, unseen and out of reach, as the reply toolbar's
* is: what the Bot says after the drawing does not move down when the turn ends and this shows.
*/
const MakeArtifactAction = memo(function MakeArtifactAction({
ask,
newest,
onMakeArtifact,
settled,
}: {
ask: string;
newest: boolean;
onMakeArtifact: (ask: string) => void;
/** The drawn answer's turn is over. */
settled: boolean;
}) {
return (
<div
aria-hidden={settled ? undefined : true}
className={cn(
"mt-1",
!settled && "invisible",
settled && !newest && ON_HOVER,
)}
data-drawn-actions=""
inert={!settled}
>
<MakeArtifactToolbar onPress={() => onMakeArtifact(ask)} />
</div>
);
});

/** Whose answer this is, by the name the person knows the Bot by. */
function AnswererName({ botId }: { botId: string }) {
const { data: bots } = useQuery(agentListQueryOptions());
Expand Down Expand Up @@ -2628,6 +2678,7 @@ export function ChatTranscript({
refusals = NO_REFUSALS,
stoppedNotice,
onCarryOn,
onMakeArtifact,
stoppedDismissed = false,
onDismissStopped,
working,
Expand Down Expand Up @@ -2682,6 +2733,14 @@ export function ChatTranscript({
);
// The latest reply's Copy stays shown; earlier ones show on hover (`TranscriptMessage`).
const newestReply = [...replies.keys()].at(-1);
/*
* What "Make this an artifact" asks for each answer the Bot drew, by its row. The newest one's
* stays shown, as the newest reply's Copy does; earlier ones show on hover.
*/
const artifactAsks = onMakeArtifact
? makeArtifactAsks(items)
: NO_ARTIFACT_ASKS;
const newestDrawn = [...artifactAsks.keys()].at(-1);
/*
* The folders this conversation's "Check your folders" steps named, for its other folder steps.
* The same map while the names are the same: a new one on every render is a new context value,
Expand Down Expand Up @@ -3187,6 +3246,13 @@ export function ChatTranscript({
if (taskWork.folds.inside.has(item.id)) return null;
// A refused turn's notice, under the last row of the person's message it answered.
const refusal = refusedUnder.get(item.id);
/*
* Under an answer the Bot drew: the way to keep it as an artifact, once its turn is over. Not on
* a read-only row, whose presses go nowhere.
*/
const ask = artifactAsks.get(item.id);
const offersArtifact =
ask !== undefined && onMakeArtifact !== undefined && !readOnly;
return (
<MessageScrollerItem
key={item.id}
Expand All @@ -3197,9 +3263,27 @@ export function ChatTranscript({
: undefined
}
{...openingProps(item.id)}
// The row is the hover that brings out an earlier drawn answer's action.
{...(offersArtifact
? {
className: cn(openingProps(item.id).className, "group/message"),
}
: {})}
{...rowGuard}
>
{rowContent(item, index)}
{/*
* Beside the drawn answer, never around it: wrapping the row once its turn ended would mount
* the interface again, and an interface drawn in a frame would load again.
*/}
{offersArtifact ? (
<MakeArtifactAction
ask={ask}
newest={item.id === newestDrawn}
onMakeArtifact={onMakeArtifact}
settled={!busy || index < turnStart}
/>
) : null}
{/*
* Inside the message's own row, not a row of its own: the scroller counts its rows by
* position, and a row added beside a message would read as a new one arriving. The gap is
Expand Down
39 changes: 39 additions & 0 deletions app/src/components/channels/conversation-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,44 @@ export function ConversationView({
.finally(() => setCarryOnSending(false));
};

/**
* "MAKE THIS AN ARTIFACT" IS THE PERSON ASKING, SENT AS A MESSAGE TYPED HERE IS.
*
* The ask goes to the Bot as an ordinary message from the person, which any Bot answers by making
* the artifact with the `artifact_create` it already holds: a Bot connected over plain AG-UI gets
* exactly what a built-in one does. Like Carry on, it goes at once while the conversation is free
* and waits as queued while a turn is in flight. Pressed again while the same ask is waiting or
* still being sent, it does nothing, so two presses never become two artifacts.
*/
const [artifactAskSending, setArtifactAskSending] = useState<string | null>(
null,
);
const pressMakeArtifact = (ask: string) => {
if (artifactAskSending === ask) return;
if (queuedRef.current.some((message) => message.text === ask)) return;
if (stopIfNeedsCard()) return;
const started = submit(
{
agentId: null,
attachments: [],
commandIds: [],
isEmpty: false,
text: ask,
},
inFlight,
);
if (!started) return;
setArtifactAskSending(ask);
void started
.catch((error: unknown) => {
restoreFailedRun(
[{ attachments: [], commandIds: [], id: newId(), text: ask }],
error,
);
})
.finally(() => setArtifactAskSending(null));
};

/**
* The turn ended. Whatever was waiting for it goes now, as one message.
*
Expand Down Expand Up @@ -653,6 +691,7 @@ export function ConversationView({
{...(stopped && pressCarryOn && !disabled
? { onCarryOn: pressCarryOn }
: {})}
{...(disabled ? {} : { onMakeArtifact: pressMakeArtifact })}
{...(stopped && stoppedDismissed ? { stoppedDismissed } : {})}
{...(stopped && onDismissStopped ? { onDismissStopped } : {})}
working={working}
Expand Down
Loading
Loading