Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
style(ai-assistant): tidy the review row, the preview panel and its strip
Elian Doran164174424045
diff --git a/apps/client/src/stylesheets/ckeditor-theme.css b/apps/client/src/stylesheets/ckeditor-theme.cssindex da01f9a39f..707d38266c 100644--- a/apps/client/src/stylesheets/ckeditor-theme.css+++ b/apps/client/src/stylesheets/ckeditor-theme.css@@ -113,17 +113,12 @@ body {--ck-input-label-height: 1.5em;}-/* -- Overrides the default .ck-dialog class to match Trilium's modals. --------------------- */-div.ck.ck-dialog {--ck-color-dialog-background: var(--modal-background-color, var(--main-background-color));- /* CKEditor rings every :focus and :active with a blue 1px border plus a 3px #cae1fc halo, and- the toolbar scopes are the only place Trilium takes it off.- `--ck-focus-ring` has to be redefined rather than just `--ck-color-focus-border`: the ring is- declared at `:root`, so the colour is substituted into it there and it inherits down already- resolved — recolouring further down the tree cannot reach it. The ring is kept at 1px rather- than made transparent because `.ck-input:focus` draws its focus border from it. */+ --ck-color-base-border: var(--main-border-color);+ --ck-border-radius: var(--bs-border-radius);+--ck-focus-ring: 1px solid var(--input-focus-outline-color, var(--main-border-color));--ck-color-focus-border: var(--input-focus-outline-color, var(--main-border-color));--ck-focus-outer-shadow: none;@@ -169,8 +164,6 @@ div.ck.ck-dialog .ck.ck-form__header > .ck.ck-button:active {transform: scale(.85);}-/* The button's own `border: 0` outranks CKEditor's focus ring, so without this the close button- has no focus indicator at all. Same outline `.modal .modal-header .btn-close` gets. */div.ck.ck-dialog .ck.ck-form__header > .ck.ck-button:focus-visible {outline: 2px solid var(--input-focus-outline-color, var(--main-border-color));outline-offset: 2px;diff --git a/apps/client/src/stylesheets/theme-next/forms.css b/apps/client/src/stylesheets/theme-next/forms.cssindex 65ee8929f5..c9b2f4c5d4 100644--- a/apps/client/src/stylesheets/theme-next/forms.css+++ b/apps/client/src/stylesheets/theme-next/forms.css@@ -222,9 +222,6 @@ button.tn-low-profile:hover {}}-/* The AI assistant's Result/Changes choice, drawn as the same track. Its buttons are CKEditor's,- so the selected one is `.ck-on` rather than `.active`, and the background has to be taken off- `--ck-button-background` instead of `--cmd-button-background-color`. */:root .ck.ck-ai-assistant-form .ck-ai-assistant-form__viewmodes {gap: 4px;border-radius: 8px;@@ -237,15 +234,8 @@ button.tn-low-profile:hover {box-shadow: unset;border-radius: 8px;background: transparent;- /* CKEditor rings a button on `:active` as well as on `:focus`, so a held segment would- outline itself; the segments a group is normally built from carry no border at all.- Only the colour is dropped, keeping the 1px so the geometry stays put. Keyboard focus- is covered by the outline below. */border-color: transparent;- /* The segments a group is normally built from are `.icon-action`s, which hover against- `--hover-item-background-color`; a CKEditor button would otherwise bring its own, far- heavier `--ck-color-button-default-hover-background`. */&:hover:not(.ck-on) {background: var(--hover-item-background-color);color: var(--hover-item-text-color);diff --git a/packages/ckeditor5/src/plugins/ai_assistant/ai_assistant_form.ts b/packages/ckeditor5/src/plugins/ai_assistant/ai_assistant_form.tsindex 7f971c1dcb..903677f52d 100644--- a/packages/ckeditor5/src/plugins/ai_assistant/ai_assistant_form.ts+++ b/packages/ckeditor5/src/plugins/ai_assistant/ai_assistant_form.ts@@ -94,7 +94,7 @@ export default class AiAssistantFormView extends View {// is about the response on screen, not about what to do with it.this.tryAgainButtonView = this._createActionButton(locale, t("Try again"), "review", "tryAgain");this.tryAgainButtonView.set({ icon: IconRefresh, withText: false, tooltip: true });- this.tryAgainButtonView.class = "ck-ai-assistant-form__try-again ck-ai-assistant-form__icon-action";+ this.tryAgainButtonView.class = "ck-ai-assistant-form__icon-action";const bind = this.bindTemplate;@@ -118,7 +118,28 @@ export default class AiAssistantFormView extends View {attributes: { class: ["ck", "ck-ai-assistant-form__viewmodes"] },children: [this.resultToggleView, this.changesToggleView]},- this.tryAgainButtonView+ {+ // What the run cost and the way to ask for another are both about the+ // response on show, so they end its strip together. A container of+ // their own, rather than a margin on each, keeps them to the end+ // whether or not the provider reported any usage.+ tag: "div",+ attributes: { class: ["ck", "ck-ai-assistant-form__preview-toolbar-end"] },+ children: [+ {+ tag: "span",+ attributes: {+ class: [+ "ck",+ "ck-ai-assistant-form__usage",+ bind.if("usageText", "ck-hidden", (text) => !text)+ ]+ },+ children: [{ text: bind.to("usageText") }]+ },+ this.tryAgainButtonView+ ]+ }]},this.previewView,@@ -143,19 +164,10 @@ export default class AiAssistantFormView extends View {attributes: { class: ["ck", "ck-ai-assistant-form__actions"] },children: [this.stopButtonView,- this.replaceButtonView,+ // The row is pushed to the end, so "Replace" comes last to land where the+ // eye finishes and the primary action is expected.this.insertBelowButtonView,- {- tag: "span",- attributes: {- class: [- "ck",- "ck-ai-assistant-form__usage",- bind.if("usageText", "ck-hidden", (text) => !text)- ]- },- children: [{ text: bind.to("usageText") }]- }+ this.replaceButtonView]}]@@ -186,8 +198,8 @@ export default class AiAssistantFormView extends View {this.promptInputView,this.sendButtonView,this.stopButtonView,- this.replaceButtonView,- this.insertBelowButtonView+ this.insertBelowButtonView,+ this.replaceButtonView];for (const view of focusables) {this._focusables.add(view);diff --git a/packages/ckeditor5/src/plugins/ai_assistant/theme/ai_assistant.css b/packages/ckeditor5/src/plugins/ai_assistant/theme/ai_assistant.cssindex ad784ccc1d..445621b61e 100644--- a/packages/ckeditor5/src/plugins/ai_assistant/theme/ai_assistant.css+++ b/packages/ckeditor5/src/plugins/ai_assistant/theme/ai_assistant.css@@ -23,13 +23,14 @@gap: var(--ck-spacing-tiny);}-/* A review with no diff to offer hides both modes; the container must not stay behind as an- empty frame wherever the host gives it a background of its own. */.ck.ck-ai-assistant-form .ck-ai-assistant-form__viewmodes:not(:has(.ck-button:not(.ck-hidden))) {display: none;}-.ck.ck-ai-assistant-form .ck-button.ck-ai-assistant-form__try-again {+.ck.ck-ai-assistant-form .ck-ai-assistant-form__preview-toolbar-end {+ display: flex;+ align-items: center;+ gap: var(--ck-spacing-small);margin-inline-start: auto;}@@ -57,6 +58,8 @@padding: var(--ck-spacing-medium);background: var(--ck-color-base-background);white-space: pre-wrap;+ -webkit-user-select: text;+ user-select: text;p:last-child {margin-bottom: 0;@@ -74,15 +77,15 @@.ck.ck-ai-assistant-form .ck-ai-assistant-form__actions {display: flex;+ justify-content: flex-end;gap: var(--ck-spacing-small);}-/* The run's model/token/cost line, tucked to the right of the review actions. */+/* The run's model/token/cost line, alongside the retry icon at the end of the preview's strip. */.ck.ck-ai-assistant-form .ck-ai-assistant-form__usage {- margin-left: auto;- align-self: center;font-size: var(--ck-font-size-small);opacity: 0.7;+ white-space: nowrap;}/* An actions row with every button hidden should not reserve a gap's worth of height. */