@conduction/nextcloud-vue 2.172.0 → 2.173.0
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.
- package/dist/esm/components/CnAiCompanion/CnAiChatWidget.vue2.js +3 -2
- package/dist/esm/components/CnAiCompanion/CnAiChatWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnAiCompanion/CnAiChatWidget.vue3.js +2 -1
- package/dist/esm/components/CnAiCompanion/CnAiChatWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnAiCompanion/CnAiCompanion.vue2.js +39 -0
- package/dist/esm/components/CnAiCompanion/CnAiCompanion.vue2.js.map +1 -1
- package/dist/esm/components/CnAiCompanion/CnAiCompanion.vue3.js.map +1 -1
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue.js +1 -1
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue2.js.map +1 -1
- package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue3.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue.js +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js +34 -4
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js +42 -34
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue.js +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js +21 -6
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js +54 -4
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +32 -26
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +28 -4
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +4 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
- package/dist/esm/composables/aiChatConfig.js +13 -1
- package/dist/esm/composables/aiChatConfig.js.map +1 -1
- package/dist/esm/composables/useAiChatStream.js +53 -1
- package/dist/esm/composables/useAiChatStream.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +475 -241
- package/dist/nextcloud-vue.cjs.js +797 -556
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +475 -241
- package/package.json +1 -1
- package/src/components/CnAiCompanion/CnAiChatWidget.md +1 -0
- package/src/components/CnAiCompanion/CnAiChatWidget.vue +4 -2
- package/src/components/CnAiCompanion/CnAiCompanion.md +1 -0
- package/src/components/CnAiCompanion/CnAiCompanion.vue +39 -0
- package/src/components/CnDashboardGrid/CnDashboardGrid.vue +5 -2
- package/src/components/CnFilesBrowser/CnFilesBrowser.vue +45 -4
- package/src/components/CnFlowsPage/CnFlowBoard.vue +27 -6
- package/src/components/CnTreeView/CnTreeNode.vue +69 -6
- package/src/components/CnTreeView/CnTreeView.vue +31 -4
- package/src/composables/aiChatConfig.js +12 -0
- package/src/composables/useAiChatStream.js +53 -0
- package/src/css/look-board-detail.css +100 -5
- package/src/css/look-board.css +118 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conduction/nextcloud-vue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.173.0",
|
|
4
4
|
"description": "Shared Vue component library for Conduction Nextcloud apps — complements @nextcloud/vue with higher-level components, OpenRegister integration, and NL Design System support",
|
|
5
5
|
"homepage": "https://github.com/ConductionNL/nextcloud-vue#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -19,6 +19,7 @@ agents) as items of the card's Actions menu.
|
|
|
19
19
|
| `note` | `string` | `''` | A line above the input, e.g. what the assistant can see. Translated. |
|
|
20
20
|
| `placeholder` | `string` | `''` | The input's placeholder; empty keeps "Message input". Translated. |
|
|
21
21
|
| `sendLabel` | `string` | `''` | A label on the send button instead of the send icon. Translated. |
|
|
22
|
+
| `openSubjectSession` | `boolean` | `false` | Open the user's latest session about the page's record (the context's `objectUuid`) instead of an empty thread, with the proposals the assistant still waits on. No such session, a backend that cannot filter sessions by record, or a session about another record leaves the thread empty. |
|
|
22
23
|
|
|
23
24
|
## Example
|
|
24
25
|
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
:inputPlaceholder="tr(content.placeholder)"
|
|
29
29
|
:sendLabel="tr(content.sendLabel)"
|
|
30
30
|
:chatAppId="content.chatAppId || defaultChatAppId"
|
|
31
|
+
:openSubjectSession="content.openSubjectSession === true"
|
|
31
32
|
@menu="onMenu" />
|
|
32
33
|
</div>
|
|
33
34
|
</template>
|
|
@@ -52,8 +53,9 @@ export default {
|
|
|
52
53
|
* The widget's content: `chatAppId`, the backend app that answers the
|
|
53
54
|
* chat (defaults to the companion's own); `pill` and `pillVariant`, a
|
|
54
55
|
* pill in the card's title row; `note`, a line above the input;
|
|
55
|
-
* `placeholder` and `sendLabel`, the input's wording
|
|
56
|
-
* the
|
|
56
|
+
* `placeholder` and `sendLabel`, the input's wording; `openSubjectSession`,
|
|
57
|
+
* open the user's latest session about the page's record instead of an
|
|
58
|
+
* empty thread. Texts go through the host's translate.
|
|
57
59
|
*/
|
|
58
60
|
content: {
|
|
59
61
|
type: Object,
|
|
@@ -24,6 +24,7 @@ The FAB and panel are both hidden when `useAiContext().pageKind === 'chat'` (i.e
|
|
|
24
24
|
| `note` | `String` | `''` | A line above the input, already translated. |
|
|
25
25
|
| `inputPlaceholder` | `String` | `''` | The input's placeholder, already translated. |
|
|
26
26
|
| `sendLabel` | `String` | `''` | A label on the send button, already translated. |
|
|
27
|
+
| `openSubjectSession` | `Boolean` | `false` | Open the user's latest session about the page's record (the context's `objectUuid`) instead of an empty thread, with its pending approvals. No such session, or one about another record, leaves the thread empty. |
|
|
27
28
|
|
|
28
29
|
## Inject
|
|
29
30
|
|
|
@@ -220,6 +220,16 @@ export default {
|
|
|
220
220
|
type: String,
|
|
221
221
|
default: '',
|
|
222
222
|
},
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Open the user's latest session about the page's record (the context's
|
|
226
|
+
* `objectUuid`) instead of an empty thread, with its pending approvals.
|
|
227
|
+
* No such session, or one about another record, leaves the thread empty.
|
|
228
|
+
*/
|
|
229
|
+
openSubjectSession: {
|
|
230
|
+
type: Boolean,
|
|
231
|
+
default: false,
|
|
232
|
+
},
|
|
223
233
|
},
|
|
224
234
|
|
|
225
235
|
emits: ['menu'],
|
|
@@ -232,6 +242,8 @@ export default {
|
|
|
232
242
|
// Cleared on unmount so a torn-down companion cannot stand itself
|
|
233
243
|
// down after the fact.
|
|
234
244
|
legacySiblingTimer: null,
|
|
245
|
+
// The record whose session was last asked for, so it is asked once.
|
|
246
|
+
openedSubjectUuid: '',
|
|
235
247
|
stream: useAiChatStream(this, { chatAppId: this.chatAppId, context: this.context }),
|
|
236
248
|
}
|
|
237
249
|
},
|
|
@@ -272,6 +284,33 @@ export default {
|
|
|
272
284
|
effectiveContext() {
|
|
273
285
|
return this.context || this.cnAiContext || null
|
|
274
286
|
},
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* The record whose session to open: the context's `objectUuid` once the
|
|
290
|
+
* backend answered, when the companion opts in; '' otherwise.
|
|
291
|
+
*
|
|
292
|
+
* @return {string} The record's uuid or ''.
|
|
293
|
+
* @spec openspec/changes/ai-chat-opens-the-subject-session/specs/ai-companion/spec.md#requirement-an-embedded-chat-may-open-the-users-session-about-the-pages-record
|
|
294
|
+
*/
|
|
295
|
+
subjectUuid() {
|
|
296
|
+
const uuid = this.effectiveContext && this.effectiveContext.objectUuid
|
|
297
|
+
return (this.openSubjectSession && this.probeSucceeded && typeof uuid === 'string') ? uuid : ''
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
watch: {
|
|
302
|
+
/**
|
|
303
|
+
* Open the session about the record once it is known, once per record.
|
|
304
|
+
*
|
|
305
|
+
* @param {string} uuid The record's uuid or ''.
|
|
306
|
+
* @spec openspec/changes/ai-chat-opens-the-subject-session/specs/ai-companion/spec.md#requirement-an-embedded-chat-may-open-the-users-session-about-the-pages-record
|
|
307
|
+
*/
|
|
308
|
+
subjectUuid(uuid) {
|
|
309
|
+
if (uuid !== '' && uuid !== this.openedSubjectUuid) {
|
|
310
|
+
this.openedSubjectUuid = uuid
|
|
311
|
+
this.stream.loadSubjectSession(uuid)
|
|
312
|
+
}
|
|
313
|
+
},
|
|
275
314
|
},
|
|
276
315
|
|
|
277
316
|
created() {
|
|
@@ -1842,8 +1842,11 @@ export default {
|
|
|
1842
1842
|
}
|
|
1843
1843
|
|
|
1844
1844
|
/* A stretched `sameHeight` card keeps its content at the top, as the boards
|
|
1845
|
-
draw a row of cards, not centred in the extra height.
|
|
1846
|
-
|
|
1845
|
+
draw a row of cards, not centred in the extra height. `.grid-stack-item`
|
|
1846
|
+
outranks the dashboard page's centring of a fitted card, which is as
|
|
1847
|
+
strong and loads later (DqProcesanalyse stat tiles).
|
|
1848
|
+
@spec openspec/changes/same-height-fit-card-content-top/specs/dashboard-grid/spec.md#requirement-a-stretched-fitted-card-keeps-its-content-at-the-top */
|
|
1849
|
+
.cn-dashboard-grid__item--same-height.grid-stack-item > :deep(.grid-stack-item-content > * > .cn-widget-wrapper__content) {
|
|
1847
1850
|
justify-content: flex-start;
|
|
1848
1851
|
}
|
|
1849
1852
|
|
|
@@ -405,6 +405,9 @@
|
|
|
405
405
|
:widget="column.widget || null"
|
|
406
406
|
:widgetProps="cellWidgetProps(column, node)"
|
|
407
407
|
:row="node" />
|
|
408
|
+
<span v-if="column.key !== 'name' && cellSubline(column, node)"
|
|
409
|
+
class="cn-files-browser__cell-subline"
|
|
410
|
+
data-testid="cn-files-browser-cell-subline">{{ cellSubline(column, node) }}</span>
|
|
408
411
|
</td>
|
|
409
412
|
<td class="cn-files-browser__col-actions" @click.stop @auxclick.stop>
|
|
410
413
|
<!-- The host's one visible button on a file ("Beoordelen"),
|
|
@@ -1185,9 +1188,12 @@ export default {
|
|
|
1185
1188
|
* The columns this browser shows, in order. An entry is a built-in name
|
|
1186
1189
|
* (`name`, `size`, `modified`, `owner`, `type`, `tags`) or an object
|
|
1187
1190
|
* declaring its own: `{ key, label, source, attribute, formatter,
|
|
1188
|
-
* sortable }`, where `source` is `node` (a property of the node),
|
|
1191
|
+
* sortable, subline }`, where `source` is `node` (a property of the node),
|
|
1189
1192
|
* `attribute` (a DAV property, added to the PROPFIND before listing) or
|
|
1190
|
-
* `row` (a value from `rowData`).
|
|
1193
|
+
* `row` (a value from `rowData`). `subline` is a template drawn as a
|
|
1194
|
+
* muted second line under the value, filled from the file's `rowData`
|
|
1195
|
+
* entry ("ground {reviewGrounds|values}"); it is left out when it
|
|
1196
|
+
* names no value.
|
|
1191
1197
|
*
|
|
1192
1198
|
* Declaring none keeps today's table: name, size and modified.
|
|
1193
1199
|
*
|
|
@@ -2219,8 +2225,7 @@ export default {
|
|
|
2219
2225
|
if ((!this.nameSecondary && fields === null) || this.isFolder(node)) {
|
|
2220
2226
|
return ''
|
|
2221
2227
|
}
|
|
2222
|
-
const
|
|
2223
|
-
const entry = byId[node.fileid] ?? byId[String(node.fileid)] ?? {}
|
|
2228
|
+
const entry = this.rowEntryOf(node)
|
|
2224
2229
|
const owner = node.attributes ? node.attributes['owner-display-name'] : undefined
|
|
2225
2230
|
const object = {
|
|
2226
2231
|
...entry,
|
|
@@ -2771,6 +2776,34 @@ export default {
|
|
|
2771
2776
|
return fileColumnValue(column, node, this.resolvedRowData)
|
|
2772
2777
|
},
|
|
2773
2778
|
|
|
2779
|
+
/**
|
|
2780
|
+
* The host's row data for one file (`rowData`, by file id), `{}` without it.
|
|
2781
|
+
*
|
|
2782
|
+
* @param {object} node The node.
|
|
2783
|
+
* @return {object} The row entry.
|
|
2784
|
+
*/
|
|
2785
|
+
rowEntryOf(node) {
|
|
2786
|
+
const byId = this.resolvedRowData && typeof this.resolvedRowData === 'object' ? this.resolvedRowData : {}
|
|
2787
|
+
return byId[node.fileid] ?? byId[String(node.fileid)] ?? {}
|
|
2788
|
+
},
|
|
2789
|
+
|
|
2790
|
+
/**
|
|
2791
|
+
* A declared column's second line under its value: the column's
|
|
2792
|
+
* `subline` template, translated and filled from the file's row data
|
|
2793
|
+
* ("ground {reviewGrounds|values}"), '' when it names no value.
|
|
2794
|
+
*
|
|
2795
|
+
* @param {object} column A resolved column.
|
|
2796
|
+
* @param {object} node The node.
|
|
2797
|
+
* @return {string} The line, or ''.
|
|
2798
|
+
* @spec openspec/changes/files-column-subline/specs/files-column-subline/spec.md#requirement-a-declared-column-can-draw-a-second-line-under-its-value
|
|
2799
|
+
*/
|
|
2800
|
+
cellSubline(column, node) {
|
|
2801
|
+
if (!column || typeof column.subline !== 'string' || column.subline === '') {
|
|
2802
|
+
return ''
|
|
2803
|
+
}
|
|
2804
|
+
return fillTemplate(this.cnTranslate(column.subline), this.rowEntryOf(node))
|
|
2805
|
+
},
|
|
2806
|
+
|
|
2774
2807
|
/**
|
|
2775
2808
|
* The tone a column or card field draws a value in: its `colorMap`
|
|
2776
2809
|
* entry for the value (case-insensitive), read from the `colorKey` field
|
|
@@ -3731,6 +3764,14 @@ export default {
|
|
|
3731
3764
|
white-space: nowrap;
|
|
3732
3765
|
}
|
|
3733
3766
|
|
|
3767
|
+
.cn-files-browser__cell-subline {
|
|
3768
|
+
display: block;
|
|
3769
|
+
margin-top: 3px;
|
|
3770
|
+
color: var(--color-text-maxcontrast);
|
|
3771
|
+
font-size: 12px;
|
|
3772
|
+
line-height: normal;
|
|
3773
|
+
}
|
|
3774
|
+
|
|
3734
3775
|
.cn-files-browser__name-secondary {
|
|
3735
3776
|
display: block;
|
|
3736
3777
|
overflow: hidden;
|
|
@@ -1011,7 +1011,8 @@ export default {
|
|
|
1011
1011
|
const options = field.optionsFrom
|
|
1012
1012
|
? [...(this.loadedOptions[field.optionsFrom] || [])]
|
|
1013
1013
|
: normaliseSelectOptions(field.options)
|
|
1014
|
-
|
|
1014
|
+
const listed = (o) => o.id === value || (o.key !== undefined && o.key === value)
|
|
1015
|
+
if (isSet(value) && typeof value !== 'object' && options.length > 0 && !options.some(listed)) {
|
|
1015
1016
|
options.push({ id: value, label: String(value) })
|
|
1016
1017
|
}
|
|
1017
1018
|
let widget = 'text'
|
|
@@ -1029,7 +1030,7 @@ export default {
|
|
|
1029
1030
|
widget,
|
|
1030
1031
|
value,
|
|
1031
1032
|
options,
|
|
1032
|
-
option: options.find((o) => o.id === value) || null,
|
|
1033
|
+
option: options.find((o) => o.id === value) || options.find(listed) || null,
|
|
1033
1034
|
isObject: value !== null && typeof value === 'object',
|
|
1034
1035
|
}
|
|
1035
1036
|
})
|
|
@@ -1037,8 +1038,10 @@ export default {
|
|
|
1037
1038
|
|
|
1038
1039
|
/**
|
|
1039
1040
|
* Where the selected step goes next: each outgoing line by its name
|
|
1040
|
-
* ("Ja", "Nee"), else
|
|
1041
|
+
* ("Ja", "Nee"), else by the exit it leaves by (its label, else its id
|
|
1042
|
+
* with a capital), else "Next", with the step it leads to.
|
|
1041
1043
|
*
|
|
1044
|
+
* @spec openspec/changes/flow-board-inspector-fields/specs/flow-board/spec.md#requirement-the-flow-board-inspector-edits-the-selected-steps-settings-and-names-its-outcomes
|
|
1042
1045
|
* @return {Array<{id: string, label: string, target: string}>} The outcomes.
|
|
1043
1046
|
*/
|
|
1044
1047
|
stepOutcomes() {
|
|
@@ -1050,9 +1053,18 @@ export default {
|
|
|
1050
1053
|
const node = this.store.nodes.find((item) => item.id === target)
|
|
1051
1054
|
return (node && (node.name || node.label)) || target
|
|
1052
1055
|
}
|
|
1056
|
+
const exits = (this.store.selectedNode && Array.isArray(this.store.selectedNode.exits)) ? this.store.selectedNode.exits : []
|
|
1057
|
+
const exitName = (line) => {
|
|
1058
|
+
const exitId = line.data && line.data.edge && line.data.edge.fromExit
|
|
1059
|
+
if (!exitId) {
|
|
1060
|
+
return ''
|
|
1061
|
+
}
|
|
1062
|
+
const exit = exits.find((item) => item && item.id === exitId)
|
|
1063
|
+
return (exit && exit.label) || String(exitId).charAt(0).toUpperCase() + String(exitId).slice(1)
|
|
1064
|
+
}
|
|
1053
1065
|
return (this.store.canvasEdges || [])
|
|
1054
1066
|
.filter((line) => line.source === id)
|
|
1055
|
-
.map((line) => ({ id: line.id, label: (line.data && line.data.label) || this.t('nextcloud-vue', 'Next'), target: nameOf(line.target) }))
|
|
1067
|
+
.map((line) => ({ id: line.id, label: (line.data && line.data.label) || exitName(line) || this.t('nextcloud-vue', 'Next'), target: nameOf(line.target) }))
|
|
1056
1068
|
},
|
|
1057
1069
|
|
|
1058
1070
|
/**
|
|
@@ -1229,8 +1241,9 @@ export default {
|
|
|
1229
1241
|
|
|
1230
1242
|
/**
|
|
1231
1243
|
* Load the choices of the selected step's select fields that name a
|
|
1232
|
-
* url (`optionsFrom`), once per url.
|
|
1244
|
+
* url (`optionsFrom`), once per url. A row's `key` stays on its option.
|
|
1233
1245
|
*
|
|
1246
|
+
* @spec openspec/changes/flow-board-inspector-fields/specs/flow-board/spec.md#requirement-the-flow-board-inspector-edits-the-selected-steps-settings-and-names-its-outcomes
|
|
1234
1247
|
* @return {Promise<void>}
|
|
1235
1248
|
*/
|
|
1236
1249
|
async loadStepOptions() {
|
|
@@ -1249,7 +1262,9 @@ export default {
|
|
|
1249
1262
|
try {
|
|
1250
1263
|
const response = await axios.get(url.startsWith('/') && !url.startsWith('/apps') && !url.startsWith('/index.php') ? generateUrl(url) : url)
|
|
1251
1264
|
const rows = Array.isArray(response.data) ? response.data : (response.data?.results || [])
|
|
1252
|
-
|
|
1265
|
+
const keys = new Map(rows.filter((row) => row && typeof row === 'object' && row.key).map((row) => [row.id ?? row.value ?? row['@self']?.uuid ?? row.uuid, row.key]))
|
|
1266
|
+
const options = normaliseSelectOptions(rows).map((option) => (keys.has(option.id) ? { ...option, key: keys.get(option.id) } : option))
|
|
1267
|
+
this.loadedOptions = { ...this.loadedOptions, [url]: options }
|
|
1253
1268
|
} catch (error) {
|
|
1254
1269
|
// The field then shows the stored value; Edit step still reaches everything.
|
|
1255
1270
|
// eslint-disable-next-line no-console -- diagnostic for a failure this degrades from
|
|
@@ -1602,6 +1617,12 @@ export default {
|
|
|
1602
1617
|
transform: translateX(18px);
|
|
1603
1618
|
}
|
|
1604
1619
|
|
|
1620
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1621
|
+
.cn-flow-board__toggle::after {
|
|
1622
|
+
transition: none;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1605
1626
|
.cn-flow-board__toggle:focus-visible {
|
|
1606
1627
|
outline: 2px solid var(--color-primary-element);
|
|
1607
1628
|
outline-offset: 2px;
|
|
@@ -9,12 +9,16 @@
|
|
|
9
9
|
:aria-expanded="hasChildren ? isExpanded : undefined"
|
|
10
10
|
:aria-selected="isSelected">
|
|
11
11
|
<div class="cn-tree-node__row"
|
|
12
|
+
v-bind="extraRowAttrs"
|
|
12
13
|
:style="{ paddingLeft: (depth * indent) + 'px' }"
|
|
13
|
-
|
|
14
|
+
:tabindex="focusableRows ? 0 : undefined"
|
|
15
|
+
@click="onRowClick"
|
|
16
|
+
@keydown="onRowKeydown">
|
|
14
17
|
<button v-if="hasChildren"
|
|
15
18
|
type="button"
|
|
19
|
+
v-bind="extraToggleAttrs"
|
|
16
20
|
class="cn-tree-node__toggle"
|
|
17
|
-
:aria-label="
|
|
21
|
+
:aria-label="toggleLabel"
|
|
18
22
|
@click.stop="toggle">
|
|
19
23
|
<span class="cn-tree-node__caret" :class="{ 'cn-tree-node__caret--open': isExpanded }">▸</span>
|
|
20
24
|
</button>
|
|
@@ -48,6 +52,9 @@
|
|
|
48
52
|
:childrenKey="childrenKey"
|
|
49
53
|
:expandLabel="expandLabel"
|
|
50
54
|
:collapseLabel="collapseLabel"
|
|
55
|
+
:toggleAttrs="toggleAttrs"
|
|
56
|
+
:rowAttrs="rowAttrs"
|
|
57
|
+
:focusableRows="focusableRows"
|
|
51
58
|
@toggle="$emit('toggle', $event)"
|
|
52
59
|
@select="$emit('select', $event)">
|
|
53
60
|
<template #actions="scope">
|
|
@@ -87,10 +94,16 @@ export default {
|
|
|
87
94
|
labelKey: { type: String, default: 'label' },
|
|
88
95
|
/** Node-field key for the children array. */
|
|
89
96
|
childrenKey: { type: String, default: 'children' },
|
|
90
|
-
/** A11y label for the expand button
|
|
91
|
-
expandLabel: { type: String, default: 'Expand' },
|
|
92
|
-
/** A11y label for the collapse button
|
|
93
|
-
collapseLabel: { type: String, default: 'Collapse' },
|
|
97
|
+
/** A11y label for the expand button, or `(node) => string`. */
|
|
98
|
+
expandLabel: { type: [String, Function], default: 'Expand' },
|
|
99
|
+
/** A11y label for the collapse button, or `(node) => string`. */
|
|
100
|
+
collapseLabel: { type: [String, Function], default: 'Collapse' },
|
|
101
|
+
/** Extra expand-button attributes per node, `(node, depth) => object`. */
|
|
102
|
+
toggleAttrs: { type: Function, default: null },
|
|
103
|
+
/** Extra row attributes per node, `(node, depth) => object`. */
|
|
104
|
+
rowAttrs: { type: Function, default: null },
|
|
105
|
+
/** Rows take focus and select on Enter or Space. */
|
|
106
|
+
focusableRows: { type: Boolean, default: false },
|
|
94
107
|
},
|
|
95
108
|
|
|
96
109
|
emits: ['select', 'toggle'],
|
|
@@ -122,6 +135,34 @@ export default {
|
|
|
122
135
|
isSelected() {
|
|
123
136
|
return this.selectedId === this.node[this.idKey]
|
|
124
137
|
},
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The expand button's accessible name for this node.
|
|
141
|
+
*
|
|
142
|
+
* @return {string}
|
|
143
|
+
*/
|
|
144
|
+
toggleLabel() {
|
|
145
|
+
const label = this.isExpanded ? this.collapseLabel : this.expandLabel
|
|
146
|
+
return typeof label === 'function' ? label(this.node) : label
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The host's extra attributes for this row.
|
|
151
|
+
*
|
|
152
|
+
* @return {object}
|
|
153
|
+
*/
|
|
154
|
+
extraRowAttrs() {
|
|
155
|
+
return this.rowAttrs ? this.rowAttrs(this.node, this.depth) : {}
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The host's extra attributes for this row's expand button.
|
|
160
|
+
*
|
|
161
|
+
* @return {object}
|
|
162
|
+
*/
|
|
163
|
+
extraToggleAttrs() {
|
|
164
|
+
return this.toggleAttrs ? this.toggleAttrs(this.node, this.depth) : {}
|
|
165
|
+
},
|
|
125
166
|
},
|
|
126
167
|
|
|
127
168
|
methods: {
|
|
@@ -132,6 +173,22 @@ export default {
|
|
|
132
173
|
onRowClick() {
|
|
133
174
|
this.$emit('select', this.node)
|
|
134
175
|
},
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Enter or Space on a focusable row selects its node. Keys pressed on
|
|
179
|
+
* the expand button or an action inside the row are theirs.
|
|
180
|
+
*
|
|
181
|
+
* @param {KeyboardEvent} event The key event.
|
|
182
|
+
*/
|
|
183
|
+
onRowKeydown(event) {
|
|
184
|
+
if (!this.focusableRows || event.target !== event.currentTarget) {
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
188
|
+
event.preventDefault()
|
|
189
|
+
this.$emit('select', this.node)
|
|
190
|
+
}
|
|
191
|
+
},
|
|
135
192
|
},
|
|
136
193
|
}
|
|
137
194
|
</script>
|
|
@@ -154,6 +211,12 @@ export default {
|
|
|
154
211
|
background: var(--color-background-hover);
|
|
155
212
|
}
|
|
156
213
|
|
|
214
|
+
/* A row made focusable by `focusableRows` shows where keyboard focus is (WCAG 2.4.7). */
|
|
215
|
+
.cn-tree-node__row[tabindex]:focus-visible {
|
|
216
|
+
outline: 2px solid var(--color-primary-element);
|
|
217
|
+
outline-offset: -2px;
|
|
218
|
+
}
|
|
219
|
+
|
|
157
220
|
.cn-tree-node--selected > .cn-tree-node__row {
|
|
158
221
|
background: var(--color-primary-element-light);
|
|
159
222
|
color: var(--color-main-text);
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
:childrenKey="childrenKey"
|
|
27
27
|
:expandLabel="expandLabel"
|
|
28
28
|
:collapseLabel="collapseLabel"
|
|
29
|
+
:toggleAttrs="toggleAttrs"
|
|
30
|
+
:rowAttrs="rowAttrs"
|
|
31
|
+
:focusableRows="focusableRows"
|
|
29
32
|
@toggle="toggleNode"
|
|
30
33
|
@select="selectNode">
|
|
31
34
|
<template #actions="scope">
|
|
@@ -78,6 +81,14 @@ import CnTreeNode from './CnTreeNode.vue'
|
|
|
78
81
|
* - `#label` — the label of every row, for an icon, a marker or a test id
|
|
79
82
|
* next to the text. Scope: `{ node, depth, expanded }`. Unused, the row
|
|
80
83
|
* shows `node[labelKey]`.
|
|
84
|
+
*
|
|
85
|
+
* Per-node hooks, all off by default:
|
|
86
|
+
* - `expandLabel` / `collapseLabel` take a function `(node) => string` for a
|
|
87
|
+
* name per row, e.g. "Expand {name}".
|
|
88
|
+
* - `toggleAttrs` and `rowAttrs` add attributes per node to the expand button
|
|
89
|
+
* and the row (test ids, `data-*`, an active class, a role).
|
|
90
|
+
* - `focusableRows` lets keyboard users reach a row and select it with
|
|
91
|
+
* Enter or Space.
|
|
81
92
|
*/
|
|
82
93
|
export default {
|
|
83
94
|
name: 'CnTreeView',
|
|
@@ -127,10 +138,26 @@ export default {
|
|
|
127
138
|
description: { type: String, default: '' },
|
|
128
139
|
/** Empty-state text when nodes[] is empty. */
|
|
129
140
|
emptyLabel: { type: String, default: 'No items.' },
|
|
130
|
-
/** A11y label for the expand button. */
|
|
131
|
-
expandLabel: { type: String, default: 'Expand' },
|
|
132
|
-
/** A11y label for the collapse button. */
|
|
133
|
-
collapseLabel: { type: String, default: 'Collapse' },
|
|
141
|
+
/** A11y label for the expand button, or `(node) => string` for a name per row. */
|
|
142
|
+
expandLabel: { type: [String, Function], default: 'Expand' },
|
|
143
|
+
/** A11y label for the collapse button, or `(node) => string` for a name per row. */
|
|
144
|
+
collapseLabel: { type: [String, Function], default: 'Collapse' },
|
|
145
|
+
/**
|
|
146
|
+
* Extra attributes for each row's expand button, as `(node, depth) => object`,
|
|
147
|
+
* e.g. a test id per node. Null adds none.
|
|
148
|
+
*/
|
|
149
|
+
toggleAttrs: { type: Function, default: null },
|
|
150
|
+
/**
|
|
151
|
+
* Extra attributes for each row, as `(node, depth) => object`: a class,
|
|
152
|
+
* `data-*` attributes, or a `role` and `aria-label`. `class` and `style`
|
|
153
|
+
* merge with the row's own. Null adds none.
|
|
154
|
+
*/
|
|
155
|
+
rowAttrs: { type: Function, default: null },
|
|
156
|
+
/**
|
|
157
|
+
* Makes each row reachable with Tab (`tabindex="0"`); Enter or Space on
|
|
158
|
+
* the row selects its node, like a click. Off, rows are click-only.
|
|
159
|
+
*/
|
|
160
|
+
focusableRows: { type: Boolean, default: false },
|
|
134
161
|
/** Expand all nodes on mount. */
|
|
135
162
|
expandAllOnMount: { type: Boolean, default: false },
|
|
136
163
|
},
|
|
@@ -107,6 +107,18 @@ export function conversationsUrl(appId) {
|
|
|
107
107
|
return `${chatApiBase(appId)}/conversations`
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Session list endpoint (`GET`). Takes `subject=<objectUuid>` to list only the
|
|
112
|
+
* caller's sessions about one record, most recent activity first.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} [appId] Backend app id.
|
|
115
|
+
* @return {string}
|
|
116
|
+
* @spec openspec/changes/ai-chat-opens-the-subject-session/specs/ai-companion/spec.md#requirement-an-embedded-chat-may-open-the-users-session-about-the-pages-record
|
|
117
|
+
*/
|
|
118
|
+
export function sessionsUrl(appId) {
|
|
119
|
+
return `${chatApiBase(appId)}/sessions`
|
|
120
|
+
}
|
|
121
|
+
|
|
110
122
|
/**
|
|
111
123
|
* Messages of a single conversation (`GET`).
|
|
112
124
|
*
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
chatStreamUrl,
|
|
37
37
|
conversationMessagesUrl,
|
|
38
38
|
DEFAULT_CHAT_APP_ID,
|
|
39
|
+
sessionsUrl,
|
|
39
40
|
} from './aiChatConfig.js'
|
|
40
41
|
import { useAiContext } from './useAiContext.js'
|
|
41
42
|
|
|
@@ -483,8 +484,13 @@ export function useAiChatStream(contextInstance, options = {}) {
|
|
|
483
484
|
* conversations identically to live ones. OR does not persist tool calls
|
|
484
485
|
* on messages, so toolCalls degrades to [].
|
|
485
486
|
*
|
|
487
|
+
* The approvals the agent still waits on come with the messages
|
|
488
|
+
* (`pendingApprovals`, the shape of the stream's `final` event), so a
|
|
489
|
+
* reopened conversation shows them as a live turn does.
|
|
490
|
+
*
|
|
486
491
|
* @param {string} conversationUuid - UUID of the conversation to resume
|
|
487
492
|
* @returns {Promise<void>}
|
|
493
|
+
* @spec openspec/changes/ai-chat-opens-the-subject-session/specs/ai-companion/spec.md#requirement-a-loaded-conversation-keeps-its-pending-approvals
|
|
488
494
|
*/
|
|
489
495
|
async function loadConversation(conversationUuid) {
|
|
490
496
|
try {
|
|
@@ -503,6 +509,7 @@ export function useAiChatStream(contextInstance, options = {}) {
|
|
|
503
509
|
content: m.content || '',
|
|
504
510
|
toolCalls: m.toolCalls || m.tool_calls || [],
|
|
505
511
|
}))
|
|
512
|
+
state.pendingApprovals = Array.isArray(data.pendingApprovals) ? data.pendingApprovals : []
|
|
506
513
|
// Don't force a new thread — resume this conversation, and remember its
|
|
507
514
|
// uuid so the next send() continues it instead of starting a new one.
|
|
508
515
|
state._newThread = false
|
|
@@ -513,6 +520,35 @@ export function useAiChatStream(contextInstance, options = {}) {
|
|
|
513
520
|
}
|
|
514
521
|
}
|
|
515
522
|
|
|
523
|
+
/**
|
|
524
|
+
* Open the user's most recent session about one record, if there is one.
|
|
525
|
+
*
|
|
526
|
+
* A session is accepted only when its subject is that record, so a backend
|
|
527
|
+
* that ignores the `subject` filter leaves the thread empty instead of
|
|
528
|
+
* opening a conversation about something else.
|
|
529
|
+
*
|
|
530
|
+
* @param {string} objectUuid The record the page is about.
|
|
531
|
+
* @return {Promise<boolean>} Whether a session was opened.
|
|
532
|
+
* @spec openspec/changes/ai-chat-opens-the-subject-session/specs/ai-companion/spec.md#requirement-an-embedded-chat-may-open-the-users-session-about-the-pages-record
|
|
533
|
+
*/
|
|
534
|
+
async function loadSubjectSession(objectUuid) {
|
|
535
|
+
let sessions
|
|
536
|
+
try {
|
|
537
|
+
const response = await axios.get(sessionsUrl(chatAppId), { params: { subject: objectUuid, limit: 1 } })
|
|
538
|
+
sessions = Array.isArray(response.data?.results) ? response.data.results : []
|
|
539
|
+
} catch (err) {
|
|
540
|
+
// eslint-disable-next-line no-console
|
|
541
|
+
console.info('[useAiChatStream] Could not list the sessions about the record:', err?.message)
|
|
542
|
+
return false
|
|
543
|
+
}
|
|
544
|
+
const session = sessions.find((candidate) => subjectOf(candidate) === objectUuid)
|
|
545
|
+
if (!session) {
|
|
546
|
+
return false
|
|
547
|
+
}
|
|
548
|
+
await loadConversation(session.uuid || session.id)
|
|
549
|
+
return state.conversationUuid !== null
|
|
550
|
+
}
|
|
551
|
+
|
|
516
552
|
return {
|
|
517
553
|
// Reactive state (accessed as state.isStreaming etc. from the component)
|
|
518
554
|
state,
|
|
@@ -521,5 +557,22 @@ export function useAiChatStream(contextInstance, options = {}) {
|
|
|
521
557
|
abort,
|
|
522
558
|
startNewThread,
|
|
523
559
|
loadConversation,
|
|
560
|
+
loadSubjectSession,
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* The record a session is about: `subject.objectUuid`, or the same under its
|
|
566
|
+
* `metadata`, where the session stores it.
|
|
567
|
+
*
|
|
568
|
+
* @param {object} session A session from the session list.
|
|
569
|
+
* @return {string} The record's uuid, or '' when the session names none.
|
|
570
|
+
* @spec openspec/changes/ai-chat-opens-the-subject-session/specs/ai-companion/spec.md#requirement-an-embedded-chat-may-open-the-users-session-about-the-pages-record
|
|
571
|
+
*/
|
|
572
|
+
function subjectOf(session) {
|
|
573
|
+
const subject = session?.subject || session?.metadata?.subject
|
|
574
|
+
if (typeof subject === 'string') {
|
|
575
|
+
return subject
|
|
524
576
|
}
|
|
577
|
+
return (subject && typeof subject.objectUuid === 'string') ? subject.objectUuid : ''
|
|
525
578
|
}
|