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
431 changes: 261 additions & 170 deletions app/src/components/manage/skill-page.tsx

Large diffs are not rendered by default.

153 changes: 83 additions & 70 deletions app/src/components/settings/learning-sharing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function SkillMark({ children }: { children: React.ReactNode }) {
* the Skills learned from their recordings and conversations, each marked Learned.
*
* Every recording a person makes goes into their own Learning space, and the Skills learned there
* reach every Bot they use. In the team edition they also choose, below the list, who else's Bots may
* reach every Bot they use. In the team edition they also choose, below the lists, who else's Bots may
* draw on them: none (the default), all, or the Skills they open one by one. Each change takes effect
* when it is made; there is no save. Sharing waits for an administrator (Admin, Automatic learning,
* Skill sharing): until then nothing can be opened, and what was opened can still be closed.
Expand All @@ -134,6 +134,7 @@ export function LearningSharing({
writtenKnown = true,
heldAbove = false,
action,
afterSkills = null,
}: {
/**
* The page above has already said OpenBot is holding off (a move, or the database out of reach):
Expand All @@ -146,6 +147,11 @@ export function LearningSharing({
writtenKnown?: boolean;
/** The section's one verb: New skill. */
action?: React.ReactNode;
/**
* The page's other lists of skills (Workspace skills), drawn right after Your skills and before
* the sharing choice, so every list is read before the setting about them.
*/
afterSkills?: React.ReactNode;
} = {}) {
const sharing = useQuery(personalLearningQueryOptions());
const setMode = useMutation(
Expand All @@ -165,24 +171,27 @@ export function LearningSharing({
</React.Fragment>
));
// Which edition decides the layout, so nothing draws until it is known. A failed read counts as the team edition.
if (capabilities.isPending) return null;
if (capabilities.isPending) return afterSkills;
// Nothing to list yet from either read.
if (sharing.isPending && !writtenKnown) return null;
if (sharing.isPending && !writtenKnown) return afterSkills;
const personal = capabilities.data?.edition === "personal";
/*
* The skills a person wrote don't come from Learning, so they and New skill are drawn whether or
* not it answered. Its failure is said inside the section, above what is still known.
*/
if (sharing.isPending || sharing.error) {
return (
<PageSection action={action} title="Your skills">
{sharing.error && !(heldAbove && isHeld(sharing.error)) ? (
<p className="text-destructive text-sm" role="alert">
{failureSaid(sharing.error)}
</p>
) : null}
{written.length > 0 ? <PageRows>{writtenRows}</PageRows> : null}
</PageSection>
<>
<PageSection action={action} title="Your skills">
{sharing.error && !(heldAbove && isHeld(sharing.error)) ? (
<p className="text-destructive text-sm" role="alert">
{failureSaid(sharing.error)}
</p>
) : null}
{written.length > 0 ? <PageRows>{writtenRows}</PageRows> : null}
</PageSection>
{afterSkills}
</>
);
}
const data = sharing.data;
Expand All @@ -200,68 +209,71 @@ export function LearningSharing({
const learned = data.skills ?? [];
const none = learned.length === 0 && written.length === 0;
return (
<PageSection
action={action}
title="Your skills"
// Said only over skills to open: above the empty state it would point at nothing.
description={
none
? undefined
: "Type / and a skill's name to give a Bot that instruction. Open one to read or change it."
}
>
{none ? (
writtenKnown ? (
<PageEmpty>
{data.skills === null
? emptySentence(data, mode, true)
: "No skills yet. Write one with New skill, or teach a Bot a task."}
</PageEmpty>
) : null
) : (
<PageRows>
{writtenRows}
{learned.map((skill, index) => (
<React.Fragment key={skill.name}>
{index > 0 || written.length > 0 ? <Separator /> : null}
<Item
size="sm"
render={
<button
onClick={() => setReading(skill.name)}
type="button"
/>
}
>
<ItemMedia variant="icon">
<IconSparkles />
</ItemMedia>
<ItemContent>
<ItemTitle>
{skillTitle(skill.name, skill.description)}
<SkillMark>Learned</SkillMark>
</ItemTitle>
<ItemDescription>{skill.description}</ItemDescription>
</ItemContent>
<ItemActions>
<IconChevronRight className="size-4 text-muted-foreground" />
</ItemActions>
</Item>
</React.Fragment>
))}
</PageRows>
)}
<LearnedSkillDialog
name={reading}
title={readingTitle}
onClose={() => setReading(null)}
source={{ kind: "personal" }}
/>
</PageSection>
<>
<PageSection
action={action}
title="Your skills"
// Said only over skills to open: above the empty state it would point at nothing.
description={
none
? undefined
: "Type / and a skill's name to give a Bot that instruction. Open one to read or change it."
}
>
{none ? (
writtenKnown ? (
<PageEmpty>
{data.skills === null
? emptySentence(data, mode, true)
: "No skills yet. Write one with New skill, or teach a Bot a task."}
</PageEmpty>
) : null
) : (
<PageRows>
{writtenRows}
{learned.map((skill, index) => (
<React.Fragment key={skill.name}>
{index > 0 || written.length > 0 ? <Separator /> : null}
<Item
size="sm"
render={
<button
onClick={() => setReading(skill.name)}
type="button"
/>
}
>
<ItemMedia variant="icon">
<IconSparkles />
</ItemMedia>
<ItemContent>
<ItemTitle>
{skillTitle(skill.name, skill.description)}
<SkillMark>Learned</SkillMark>
</ItemTitle>
<ItemDescription>{skill.description}</ItemDescription>
</ItemContent>
<ItemActions>
<IconChevronRight className="size-4 text-muted-foreground" />
</ItemActions>
</Item>
</React.Fragment>
))}
</PageRows>
)}
<LearnedSkillDialog
name={reading}
title={readingTitle}
onClose={() => setReading(null)}
source={{ kind: "personal" }}
/>
</PageSection>
{afterSkills}
</>
);
}

// Below the list: it is a choice about the learned skills in it.
// Below the lists: it is a choice about the learned skills in them.
const choiceSection = (
<PageSection
title="Who else's Bots use your skills"
Expand Down Expand Up @@ -476,6 +488,7 @@ export function LearningSharing({
source={{ kind: "personal" }}
/>
</PageSection>
{afterSkills}
{choiceSection}
{failure ? (
<p className="mt-4 text-destructive text-sm" role="alert">
Expand Down
102 changes: 0 additions & 102 deletions app/src/components/skills/edit-skill.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/components/skills/proposed-skill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ function PutItOnABot({ slug }: { slug: string }) {
return (
<Link
className="mt-2 inline-block text-sm underline underline-offset-4"
search={{ edit: slug }}
to="/skills"
params={{ slug }}
to="/skills/$slug"
>
Put it on a Bot
</Link>
Expand Down
Loading
Loading