@autobusal/common 1.36.0 → 1.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import { useState } from 'react';
2
2
  import { TFunction } from 'i18next';
3
3
  import { Container, ContainerLocales, LocaleButton, Notice, Textarea } from './styles';
4
4
  import { useGetSettings } from '@autobusal/providers/services';
5
+ import AiFieldAssist from '../AiAssist/AiFieldAssist';
5
6
 
6
7
  export interface SeoEntry {
7
8
  title?: string
@@ -64,6 +65,26 @@ const SeoOverride = ({ value, t, onChange }: Props): JSX.Element => {
64
65
  });
65
66
  };
66
67
 
68
+ /*
69
+ * Claude - 2026-08-29 (asked for by Ferjolt): "when we have any AI
70
+ * provider enabled, the SEO should make use of that ai by using it to
71
+ * generate, get suggestions or translate the fields".
72
+ *
73
+ * The default language's own copy, which is what a translation is made
74
+ * FROM. Undefined while editing the default language itself, which is
75
+ * what hides the Translate trigger there - there is nothing to translate
76
+ * from when you are standing on the source.
77
+ *
78
+ * AiFieldAssist renders nothing at all when no provider is enabled, so
79
+ * this needs no flag of its own and no condition here: a brand with AI
80
+ * switched off sees exactly the editor it sees today.
81
+ */
82
+ const isDefault = locale === data.preferences.languages.default;
83
+
84
+ const source = (field: keyof SeoEntry): string | undefined => (
85
+ isDefault ? undefined : overrides[data.preferences.languages.default]?.[field]
86
+ );
87
+
67
88
  const written = (language: string): boolean => {
68
89
  const entry = overrides[language];
69
90
 
@@ -104,6 +125,14 @@ const SeoOverride = ({ value, t, onChange }: Props): JSX.Element => {
104
125
  value={ current.title ?? '' }
105
126
  onChange={ (event) => update('title', event.target.value) }
106
127
  />
128
+
129
+ <AiFieldAssist
130
+ text={ current.title }
131
+ sourceText={ source('title') }
132
+ targetLocale={ isDefault ? undefined : locale }
133
+ onInsert={ (content: string) => update('title', content.slice(0, 250)) }
134
+ t={ t }
135
+ />
107
136
  </div>
108
137
 
109
138
  <div className="row row-nomargin">
@@ -114,6 +143,19 @@ const SeoOverride = ({ value, t, onChange }: Props): JSX.Element => {
114
143
  value={ current.description ?? '' }
115
144
  onChange={ (event) => update('description', event.target.value) }
116
145
  />
146
+
147
+ { /* Truncated to the field's own maxLength on the way in: the model
148
+ is asked for a meta description and generally obliges, but
149
+ nothing about a language model guarantees a length, and a draft
150
+ that silently exceeded what the server will store would be
151
+ saved cut off with no warning. */ }
152
+ <AiFieldAssist
153
+ text={ current.description }
154
+ sourceText={ source('description') }
155
+ targetLocale={ isDefault ? undefined : locale }
156
+ onInsert={ (content: string) => update('description', content.slice(0, 500)) }
157
+ t={ t }
158
+ />
117
159
  </div>
118
160
  </Container>
119
161
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.36.0",
3
+ "version": "1.36.1",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"