@things-factory/ai-assistant 10.1.47 → 10.1.50
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/client/components/assistant-chat.ts +97 -19
- package/client/components/assistant-dock.ts +617 -0
- package/client/components/assistant-mode.ts +2 -0
- package/client/components/assistant-session-manager.ts +607 -0
- package/client/components/chat-echo-dedup.ts +4 -0
- package/client/components/chat-input-builder.ts +4 -1
- package/client/components/panel-aria.test.ts +13 -8
- package/client/index.ts +8 -0
- package/client/setup-assistant-dock.ts +109 -0
- package/client/utils/assistant-activity.ts +122 -0
- package/client/utils/assistant-ask.ts +44 -0
- package/client/utils/assistant-proposals.ts +50 -0
- package/client/utils/assistant-session-actions.ts +18 -0
- package/client/utils/assistant-session-admin.ts +167 -0
- package/client/utils/assistant-session-controller.ts +2 -0
- package/client/utils/assistant-session-transport.ts +6 -2
- package/client/utils/assistant-surface.ts +157 -0
- package/client/utils/attachment-policy.ts +71 -0
- package/dist-client/components/assistant-chat.d.ts +6 -0
- package/dist-client/components/assistant-chat.js +98 -20
- package/dist-client/components/assistant-chat.js.map +1 -1
- package/dist-client/components/assistant-dock.d.ts +74 -0
- package/dist-client/components/assistant-dock.js +641 -0
- package/dist-client/components/assistant-dock.js.map +1 -0
- package/dist-client/components/assistant-mode.d.ts +6 -0
- package/dist-client/components/assistant-mode.js.map +1 -1
- package/dist-client/components/assistant-session-manager.d.ts +77 -0
- package/dist-client/components/assistant-session-manager.js +652 -0
- package/dist-client/components/assistant-session-manager.js.map +1 -0
- package/dist-client/components/chat-echo-dedup.js +4 -0
- package/dist-client/components/chat-echo-dedup.js.map +1 -1
- package/dist-client/components/chat-input-builder.d.ts +2 -0
- package/dist-client/components/chat-input-builder.js +2 -1
- package/dist-client/components/chat-input-builder.js.map +1 -1
- package/dist-client/components/panel-aria.test.js +12 -8
- package/dist-client/components/panel-aria.test.js.map +1 -1
- package/dist-client/index.d.ts +8 -0
- package/dist-client/index.js +8 -0
- package/dist-client/index.js.map +1 -1
- package/dist-client/setup-assistant-dock.d.ts +15 -0
- package/dist-client/setup-assistant-dock.js +110 -0
- package/dist-client/setup-assistant-dock.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/assistant-activity.d.ts +22 -0
- package/dist-client/utils/assistant-activity.js +104 -0
- package/dist-client/utils/assistant-activity.js.map +1 -0
- package/dist-client/utils/assistant-ask.d.ts +23 -0
- package/dist-client/utils/assistant-ask.js +18 -0
- package/dist-client/utils/assistant-ask.js.map +1 -0
- package/dist-client/utils/assistant-proposals.d.ts +29 -0
- package/dist-client/utils/assistant-proposals.js +22 -0
- package/dist-client/utils/assistant-proposals.js.map +1 -0
- package/dist-client/utils/assistant-session-actions.d.ts +12 -0
- package/dist-client/utils/assistant-session-actions.js +19 -0
- package/dist-client/utils/assistant-session-actions.js.map +1 -0
- package/dist-client/utils/assistant-session-admin.d.ts +72 -0
- package/dist-client/utils/assistant-session-admin.js +81 -0
- package/dist-client/utils/assistant-session-admin.js.map +1 -0
- package/dist-client/utils/assistant-session-controller.d.ts +2 -0
- package/dist-client/utils/assistant-session-controller.js.map +1 -1
- package/dist-client/utils/assistant-session-transport.js +6 -2
- package/dist-client/utils/assistant-session-transport.js.map +1 -1
- package/dist-client/utils/assistant-surface.d.ts +72 -0
- package/dist-client/utils/assistant-surface.js +99 -0
- package/dist-client/utils/assistant-surface.js.map +1 -0
- package/dist-client/utils/attachment-policy.d.ts +35 -0
- package/dist-client/utils/attachment-policy.js +56 -0
- package/dist-client/utils/attachment-policy.js.map +1 -0
- package/dist-server/service/assistant-chat-resolver.d.ts +1 -0
- package/dist-server/service/assistant-chat-resolver.js +71 -3
- package/dist-server/service/assistant-chat-resolver.js.map +1 -1
- package/dist-server/service/assistant-mode/assistant-mode-resolver.d.ts +1 -0
- package/dist-server/service/assistant-mode/assistant-mode-resolver.js +7 -0
- package/dist-server/service/assistant-mode/assistant-mode-resolver.js.map +1 -1
- package/dist-server/service/assistant-mode/resolve.d.ts +3 -0
- package/dist-server/service/assistant-mode/resolve.js +6 -2
- package/dist-server/service/assistant-mode/resolve.js.map +1 -1
- package/dist-server/service/assistant-mode/types.d.ts +6 -0
- package/dist-server/service/assistant-mode/types.js +0 -9
- package/dist-server/service/assistant-mode/types.js.map +1 -1
- package/dist-server/service/chat-message/chat-message.d.ts +6 -0
- package/dist-server/service/chat-message/chat-message.js +19 -0
- package/dist-server/service/chat-message/chat-message.js.map +1 -1
- package/dist-server/service/chat-session/attachment-policy.d.ts +44 -0
- package/dist-server/service/chat-session/attachment-policy.js +56 -0
- package/dist-server/service/chat-session/attachment-policy.js.map +1 -0
- package/dist-server/service/chat-session/attachment-route.d.ts +3 -0
- package/dist-server/service/chat-session/attachment-route.js +44 -0
- package/dist-server/service/chat-session/attachment-route.js.map +1 -0
- package/dist-server/service/chat-session/attachment-tools.d.ts +3 -0
- package/dist-server/service/chat-session/attachment-tools.js +59 -0
- package/dist-server/service/chat-session/attachment-tools.js.map +1 -0
- package/dist-server/service/chat-session/session-attachments.d.ts +36 -0
- package/dist-server/service/chat-session/session-attachments.js +84 -0
- package/dist-server/service/chat-session/session-attachments.js.map +1 -0
- package/dist-server/service/chat-session/session-inbox.d.ts +29 -0
- package/dist-server/service/chat-session/session-inbox.js +32 -8
- package/dist-server/service/chat-session/session-inbox.js.map +1 -1
- package/dist-server/service/chat-session/session-purge.d.ts +14 -0
- package/dist-server/service/chat-session/session-purge.js +77 -0
- package/dist-server/service/chat-session/session-purge.js.map +1 -0
- package/dist-server/service/chat-session/session-retention.d.ts +6 -0
- package/dist-server/service/chat-session/session-retention.js +20 -0
- package/dist-server/service/chat-session/session-retention.js.map +1 -0
- package/dist-server/service/chat-session/session-visibility.d.ts +8 -0
- package/dist-server/service/chat-session/session-visibility.js +11 -0
- package/dist-server/service/chat-session/session-visibility.js.map +1 -1
- package/dist-server/service/chat-session/session-write-gate.d.ts +11 -0
- package/dist-server/service/chat-session/session-write-gate.js +24 -0
- package/dist-server/service/chat-session/session-write-gate.js.map +1 -0
- package/dist-server/service/chat-session-participant/invite-notification.d.ts +1 -1
- package/dist-server/service/chat-session-participant/invite-notification.js +21 -6
- package/dist-server/service/chat-session-participant/invite-notification.js.map +1 -1
- package/dist-server/service/chat-session-participant/participant-lookup-roles.d.ts +3 -0
- package/dist-server/service/chat-session-participant/participant-lookup-roles.js +10 -0
- package/dist-server/service/chat-session-participant/participant-lookup-roles.js.map +1 -0
- package/dist-server/service/chat-session-participant/participant-lookup.d.ts +2 -0
- package/dist-server/service/chat-session-participant/participant-lookup.js +26 -0
- package/dist-server/service/chat-session-participant/participant-lookup.js.map +1 -0
- package/dist-server/service/chat-session-resolver.d.ts +17 -2
- package/dist-server/service/chat-session-resolver.js +135 -15
- package/dist-server/service/chat-session-resolver.js.map +1 -1
- package/dist-server/service/index.d.ts +5 -0
- package/dist-server/service/index.js +5 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -2
- package/server/service/assistant-chat-resolver.ts +71 -4
- package/server/service/assistant-mode/assistant-mode-resolver.ts +6 -0
- package/server/service/assistant-mode/resolve.ts +9 -2
- package/server/service/assistant-mode/types.ts +6 -0
- package/server/service/chat-message/chat-message.ts +17 -0
- package/server/service/chat-session/attachment-policy.test.ts +42 -0
- package/server/service/chat-session/attachment-policy.ts +68 -0
- package/server/service/chat-session/attachment-route.ts +45 -0
- package/server/service/chat-session/attachment-tools.ts +63 -0
- package/server/service/chat-session/session-attachments.ts +89 -0
- package/server/service/chat-session/session-inbox.test.ts +71 -1
- package/server/service/chat-session/session-inbox.ts +61 -11
- package/server/service/chat-session/session-purge.test.ts +24 -0
- package/server/service/chat-session/session-purge.ts +81 -0
- package/server/service/chat-session/session-retention.ts +17 -0
- package/server/service/chat-session/session-visibility.ts +11 -0
- package/server/service/chat-session/session-write-gate.test.ts +53 -0
- package/server/service/chat-session/session-write-gate.ts +31 -0
- package/server/service/chat-session-participant/invite-notification.test.ts +15 -0
- package/server/service/chat-session-participant/invite-notification.ts +24 -6
- package/server/service/chat-session-participant/participant-lookup-roles.ts +6 -0
- package/server/service/chat-session-participant/participant-lookup.ts +22 -0
- package/server/service/chat-session-resolver.ts +130 -13
- package/server/service/index.ts +5 -0
- package/test/assistant-dock.test.ts +118 -0
- package/test/assistant-session-manager.test.ts +126 -0
- package/test/attachment-policy-agree.test.ts +32 -0
- package/test/open-doors.test.ts +5 -2
- package/translations/en.json +61 -1
- package/translations/ja.json +61 -1
- package/translations/ko.json +61 -1
- package/translations/ms.json +61 -1
- package/translations/zh.json +61 -1
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/icon/icon.js';
|
|
3
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
4
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
5
|
+
import { i18next } from '@operato/i18n';
|
|
6
|
+
import { OxPrompt } from '@operato/popup';
|
|
7
|
+
import { assistantSessionAdmin, sessionActions } from '../utils/assistant-session-admin.js';
|
|
8
|
+
const PAGE = 30;
|
|
9
|
+
const t = (key, defaultValue, options = {}) => i18next.t(`ai-assistant.session.${key}`, { defaultValue, ...options });
|
|
10
|
+
/**
|
|
11
|
+
* The conversations on one anchor, managed - `<ox-assistant-session-manager>`.
|
|
12
|
+
*
|
|
13
|
+
* Search, a filter (all / mine / including hidden), paging, and on each row: open, rename, hide or
|
|
14
|
+
* unhide, private ⇄ public, delete. Taken from operato-twin's dock, where it was written first, so every
|
|
15
|
+
* dock gets it by placing this element (typically behind the toolbar's "All History").
|
|
16
|
+
*
|
|
17
|
+
* ── What is the host's ──────────────────────────────────────────────────────────
|
|
18
|
+
* Opening and starting a conversation belong to the dock's session controller, so this element asks
|
|
19
|
+
* with the toolbar's own events and does not open anything itself:
|
|
20
|
+
* assistant-session-select { sessionId } open that conversation
|
|
21
|
+
* assistant-session-reset start a new one
|
|
22
|
+
* assistant-session-changed { sessionId, change: 'renamed' | 'hidden' | 'unhidden' | 'removed' | 'visibility' }
|
|
23
|
+
* a row changed - the host refreshes its tabs; if the open
|
|
24
|
+
* conversation was removed or hidden, it moves off it
|
|
25
|
+
*
|
|
26
|
+
* ── What is the server's ────────────────────────────────────────────────────────
|
|
27
|
+
* Who may do what (`sessionActions`): rename any participant, hide anyone for their own list, delete
|
|
28
|
+
* the creator, visibility the owner. The buttons follow those hints; the doors decide again.
|
|
29
|
+
*
|
|
30
|
+
* ── Asking before what cannot be undone ─────────────────────────────────────────
|
|
31
|
+
* Delete, and opening a private conversation to the domain, ask on the row itself - [Cancel][OK].
|
|
32
|
+
* Making it private, hiding and renaming do not: each can be undone from the same row.
|
|
33
|
+
*/
|
|
34
|
+
let AssistantSessionManager = class AssistantSessionManager extends LitElement {
|
|
35
|
+
constructor() {
|
|
36
|
+
super(...arguments);
|
|
37
|
+
/** The anchor whose conversations are listed - the same one the dock's session controller opened. */
|
|
38
|
+
this.anchorType = '';
|
|
39
|
+
this.anchorId = '';
|
|
40
|
+
/** The conversation the dock has open - marked in the list. */
|
|
41
|
+
this.sessionId = '';
|
|
42
|
+
/** The doors. Replaceable for tests; a host normally leaves it. */
|
|
43
|
+
this.admin = assistantSessionAdmin;
|
|
44
|
+
/** The conversation kind (mode) open in the dock - the list's default scope (§2-6). */
|
|
45
|
+
this.kind = '';
|
|
46
|
+
/** kind → the words people know it by (the modes' labels), for each row. */
|
|
47
|
+
this.kindLabels = {};
|
|
48
|
+
this.entries = [];
|
|
49
|
+
this.total = 0;
|
|
50
|
+
this.hiddenCount = 0;
|
|
51
|
+
this.search = '';
|
|
52
|
+
this.allKinds = false;
|
|
53
|
+
this.whose = 'all';
|
|
54
|
+
this.visibility = 'all';
|
|
55
|
+
this.includeHidden = false;
|
|
56
|
+
this.unreadOnly = false;
|
|
57
|
+
this.pageSize = PAGE;
|
|
58
|
+
this.loading = false;
|
|
59
|
+
this.error = '';
|
|
60
|
+
this.renamingId = '';
|
|
61
|
+
this.generation = 0;
|
|
62
|
+
}
|
|
63
|
+
static { this.styles = css `
|
|
64
|
+
:host {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
min-height: 0;
|
|
68
|
+
font-size: 12.5px;
|
|
69
|
+
color: var(--md-sys-color-on-surface);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.bar {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
gap: 6px;
|
|
76
|
+
padding: 8px 10px;
|
|
77
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.bar input,
|
|
81
|
+
.bar select {
|
|
82
|
+
min-width: 0;
|
|
83
|
+
height: 28px;
|
|
84
|
+
box-sizing: border-box;
|
|
85
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
86
|
+
border-radius: 6px;
|
|
87
|
+
background: var(--md-sys-color-surface-container-lowest);
|
|
88
|
+
color: inherit;
|
|
89
|
+
font: inherit;
|
|
90
|
+
padding: 0 8px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.bar input {
|
|
94
|
+
flex: 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.new {
|
|
98
|
+
flex: none;
|
|
99
|
+
border: 0;
|
|
100
|
+
border-radius: 6px;
|
|
101
|
+
padding: 4px 8px;
|
|
102
|
+
background: transparent;
|
|
103
|
+
color: var(--md-sys-color-primary);
|
|
104
|
+
font: inherit;
|
|
105
|
+
font-weight: 650;
|
|
106
|
+
cursor: pointer;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.filters {
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-wrap: wrap;
|
|
112
|
+
align-items: center;
|
|
113
|
+
gap: 6px 10px;
|
|
114
|
+
padding: 6px 10px;
|
|
115
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
116
|
+
font-size: 11.5px;
|
|
117
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.filters select {
|
|
121
|
+
height: 26px;
|
|
122
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
123
|
+
border-radius: 6px;
|
|
124
|
+
background: var(--md-sys-color-surface-container-lowest);
|
|
125
|
+
color: inherit;
|
|
126
|
+
font: inherit;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.filters label {
|
|
130
|
+
display: inline-flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
gap: 3px;
|
|
133
|
+
cursor: pointer;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.kind {
|
|
137
|
+
color: var(--md-sys-color-primary);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.list {
|
|
141
|
+
flex: 1;
|
|
142
|
+
min-height: 0;
|
|
143
|
+
overflow: auto;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.row {
|
|
147
|
+
position: relative;
|
|
148
|
+
display: flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: 8px;
|
|
151
|
+
padding: 9px 10px;
|
|
152
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.row:hover,
|
|
157
|
+
.row.current {
|
|
158
|
+
background: var(--md-sys-color-surface-container);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.row.hidden {
|
|
162
|
+
opacity: 0.6;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.dot {
|
|
166
|
+
flex: none;
|
|
167
|
+
width: 7px;
|
|
168
|
+
height: 7px;
|
|
169
|
+
border-radius: 50%;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.row.unread .dot {
|
|
173
|
+
background: var(--md-sys-color-primary);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.row md-icon {
|
|
177
|
+
--md-icon-size: 16px;
|
|
178
|
+
flex: none;
|
|
179
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.body {
|
|
183
|
+
flex: 1;
|
|
184
|
+
min-width: 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.title,
|
|
188
|
+
.prev {
|
|
189
|
+
overflow: hidden;
|
|
190
|
+
text-overflow: ellipsis;
|
|
191
|
+
white-space: nowrap;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.row.unread .title {
|
|
195
|
+
font-weight: 700;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.prev {
|
|
199
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
200
|
+
font-size: 11px;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* Row actions show on hover and on keyboard focus - the list's body is the names. */
|
|
204
|
+
.acts {
|
|
205
|
+
display: none;
|
|
206
|
+
gap: 2px;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.row:hover .acts,
|
|
210
|
+
.row:focus-within .acts {
|
|
211
|
+
display: flex;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
button.icon {
|
|
215
|
+
display: inline-flex;
|
|
216
|
+
padding: 3px;
|
|
217
|
+
border: 0;
|
|
218
|
+
border-radius: 6px;
|
|
219
|
+
background: none;
|
|
220
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
221
|
+
cursor: pointer;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
button.icon:hover {
|
|
225
|
+
background: var(--md-sys-color-surface-container-high);
|
|
226
|
+
color: var(--md-sys-color-on-surface);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
button.icon.danger:hover {
|
|
230
|
+
color: var(--md-sys-color-error);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.rename {
|
|
234
|
+
flex: 1;
|
|
235
|
+
min-width: 0;
|
|
236
|
+
height: 26px;
|
|
237
|
+
border: 1px solid var(--md-sys-color-primary);
|
|
238
|
+
border-radius: 6px;
|
|
239
|
+
padding: 0 6px;
|
|
240
|
+
font: inherit;
|
|
241
|
+
background: var(--md-sys-color-surface-container-lowest);
|
|
242
|
+
color: inherit;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.ask {
|
|
246
|
+
display: grid;
|
|
247
|
+
gap: 6px;
|
|
248
|
+
padding: 10px;
|
|
249
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
250
|
+
background: var(--md-sys-color-surface-container);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.ask .buttons {
|
|
254
|
+
display: flex;
|
|
255
|
+
justify-content: flex-end;
|
|
256
|
+
gap: 6px;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.ask button {
|
|
260
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
261
|
+
border-radius: 6px;
|
|
262
|
+
padding: 4px 10px;
|
|
263
|
+
background: var(--md-sys-color-surface-container-lowest);
|
|
264
|
+
color: inherit;
|
|
265
|
+
font: inherit;
|
|
266
|
+
cursor: pointer;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.ask button.ok {
|
|
270
|
+
border-color: var(--md-sys-color-primary);
|
|
271
|
+
background: var(--md-sys-color-primary);
|
|
272
|
+
color: var(--md-sys-color-on-primary);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.ask button.ok.danger {
|
|
276
|
+
border-color: var(--md-sys-color-error);
|
|
277
|
+
background: var(--md-sys-color-error);
|
|
278
|
+
color: var(--md-sys-color-on-error);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.note,
|
|
282
|
+
.empty {
|
|
283
|
+
padding: 14px 12px;
|
|
284
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
[role='alert'] {
|
|
288
|
+
color: var(--md-sys-color-error);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.more,
|
|
292
|
+
.hiddenfilter {
|
|
293
|
+
display: flex;
|
|
294
|
+
align-items: center;
|
|
295
|
+
justify-content: center;
|
|
296
|
+
gap: 6px;
|
|
297
|
+
width: 100%;
|
|
298
|
+
padding: 8px;
|
|
299
|
+
border: 0;
|
|
300
|
+
border-top: 1px solid var(--md-sys-color-outline-variant);
|
|
301
|
+
background: none;
|
|
302
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
303
|
+
font: inherit;
|
|
304
|
+
cursor: pointer;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.hiddenfilter md-icon {
|
|
308
|
+
--md-icon-size: 16px;
|
|
309
|
+
}
|
|
310
|
+
`; }
|
|
311
|
+
/** Read the list again - the host calls this after it opened or started a conversation. */
|
|
312
|
+
async reload() {
|
|
313
|
+
const generation = ++this.generation;
|
|
314
|
+
if (!this.anchorType || !this.anchorId) {
|
|
315
|
+
this.entries = [];
|
|
316
|
+
this.total = this.hiddenCount = 0;
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
this.loading = true;
|
|
320
|
+
this.error = '';
|
|
321
|
+
try {
|
|
322
|
+
/*
|
|
323
|
+
* Paging reads again from the start rather than appending - live activity reorders the list, and
|
|
324
|
+
* appending a later page to an earlier order duplicates and drops rows.
|
|
325
|
+
*/
|
|
326
|
+
const page = await this.admin.inbox({
|
|
327
|
+
anchorType: this.anchorType,
|
|
328
|
+
anchorId: this.anchorId,
|
|
329
|
+
search: this.search,
|
|
330
|
+
filters: {
|
|
331
|
+
kind: this.allKinds ? '' : this.kind,
|
|
332
|
+
whose: this.whose,
|
|
333
|
+
visibility: this.visibility,
|
|
334
|
+
includeHidden: this.includeHidden,
|
|
335
|
+
unreadOnly: this.unreadOnly
|
|
336
|
+
},
|
|
337
|
+
limit: this.pageSize,
|
|
338
|
+
offset: 0
|
|
339
|
+
});
|
|
340
|
+
if (generation !== this.generation)
|
|
341
|
+
return;
|
|
342
|
+
this.entries = page.entries;
|
|
343
|
+
this.total = page.total;
|
|
344
|
+
this.hiddenCount = page.hiddenCount;
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
if (generation !== this.generation)
|
|
348
|
+
return;
|
|
349
|
+
this.entries = [];
|
|
350
|
+
this.total = this.hiddenCount = 0;
|
|
351
|
+
this.error = error.message || t('failed', 'could not load the conversation list.');
|
|
352
|
+
}
|
|
353
|
+
finally {
|
|
354
|
+
if (generation === this.generation)
|
|
355
|
+
this.loading = false;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
updated(changed) {
|
|
359
|
+
if (changed.has('anchorType') || changed.has('anchorId') || changed.has('admin') || changed.has('kind'))
|
|
360
|
+
void this.reload();
|
|
361
|
+
/*
|
|
362
|
+
* The rename box takes the keys the moment it opens, with the name selected. `autofocus` works once
|
|
363
|
+
* per document, so the second rename opened a box that ignored the typing (2026-09-24, operato-ecs).
|
|
364
|
+
*/
|
|
365
|
+
if (changed.has('renamingId') && this.renamingId) {
|
|
366
|
+
const input = this.renderRoot.querySelector('input.rename');
|
|
367
|
+
input?.focus();
|
|
368
|
+
input?.select();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
disconnectedCallback() {
|
|
372
|
+
this.generation++;
|
|
373
|
+
clearTimeout(this.searchTimer);
|
|
374
|
+
super.disconnectedCallback();
|
|
375
|
+
}
|
|
376
|
+
emit(name, detail) {
|
|
377
|
+
this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
|
|
378
|
+
}
|
|
379
|
+
/* ── what the person does ────────────────────────────────────────────────────────── */
|
|
380
|
+
onSearch(value) {
|
|
381
|
+
this.search = value;
|
|
382
|
+
clearTimeout(this.searchTimer);
|
|
383
|
+
/* Not on every keystroke. A new search starts from the first page. */
|
|
384
|
+
this.searchTimer = setTimeout(() => {
|
|
385
|
+
this.pageSize = PAGE;
|
|
386
|
+
void this.reload();
|
|
387
|
+
}, 200);
|
|
388
|
+
}
|
|
389
|
+
/** A filter changed - the list starts from its first page again. */
|
|
390
|
+
refilter(change) {
|
|
391
|
+
change();
|
|
392
|
+
this.pageSize = PAGE;
|
|
393
|
+
void this.reload();
|
|
394
|
+
}
|
|
395
|
+
loadMore() {
|
|
396
|
+
this.pageSize += PAGE;
|
|
397
|
+
void this.reload();
|
|
398
|
+
}
|
|
399
|
+
/** Runs one door, then reads the list again - on success and on failure alike, so the row shows the truth. */
|
|
400
|
+
async act(entry, change, run, refused) {
|
|
401
|
+
this.renamingId = '';
|
|
402
|
+
try {
|
|
403
|
+
if (!(await run()))
|
|
404
|
+
this.error = refused;
|
|
405
|
+
else
|
|
406
|
+
this.emit('assistant-session-changed', { sessionId: entry.id, change });
|
|
407
|
+
}
|
|
408
|
+
catch (error) {
|
|
409
|
+
/* Never pass a failure silently - a person must not believe a conversation was deleted when it was not. */
|
|
410
|
+
this.error = error.message;
|
|
411
|
+
}
|
|
412
|
+
const error = this.error;
|
|
413
|
+
await this.reload();
|
|
414
|
+
if (error && !this.error)
|
|
415
|
+
this.error = error;
|
|
416
|
+
}
|
|
417
|
+
rename(entry, name) {
|
|
418
|
+
const trimmed = name.trim();
|
|
419
|
+
this.renamingId = '';
|
|
420
|
+
if (!trimmed || trimmed === entry.name)
|
|
421
|
+
return;
|
|
422
|
+
void this.act(entry, 'renamed', () => this.admin.rename(entry.id, trimmed), t('rename-refused', 'this conversation could not be renamed.'));
|
|
423
|
+
}
|
|
424
|
+
setHidden(entry, hidden) {
|
|
425
|
+
void this.act(entry, hidden ? 'hidden' : 'unhidden', () => this.admin.hide(entry.id, hidden), t('hide-refused', 'this conversation could not be hidden.'));
|
|
426
|
+
}
|
|
427
|
+
setVisibility(entry, visibility) {
|
|
428
|
+
void this.act(entry, 'visibility', () => this.admin.setVisibility(entry.id, visibility), t('visibility-refused', 'only the owner of this conversation can change who reads it.'));
|
|
429
|
+
}
|
|
430
|
+
_removeSession(entry) {
|
|
431
|
+
void this.act(entry, 'removed', () => this.admin.remove(entry.id), t('remove-refused', 'this conversation could not be deleted.'));
|
|
432
|
+
}
|
|
433
|
+
/* ── drawing ─────────────────────────────────────────────────────────────────────── */
|
|
434
|
+
render() {
|
|
435
|
+
const shown = this.entries.length;
|
|
436
|
+
return html `
|
|
437
|
+
<div class="bar">
|
|
438
|
+
<input
|
|
439
|
+
.value=${this.search}
|
|
440
|
+
placeholder=${t('search', 'Search names and last messages')}
|
|
441
|
+
aria-label=${t('search', 'Search names and last messages')}
|
|
442
|
+
@input=${(e) => this.onSearch(e.target.value)}
|
|
443
|
+
@keydown=${(e) => e.key === 'Escape' && this.onSearch('')}
|
|
444
|
+
/>
|
|
445
|
+
<button class="new" @click=${() => this.emit('assistant-session-reset')}>+ ${t('new', 'New conversation')}</button>
|
|
446
|
+
</div>
|
|
447
|
+
<div class="filters">
|
|
448
|
+
${this.kind
|
|
449
|
+
? html `<select aria-label=${t('filter-kind', 'Which kind')} .value=${this.allKinds ? 'all' : 'this'}
|
|
450
|
+
@change=${(e) => this.refilter(() => (this.allKinds = e.target.value === 'all'))}>
|
|
451
|
+
<option value="this">${this.kindLabels[this.kind] || t('filter-this-kind', 'This conversation')}</option>
|
|
452
|
+
<option value="all">${t('filter-all-kinds', 'All kinds here')}</option>
|
|
453
|
+
</select>`
|
|
454
|
+
: nothing}
|
|
455
|
+
<select aria-label=${t('filter-whose', 'Whose')} .value=${this.whose}
|
|
456
|
+
@change=${(e) => this.refilter(() => (this.whose = e.target.value))}>
|
|
457
|
+
<option value="all">${t('filter-all', 'All')}</option>
|
|
458
|
+
<option value="mine">${t('filter-mine', 'Started by me')}</option>
|
|
459
|
+
<option value="participant">${t('filter-participant', "I'm in")}</option>
|
|
460
|
+
</select>
|
|
461
|
+
<select aria-label=${t('filter-visibility', 'Visibility')} .value=${this.visibility}
|
|
462
|
+
@change=${(e) => this.refilter(() => (this.visibility = e.target.value))}>
|
|
463
|
+
<option value="all">${t('filter-any-visibility', 'Public and private')}</option>
|
|
464
|
+
<option value="open">${t('filter-open', 'Public')}</option>
|
|
465
|
+
<option value="private">${t('filter-private', 'Private')}</option>
|
|
466
|
+
</select>
|
|
467
|
+
<label><input type="checkbox" .checked=${this.unreadOnly}
|
|
468
|
+
@change=${(e) => this.refilter(() => (this.unreadOnly = e.target.checked))} />${t('filter-unread', 'Unread')}</label>
|
|
469
|
+
<label><input type="checkbox" .checked=${this.includeHidden}
|
|
470
|
+
@change=${(e) => this.refilter(() => (this.includeHidden = e.target.checked))} />${t('filter-hidden', 'Including hidden')}</label>
|
|
471
|
+
</div>
|
|
472
|
+
<div class="list">
|
|
473
|
+
${this.error ? html `<div class="note" role="alert">${this.error}</div>` : nothing}
|
|
474
|
+
${shown === 0 && !this.loading
|
|
475
|
+
? html `<div class="empty">${this.search ? t('no-match', 'No conversation matches "{q}".', { q: this.search }) : t('none', 'No conversations yet.')}</div>`
|
|
476
|
+
: this.entries.map(entry => this.renderRow(entry))}
|
|
477
|
+
${shown < this.total
|
|
478
|
+
? html `<button class="more" @click=${() => this.loadMore()}>${t('load-more', 'Show more ({rest})', { rest: this.total - shown })}</button>`
|
|
479
|
+
: nothing}
|
|
480
|
+
</div>
|
|
481
|
+
<!-- A hidden conversation must not be forgotten: say how many, and one press shows them. -->
|
|
482
|
+
${this.hiddenCount > 0 && !this.includeHidden
|
|
483
|
+
? html `<button class="hiddenfilter" @click=${() => this.refilter(() => (this.includeHidden = true))}>
|
|
484
|
+
<md-icon>visibility_off</md-icon>${t('hidden-count', '{count} hidden', { count: this.hiddenCount })}
|
|
485
|
+
</button>`
|
|
486
|
+
: nothing}
|
|
487
|
+
`;
|
|
488
|
+
}
|
|
489
|
+
renderRow(entry) {
|
|
490
|
+
const name = entry.name || t('untitled', 'Untitled conversation');
|
|
491
|
+
const actions = sessionActions(entry);
|
|
492
|
+
const isPrivate = entry.visibility === 'private';
|
|
493
|
+
if (this.renamingId === entry.id) {
|
|
494
|
+
return html `<div class="row">
|
|
495
|
+
<span class="dot"></span>
|
|
496
|
+
<input
|
|
497
|
+
class="rename"
|
|
498
|
+
.value=${entry.name || ''}
|
|
499
|
+
aria-label=${t('rename', 'Rename')}
|
|
500
|
+
@keydown=${(e) => {
|
|
501
|
+
if (e.key === 'Enter')
|
|
502
|
+
this.rename(entry, e.target.value);
|
|
503
|
+
if (e.key === 'Escape')
|
|
504
|
+
this.renamingId = '';
|
|
505
|
+
}}
|
|
506
|
+
@blur=${(e) => this.rename(entry, e.target.value)}
|
|
507
|
+
/>
|
|
508
|
+
</div>`;
|
|
509
|
+
}
|
|
510
|
+
return html `<div
|
|
511
|
+
class="row ${entry.unread ? 'unread' : ''} ${entry.hidden ? 'hidden' : ''} ${entry.id === this.sessionId ? 'current' : ''}"
|
|
512
|
+
@click=${() => this.emit('assistant-session-select', { sessionId: entry.id, kind: entry.kind })}
|
|
513
|
+
>
|
|
514
|
+
<span class="dot"></span>
|
|
515
|
+
<md-icon title=${isPrivate ? t('private', 'Private - only its participants read it') : t('open', 'Public - everyone in this domain reads it')}
|
|
516
|
+
>${isPrivate ? 'lock' : 'public'}</md-icon
|
|
517
|
+
>
|
|
518
|
+
<span class="body">
|
|
519
|
+
<div class="title" @dblclick=${(e) => { e.stopPropagation(); if (actions.rename)
|
|
520
|
+
this.renamingId = entry.id; }}>${name}</div>
|
|
521
|
+
<div class="prev">${this.allKinds && entry.kind ? html `<span class="kind">${this.kindLabels[entry.kind] || entry.kind}</span> · ` : nothing}${entry.lastMessagePreview || ''}</div>
|
|
522
|
+
</span>
|
|
523
|
+
<span class="acts" @click=${(e) => e.stopPropagation()}>
|
|
524
|
+
${actions.rename
|
|
525
|
+
? html `<button class="icon" title=${t('rename', 'Rename')} aria-label=${t('rename', 'Rename')} @click=${() => (this.renamingId = entry.id)}>
|
|
526
|
+
<md-icon>edit</md-icon>
|
|
527
|
+
</button>`
|
|
528
|
+
: nothing}
|
|
529
|
+
${actions.setVisibility
|
|
530
|
+
? isPrivate
|
|
531
|
+
? html `<button class="icon" title=${t('make-open', 'Make public')} aria-label=${t('make-open', 'Make public')}
|
|
532
|
+
@click=${() => this.askOpen(entry, name)}><md-icon>public</md-icon></button>`
|
|
533
|
+
: html `<button class="icon" title=${t('make-private', 'Make private')} aria-label=${t('make-private', 'Make private')}
|
|
534
|
+
@click=${() => this.setVisibility(entry, 'private')}><md-icon>lock</md-icon></button>`
|
|
535
|
+
: nothing}
|
|
536
|
+
<button
|
|
537
|
+
class="icon"
|
|
538
|
+
title=${actions.unhide ? t('unhide', 'Show in my list') : t('hide', 'Hide from my list')}
|
|
539
|
+
aria-label=${actions.unhide ? t('unhide', 'Show in my list') : t('hide', 'Hide from my list')}
|
|
540
|
+
@click=${() => this.setHidden(entry, !entry.hidden)}
|
|
541
|
+
>
|
|
542
|
+
<md-icon>${actions.unhide ? 'visibility' : 'visibility_off'}</md-icon>
|
|
543
|
+
</button>
|
|
544
|
+
${actions.remove
|
|
545
|
+
? html `<button class="icon danger" title=${t('remove', 'Delete')} aria-label=${t('remove', 'Delete')}
|
|
546
|
+
@click=${() => this.askRemove(entry, name)}><md-icon>delete</md-icon></button>`
|
|
547
|
+
: nothing}
|
|
548
|
+
</span>
|
|
549
|
+
</div>`;
|
|
550
|
+
}
|
|
551
|
+
/** Before what cannot be taken back - the platform's confirm, [Cancel][OK] (decided 2026-09-25, §7-3). */
|
|
552
|
+
async ask(title, text, confirmText) {
|
|
553
|
+
return !!(await OxPrompt.open({
|
|
554
|
+
type: 'warning',
|
|
555
|
+
title,
|
|
556
|
+
text,
|
|
557
|
+
confirmButton: { text: confirmText },
|
|
558
|
+
cancelButton: { text: t('cancel', 'Cancel') }
|
|
559
|
+
}));
|
|
560
|
+
}
|
|
561
|
+
async askRemove(entry, name) {
|
|
562
|
+
const ok = await this.ask(t('remove', 'Delete'), t('confirm-remove', 'Delete "{name}"? It disappears for every participant and cannot be brought back.', { name }), t('remove', 'Delete'));
|
|
563
|
+
if (ok)
|
|
564
|
+
this._removeSession(entry);
|
|
565
|
+
}
|
|
566
|
+
async askOpen(entry, name) {
|
|
567
|
+
const ok = await this.ask(t('make-open', 'Make public'), t('confirm-open', 'Make "{name}" public? Everyone in this domain will be able to read what is already written.', { name }), t('make-open', 'Make public'));
|
|
568
|
+
if (ok)
|
|
569
|
+
this.setVisibility(entry, 'open');
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
__decorate([
|
|
573
|
+
property({ type: String }),
|
|
574
|
+
__metadata("design:type", Object)
|
|
575
|
+
], AssistantSessionManager.prototype, "anchorType", void 0);
|
|
576
|
+
__decorate([
|
|
577
|
+
property({ type: String }),
|
|
578
|
+
__metadata("design:type", Object)
|
|
579
|
+
], AssistantSessionManager.prototype, "anchorId", void 0);
|
|
580
|
+
__decorate([
|
|
581
|
+
property({ type: String }),
|
|
582
|
+
__metadata("design:type", Object)
|
|
583
|
+
], AssistantSessionManager.prototype, "sessionId", void 0);
|
|
584
|
+
__decorate([
|
|
585
|
+
property({ attribute: false }),
|
|
586
|
+
__metadata("design:type", Object)
|
|
587
|
+
], AssistantSessionManager.prototype, "admin", void 0);
|
|
588
|
+
__decorate([
|
|
589
|
+
property({ type: String }),
|
|
590
|
+
__metadata("design:type", Object)
|
|
591
|
+
], AssistantSessionManager.prototype, "kind", void 0);
|
|
592
|
+
__decorate([
|
|
593
|
+
property({ attribute: false }),
|
|
594
|
+
__metadata("design:type", Object)
|
|
595
|
+
], AssistantSessionManager.prototype, "kindLabels", void 0);
|
|
596
|
+
__decorate([
|
|
597
|
+
state(),
|
|
598
|
+
__metadata("design:type", Array)
|
|
599
|
+
], AssistantSessionManager.prototype, "entries", void 0);
|
|
600
|
+
__decorate([
|
|
601
|
+
state(),
|
|
602
|
+
__metadata("design:type", Object)
|
|
603
|
+
], AssistantSessionManager.prototype, "total", void 0);
|
|
604
|
+
__decorate([
|
|
605
|
+
state(),
|
|
606
|
+
__metadata("design:type", Object)
|
|
607
|
+
], AssistantSessionManager.prototype, "hiddenCount", void 0);
|
|
608
|
+
__decorate([
|
|
609
|
+
state(),
|
|
610
|
+
__metadata("design:type", Object)
|
|
611
|
+
], AssistantSessionManager.prototype, "search", void 0);
|
|
612
|
+
__decorate([
|
|
613
|
+
state(),
|
|
614
|
+
__metadata("design:type", Object)
|
|
615
|
+
], AssistantSessionManager.prototype, "allKinds", void 0);
|
|
616
|
+
__decorate([
|
|
617
|
+
state(),
|
|
618
|
+
__metadata("design:type", Object)
|
|
619
|
+
], AssistantSessionManager.prototype, "whose", void 0);
|
|
620
|
+
__decorate([
|
|
621
|
+
state(),
|
|
622
|
+
__metadata("design:type", Object)
|
|
623
|
+
], AssistantSessionManager.prototype, "visibility", void 0);
|
|
624
|
+
__decorate([
|
|
625
|
+
state(),
|
|
626
|
+
__metadata("design:type", Object)
|
|
627
|
+
], AssistantSessionManager.prototype, "includeHidden", void 0);
|
|
628
|
+
__decorate([
|
|
629
|
+
state(),
|
|
630
|
+
__metadata("design:type", Object)
|
|
631
|
+
], AssistantSessionManager.prototype, "unreadOnly", void 0);
|
|
632
|
+
__decorate([
|
|
633
|
+
state(),
|
|
634
|
+
__metadata("design:type", Object)
|
|
635
|
+
], AssistantSessionManager.prototype, "pageSize", void 0);
|
|
636
|
+
__decorate([
|
|
637
|
+
state(),
|
|
638
|
+
__metadata("design:type", Object)
|
|
639
|
+
], AssistantSessionManager.prototype, "loading", void 0);
|
|
640
|
+
__decorate([
|
|
641
|
+
state(),
|
|
642
|
+
__metadata("design:type", Object)
|
|
643
|
+
], AssistantSessionManager.prototype, "error", void 0);
|
|
644
|
+
__decorate([
|
|
645
|
+
state(),
|
|
646
|
+
__metadata("design:type", Object)
|
|
647
|
+
], AssistantSessionManager.prototype, "renamingId", void 0);
|
|
648
|
+
AssistantSessionManager = __decorate([
|
|
649
|
+
customElement('ox-assistant-session-manager')
|
|
650
|
+
], AssistantSessionManager);
|
|
651
|
+
export { AssistantSessionManager };
|
|
652
|
+
//# sourceMappingURL=assistant-session-manager.js.map
|