Skip to content
Merged
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
12 changes: 12 additions & 0 deletions packages/ui/src/components/message-part.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
[data-component="assistant-message"] {
content-visibility: auto;
width: 100%;
/* min-width:0 — a flex column won't shrink below its content's intrinsic
width without it, so a long unbroken-ish line (URLs, "overlapping" running
into the next word) pushed the message past the viewport and clipped on the
right. The container chain already sets this; the message column + its
text parts were the gap. */
min-width: 0;
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 12px;
}

[data-component="assistant-message"] [data-component="text-part"],
[data-component="assistant-message"] [data-slot="text-part-body"] {
min-width: 0;
max-width: 100%;
}

[data-component="user-message"] {
font-family: var(--font-family-sans);
font-size: var(--font-size-base);
Expand Down
185 changes: 105 additions & 80 deletions packages/ui/src/components/message-part.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AmicoSpinner } from "../amicode/spinner"
import { AmicoSpinner, AmicoMark } from "../amicode/spinner"
import {
Component,
createEffect,
Expand Down Expand Up @@ -604,89 +604,114 @@ export function AssistantParts(props: {

const last = createMemo(() => grouped().at(-1)?.key)

return (
<Index each={grouped()}>
{(entryAccessor) => {
const entryType = createMemo(() => entryAccessor().type)
// amicode: does this turn already carry an amicode_* tool card? Those cards
// (card.tsx) render their OWN AMICO signature, so a turn-level one would
// double up. The turn-level signature exists precisely for the OTHER case —
// plain prose replies, which otherwise show no Amico identity at all.
const hasAmicodeCard = createMemo(() =>
props.messages.some((message) =>
list(data.store.part?.[message.id], emptyParts).some(
(p) => p.type === "tool" && /^amicode_/.test((p as ToolPart).tool ?? ""),
),
),
)

return (
<Switch>
<Match when={entryType() === "context"}>
{(() => {
const parts = createMemo(
() => {
return (
<>
{/* amicode: the AMICO signature heads assistant turns so the brand
identity doesn't vanish in plain chat (it only lived on interview
receipt cards before). Suppressed when a turn already has an
amicode_* card — that card brings its own signature. Kate's restyle
(amc-sig/amc-wordmark) is reused untouched. */}
<Show when={grouped().length > 0 && !hasAmicodeCard()}>
<span class="amc-sig" data-slot="amicode-turn-signature">
<AmicoMark running={props.working && last() === grouped().at(-1)?.key} />
<span class="amc-wordmark">AMICO</span>
</span>
</Show>
<Index each={grouped()}>
{(entryAccessor) => {
const entryType = createMemo(() => entryAccessor().type)

return (
<Switch>
<Match when={entryType() === "context"}>
{(() => {
const parts = createMemo(
() => {
const entry = entryAccessor()
if (entry.type !== "context") return emptyTools
return entry.refs
.map((ref) => part().get(ref.messageID)?.get(ref.partID))
.filter((part): part is ToolPart => !!part && isContextGroupTool(part))
},
emptyTools,
{ equals: same },
)
const busy = createMemo(() => props.working && last() === entryAccessor().key)

return (
<Show when={parts().length > 0}>
<ContextToolGroup parts={parts()} busy={busy()} />
</Show>
)
})()}
</Match>
<Match when={entryType() === "shell"}>
{(() => {
const parts = createMemo(
() => {
const entry = entryAccessor()
if (entry.type !== "shell") return emptyTools
return entry.refs
.map((ref) => part().get(ref.messageID)?.get(ref.partID))
.filter((part): part is ToolPart => !!part && isShellGroupTool(part))
},
emptyTools,
{ equals: same },
)
const busy = createMemo(() => props.working && last() === entryAccessor().key)

return (
<Show when={parts().length > 0}>
<ShellToolGroup parts={parts()} busy={busy()} />
</Show>
)
})()}
</Match>
<Match when={entryType() === "part"}>
{(() => {
const message = createMemo(() => {
const entry = entryAccessor()
if (entry.type !== "context") return emptyTools
return entry.refs
.map((ref) => part().get(ref.messageID)?.get(ref.partID))
.filter((part): part is ToolPart => !!part && isContextGroupTool(part))
},
emptyTools,
{ equals: same },
)
const busy = createMemo(() => props.working && last() === entryAccessor().key)

return (
<Show when={parts().length > 0}>
<ContextToolGroup parts={parts()} busy={busy()} />
</Show>
)
})()}
</Match>
<Match when={entryType() === "shell"}>
{(() => {
const parts = createMemo(
() => {
if (entry.type !== "part") return
return msgs().get(entry.ref.messageID)
})
const item = createMemo(() => {
const entry = entryAccessor()
if (entry.type !== "shell") return emptyTools
return entry.refs
.map((ref) => part().get(ref.messageID)?.get(ref.partID))
.filter((part): part is ToolPart => !!part && isShellGroupTool(part))
},
emptyTools,
{ equals: same },
)
const busy = createMemo(() => props.working && last() === entryAccessor().key)

return (
<Show when={parts().length > 0}>
<ShellToolGroup parts={parts()} busy={busy()} />
</Show>
)
})()}
</Match>
<Match when={entryType() === "part"}>
{(() => {
const message = createMemo(() => {
const entry = entryAccessor()
if (entry.type !== "part") return
return msgs().get(entry.ref.messageID)
})
const item = createMemo(() => {
const entry = entryAccessor()
if (entry.type !== "part") return
return part().get(entry.ref.messageID)?.get(entry.ref.partID)
})

return (
<Show when={message()}>
<Show when={item()}>
<Part
part={item()!}
message={message()!}
showAssistantCopyPartID={props.showAssistantCopyPartID}
turnDurationMs={props.turnDurationMs}
defaultOpen={partDefaultOpen(item()!, props.shellToolDefaultOpen, props.editToolDefaultOpen)}
/>
if (entry.type !== "part") return
return part().get(entry.ref.messageID)?.get(entry.ref.partID)
})

return (
<Show when={message()}>
<Show when={item()}>
<Part
part={item()!}
message={message()!}
showAssistantCopyPartID={props.showAssistantCopyPartID}
turnDurationMs={props.turnDurationMs}
defaultOpen={partDefaultOpen(item()!, props.shellToolDefaultOpen, props.editToolDefaultOpen)}
/>
</Show>
</Show>
</Show>
)
})()}
</Match>
</Switch>
)
}}
</Index>
)
})()}
</Match>
</Switch>
)
}}
</Index>
</>
)
}

Expand Down
Loading