Skip to content

Build your personal knowledge base with Trilium Notes

feat(ckeditor): group the AI length actions under Adjust

Elian Dorana2fbf3023a51
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index a67236815a..ca05ce8373 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -2836,30 +2836,34 @@
"ai_assistant": {
"group_edit": "Edit or review",
"group_generate": "Generate",
+ "group_adjust": "Adjust",
"group_tone": "Change tone",
"group_reformat": "Reformat",
"group_translate": "Translate",
+ "command_make_shorter": "Make shorter",
+ "command_make_longer": "Make longer",
+ "command_simplify": "Simplify language",
"command_tone": "Change tone to {{tone}}",
- "command_translate": "Translate to {{language}}",
"command_bullet_list": "Turn into a bullet list",
"command_table": "Turn into a table",
"command_action_items": "Extract action items",
+ "command_translate": "Translate to {{language}}",
"action_fix_typos": "Fix typos",
"action_improve_writing": "Improve writing",
- "action_make_shorter": "Make shorter",
- "action_make_longer": "Make longer",
- "action_simplify": "Simplify language",
"action_summarize": "Summarize",
"action_explain": "Explain",
"action_continue": "Continue writing",
- "action_bullet_list": "Bullet list",
- "action_table": "Table",
- "action_action_items": "Action items",
+ "adjust_shorter": "Shorter",
+ "adjust_longer": "Longer",
+ "adjust_simpler": "Simpler",
"tone_professional": "Professional",
"tone_casual": "Casual",
"tone_direct": "Direct",
"tone_friendly": "Friendly",
"tone_confident": "Confident",
+ "reformat_bullet_list": "Bullet list",
+ "reformat_table": "Table",
+ "reformat_action_items": "Action items",
"lang_english": "English",
"lang_german": "German",
"lang_spanish": "Spanish",
diff --git a/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.spec.ts b/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.spec.ts
index 973d7f6df8..8f7e485d1a 100644
--- a/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.spec.ts
+++ b/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.spec.ts
@@ -104,12 +104,18 @@ describe("buildAiAssistantQuickActions", () => {
expect(romanian?.prompt).toBe("Translate the content to Romanian.");
});
- it("gives each reformat its own command label rather than composing one", () => {
- // "Turn into a table" against "Extract action items": no single phrase composes both.
+ // "Make shorter" against "Simplify language", "Turn into a table" against "Extract action
+ // items": no single phrase composes either pair, so both labels are translated as a pair.
+ it("spells out both labels for the adjustments and the reformats", () => {
+ expect(actions("adjust").map((action) => [action.label, action.commandLabel])).toEqual([
+ ["ai_assistant.adjust_shorter", "ai_assistant.command_make_shorter"],
+ ["ai_assistant.adjust_longer", "ai_assistant.command_make_longer"],
+ ["ai_assistant.adjust_simpler", "ai_assistant.command_simplify"]
+ ]);
expect(actions("reformat").map((action) => [action.label, action.commandLabel])).toEqual([
- ["ai_assistant.action_bullet_list", "ai_assistant.command_bullet_list"],
- ["ai_assistant.action_table", "ai_assistant.command_table"],
- ["ai_assistant.action_action_items", "ai_assistant.command_action_items"]
+ ["ai_assistant.reformat_bullet_list", "ai_assistant.command_bullet_list"],
+ ["ai_assistant.reformat_table", "ai_assistant.command_table"],
+ ["ai_assistant.reformat_action_items", "ai_assistant.command_action_items"]
]);
});
@@ -125,13 +131,14 @@ describe("buildAiAssistantQuickActions", () => {
// Improve writing leaves the mechanics to Fix typos and the length to Make shorter.
expect(promptOf("edit", "improveWriting")).not.toMatch(/mistakes|tighten/i);
+ expect(promptOf("adjust", "makeShorter")).toMatch(/shorten/i);
expect(promptOf("edit", "fixTypos")).toMatch(/spelling, grammar and punctuation/i);
});
it("inlines the groups whose actions already read as commands", () => {
const groups = buildAiAssistantQuickActions();
expect(groups.filter((group) => group.submenu).map((group) => group.id))
- .toEqual(["tone", "reformat", "translate"]);
+ .toEqual(["adjust", "tone", "reformat", "translate"]);
expect(groups.filter((group) => !group.submenu).map((group) => group.id))
.toEqual(["edit", "generate"]);
});
diff --git a/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.ts b/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.ts
index 2223fa3060..16f5954953 100644
--- a/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.ts
+++ b/apps/client/src/widgets/type_widgets/text/ai_assistant_stream.ts
@@ -76,13 +76,7 @@ export function buildAiAssistantQuickActions(): AiQuickActionGroup[] {
// Deliberately not "fix mistakes and tighten the phrasing": that made this the same
// instruction as Fix typos and Make shorter, which are one click away either side.
action("improveWriting", t("ai_assistant.action_improve_writing"),
- "Improve the clarity, flow and word choice of this content, keeping its meaning and roughly its length."),
- action("makeShorter", t("ai_assistant.action_make_shorter"),
- "Shorten this content by removing repetition and non-essential details, without losing key information."),
- action("makeLonger", t("ai_assistant.action_make_longer"),
- "Expand this content with more detail and clearer explanations, keeping the original meaning."),
- action("simplify", t("ai_assistant.action_simplify"),
- "Rewrite this content in simpler language so that it is easier to understand.")
+ "Improve the clarity, flow and word choice of this content, keeping its meaning and roughly its length.")
]
},
{
@@ -97,6 +91,21 @@ export function buildAiAssistantQuickActions(): AiQuickActionGroup[] {
"Continue writing from the end of the provided content, staying on topic and matching its style. Keep the continuation brief.")
]
},
+ {
+ // The three ways of saying the same thing differently, as against improving it
+ // (Improve writing), replacing it (Summarize, Explain) or correcting it (Fix typos).
+ id: "adjust",
+ label: t("ai_assistant.group_adjust"),
+ submenu: true,
+ actions: [
+ spelledOutAction("makeShorter", t("ai_assistant.adjust_shorter"), t("ai_assistant.command_make_shorter"),
+ "Shorten this content by removing repetition and non-essential details, without losing key information."),
+ spelledOutAction("makeLonger", t("ai_assistant.adjust_longer"), t("ai_assistant.command_make_longer"),
+ "Expand this content with more detail and clearer explanations, keeping the original meaning."),
+ spelledOutAction("simplify", t("ai_assistant.adjust_simpler"), t("ai_assistant.command_simplify"),
+ "Rewrite this content in simpler language so that it is easier to understand.")
+ ]
+ },
{
id: "tone",
label: t("ai_assistant.group_tone"),
@@ -121,13 +130,13 @@ export function buildAiAssistantQuickActions(): AiQuickActionGroup[] {
label: t("ai_assistant.group_reformat"),
submenu: true,
actions: [
- reformatAction("bulletList", t("ai_assistant.action_bullet_list"), t("ai_assistant.command_bullet_list"),
+ spelledOutAction("bulletList", t("ai_assistant.reformat_bullet_list"), t("ai_assistant.command_bullet_list"),
"Rewrite this content as a bulleted list, one point per item, without losing information."),
- reformatAction("table", t("ai_assistant.action_table"), t("ai_assistant.command_table"),
+ spelledOutAction("table", t("ai_assistant.reformat_table"), t("ai_assistant.command_table"),
"Reorganize this content into a table with a header row, choosing columns that fit what the content describes."),
// Kept to a plain list: the editor's task lists need CKEditor's own `todo-list`
// markup, which the system prompt does not describe to the model.
- reformatAction("actionItems", t("ai_assistant.action_action_items"), t("ai_assistant.command_action_items"),
+ spelledOutAction("actionItems", t("ai_assistant.reformat_action_items"), t("ai_assistant.command_action_items"),
"Extract the action items from this content as a bulleted list, each one short and starting with a verb. Leave out anything that is not an action.")
]
},
@@ -168,11 +177,13 @@ function translateAction(id: string, language: string, prompt: string): AiQuickA
}
/**
- * A reformat needs the same two labels as a tone or a language — a bare "Table" says nothing in the
- * `/` palette — but its commands do not compose from a single phrase ("Turn into a table" against
- * "Extract action items"), so each carries its own translated pair instead of a substitution.
+ * An action that needs the two labels spelled out rather than composed. Adjust and Reformat both
+ * read as a bare word under their heading ("Shorter", "Table") and so need the standalone wording
+ * the `/` palette shows, but neither composes from a single phrase the way a tone or a language
+ * does — "Make shorter" against "Simplify language", "Turn into a table" against "Extract action
+ * items". So the pair is translated as a pair.
*/
-function reformatAction(id: string, label: string, commandLabel: string, prompt: string): AiQuickAction {
+function spelledOutAction(id: string, label: string, commandLabel: string, prompt: string): AiQuickAction {
return { id, label, commandLabel, prompt };
}