@things-factory/ai-assistant 10.1.270 → 10.1.272
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 +18 -6
- package/client/components/assistant-dock.ts +15 -1
- package/client/components/proposal-request.test.ts +12 -1
- package/client/setup-assistant-dock.ts +30 -15
- package/client/utils/addressed-draft.test.ts +31 -0
- package/client/utils/assistant-ask.ts +7 -0
- package/client/utils/assistant-request-context.ts +10 -0
- package/dist-client/components/assistant-chat.d.ts +6 -0
- package/dist-client/components/assistant-chat.js +23 -6
- package/dist-client/components/assistant-chat.js.map +1 -1
- package/dist-client/components/assistant-dock.js +15 -0
- package/dist-client/components/assistant-dock.js.map +1 -1
- package/dist-client/components/proposal-request.test.js +11 -1
- package/dist-client/components/proposal-request.test.js.map +1 -1
- package/dist-client/setup-assistant-dock.js +30 -15
- package/dist-client/setup-assistant-dock.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/addressed-draft.test.d.ts +1 -0
- package/dist-client/utils/addressed-draft.test.js +27 -0
- package/dist-client/utils/addressed-draft.test.js.map +1 -0
- package/dist-client/utils/assistant-ask.d.ts +10 -0
- package/dist-client/utils/assistant-ask.js.map +1 -1
- package/dist-client/utils/assistant-request-context.d.ts +12 -0
- package/dist-client/utils/assistant-request-context.js +11 -0
- package/dist-client/utils/assistant-request-context.js.map +1 -1
- package/dist-server/service/assistant-chat-resolver.js +5 -2
- package/dist-server/service/assistant-chat-resolver.js.map +1 -1
- package/dist-server/service/assistant-mode/index.d.ts +1 -0
- package/dist-server/service/assistant-mode/index.js +4 -1
- package/dist-server/service/assistant-mode/index.js.map +1 -1
- package/dist-server/service/assistant-mode/turn-lines.d.ts +12 -0
- package/dist-server/service/assistant-mode/turn-lines.js +38 -0
- package/dist-server/service/assistant-mode/turn-lines.js.map +1 -0
- package/dist-server/service/chat-message/index.d.ts +1 -0
- package/dist-server/service/chat-message/index.js +3 -1
- package/dist-server/service/chat-message/index.js.map +1 -1
- package/dist-server/service/chat-message/room-turn.d.ts +31 -0
- package/dist-server/service/chat-message/room-turn.js +30 -0
- package/dist-server/service/chat-message/room-turn.js.map +1 -0
- package/dist-server/service/chat-session-participant/invite-notification.d.ts +20 -4
- package/dist-server/service/chat-session-participant/invite-notification.js +17 -12
- package/dist-server/service/chat-session-participant/invite-notification.js.map +1 -1
- package/dist-server/service/chat-session-participant/mention-invite.d.ts +2 -0
- package/dist-server/service/chat-session-participant/mention-invite.js +5 -0
- package/dist-server/service/chat-session-participant/mention-invite.js.map +1 -1
- package/dist-server/service/chat-session-resolver.d.ts +5 -0
- package/dist-server/service/chat-session-resolver.js +56 -3
- package/dist-server/service/chat-session-resolver.js.map +1 -1
- package/dist-server/service/data-entry/entry-apply.d.ts +2 -0
- package/dist-server/service/data-entry/entry-apply.js +1 -1
- package/dist-server/service/data-entry/entry-apply.js.map +1 -1
- package/dist-server/service/data-entry/entry-resolver.js +2 -1
- package/dist-server/service/data-entry/entry-resolver.js.map +1 -1
- package/dist-server/service/data-entry/entry-target.d.ts +7 -2
- package/dist-server/service/data-entry/entry-target.js.map +1 -1
- package/dist-server/service/people/index.d.ts +2 -0
- package/dist-server/service/people/index.js +9 -1
- package/dist-server/service/people/index.js.map +1 -1
- package/dist-server/service/people/person-subject.d.ts +34 -0
- package/dist-server/service/people/person-subject.js +89 -0
- package/dist-server/service/people/person-subject.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/server/service/assistant-chat-resolver.ts +5 -2
- package/server/service/assistant-mode/index.ts +1 -0
- package/server/service/assistant-mode/open-subject-door.test.ts +7 -2
- package/server/service/assistant-mode/turn-lines.ts +43 -0
- package/server/service/chat-message/index.ts +1 -0
- package/server/service/chat-message/room-turn.ts +42 -0
- package/server/service/chat-session/group-room.test.ts +4 -4
- package/server/service/chat-session-participant/invite-notification.test.ts +12 -12
- package/server/service/chat-session-participant/invite-notification.ts +25 -11
- package/server/service/chat-session-participant/mention-invite.ts +5 -0
- package/server/service/chat-session-resolver.ts +50 -3
- package/server/service/data-entry/entry-apply.ts +3 -1
- package/server/service/data-entry/entry-resolver.ts +2 -1
- package/server/service/data-entry/entry-target.ts +5 -2
- package/server/service/people/index.ts +2 -0
- package/server/service/people/person-subject.test.ts +163 -0
- package/server/service/people/person-subject.ts +88 -0
- package/test/assistant-request-context.test.ts +1 -1
- package/test/open-doors.test.ts +3 -1
- package/translations/en.json +2 -0
- package/translations/es.json +2 -0
- package/translations/ja.json +2 -0
- package/translations/ko.json +2 -0
- package/translations/ms.json +2 -0
- package/translations/zh.json +2 -0
|
@@ -22,7 +22,7 @@ import { noteForDisplay } from '../utils/assistant-selection.js'
|
|
|
22
22
|
*/
|
|
23
23
|
import '@material/web/icon/icon.js'
|
|
24
24
|
import './assistant-session-toolbar.js'
|
|
25
|
-
import { assistantAutoAskKey, assistantDraftDecision, assistantModelFingerprint, type AssistantRequestContext } from '../utils/assistant-request-context.js'
|
|
25
|
+
import { addressedDraft, assistantAutoAskKey, assistantDraftDecision, assistantModelFingerprint, type AssistantRequestContext } from '../utils/assistant-request-context.js'
|
|
26
26
|
|
|
27
27
|
import { LitElement, css, html, nothing } from 'lit'
|
|
28
28
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
@@ -346,6 +346,7 @@ const CHAT_MESSAGE_SUBSCRIPTION = gql`
|
|
|
346
346
|
const CHAT_PARTICIPANTS_QUERY = gql`
|
|
347
347
|
query ChatSessionParticipants($sessionId: String!) {
|
|
348
348
|
mayInviteToAISession(sessionId: $sessionId)
|
|
349
|
+
keptInAISession(sessionId: $sessionId)
|
|
349
350
|
chatSessionParticipants(sessionId: $sessionId) {
|
|
350
351
|
id
|
|
351
352
|
role
|
|
@@ -600,6 +601,8 @@ export class OxAssistantChat extends LitElement {
|
|
|
600
601
|
@property({ attribute: false })
|
|
601
602
|
draft?: string
|
|
602
603
|
@property() draftRequestId?: string
|
|
604
|
+
/** Whom the draft is said to - a person of the conversation; sending it goes to the room (`addressedDraft`). */
|
|
605
|
+
@property({ attribute: false }) draftTo?: { id: string; name: string }
|
|
603
606
|
@property({ attribute: false }) contextProvider?: () => AssistantRequestContext
|
|
604
607
|
|
|
605
608
|
/**
|
|
@@ -1071,6 +1074,8 @@ export class OxAssistantChat extends LitElement {
|
|
|
1071
1074
|
@state() private rosterLoaded = false
|
|
1072
1075
|
/** May I bring someone in here - the server's answer (`mayInviteToAISession`); unknown until the roster is read. */
|
|
1073
1076
|
@state() private mayInvite?: boolean
|
|
1077
|
+
/* The person a conversation is about - always in it, so no button sends them out (ADR-0200). */
|
|
1078
|
+
@state() private keptUserId?: string
|
|
1074
1079
|
/** The name box under the roster is open. */
|
|
1075
1080
|
@state() private inviting = false
|
|
1076
1081
|
/** Who is typing now, by name - kept by `typingRoom`, redrawn on each notice and as they fade. */
|
|
@@ -3114,6 +3119,7 @@ export class OxAssistantChat extends LitElement {
|
|
|
3114
3119
|
this.participants = []
|
|
3115
3120
|
this.rosterLoaded = false
|
|
3116
3121
|
this.mayInvite = undefined
|
|
3122
|
+
this.keptUserId = undefined
|
|
3117
3123
|
this.inviting = false
|
|
3118
3124
|
this.typingRoom.clear()
|
|
3119
3125
|
this.typingNames = []
|
|
@@ -3135,9 +3141,13 @@ export class OxAssistantChat extends LitElement {
|
|
|
3135
3141
|
void this.send()
|
|
3136
3142
|
}
|
|
3137
3143
|
|
|
3138
|
-
/*
|
|
3144
|
+
/*
|
|
3145
|
+
* A draft fills the input and waits for the person — it is never sent from here. One said to a person carries their
|
|
3146
|
+
* name as a mention, so it goes to the room; an empty one still puts the name in the input (`addressedDraft`).
|
|
3147
|
+
*/
|
|
3148
|
+
const addressed = this.draft || this.draftTo ? addressedDraft(this.draft ?? '', this.draftTo) : undefined
|
|
3139
3149
|
const draft = assistantDraftDecision({
|
|
3140
|
-
draft:
|
|
3150
|
+
draft: addressed?.input,
|
|
3141
3151
|
draftRequestId: this.draftRequestId,
|
|
3142
3152
|
drafted: this._drafted,
|
|
3143
3153
|
typed: this.input,
|
|
@@ -3145,8 +3155,9 @@ export class OxAssistantChat extends LitElement {
|
|
|
3145
3155
|
autoAskRequestId: this.autoAskRequestId
|
|
3146
3156
|
})
|
|
3147
3157
|
if (draft.consumed) this._drafted = draft.consumed
|
|
3148
|
-
if (draft.fill) {
|
|
3149
|
-
|
|
3158
|
+
if (draft.fill && addressed) {
|
|
3159
|
+
if (addressed.mention) this.pickedUserMentions.set(...addressed.mention)
|
|
3160
|
+
this.input = addressed.input
|
|
3150
3161
|
this.updateComplete.then(() => (this.renderRoot.querySelector('textarea') as HTMLTextAreaElement | null)?.focus())
|
|
3151
3162
|
}
|
|
3152
3163
|
|
|
@@ -3291,6 +3302,7 @@ export class OxAssistantChat extends LitElement {
|
|
|
3291
3302
|
if (this.sessionId !== sessionId) return
|
|
3292
3303
|
this.participants=result.data?.chatSessionParticipants??[]
|
|
3293
3304
|
this.mayInvite=result.data?.mayInviteToAISession === true
|
|
3305
|
+
this.keptUserId = result.data?.keptInAISession ?? undefined
|
|
3294
3306
|
this.rosterLoaded=true
|
|
3295
3307
|
} catch {
|
|
3296
3308
|
if (this.sessionId === sessionId) this.rosterLoaded=false
|
|
@@ -4291,7 +4303,7 @@ export class OxAssistantChat extends LitElement {
|
|
|
4291
4303
|
${this.participants.map(p => {
|
|
4292
4304
|
const name = rosterName(p,String(i18next.t('ai-assistant.text.participant-unavailable')))
|
|
4293
4305
|
const on = this._isOnline(p.lastSeenAt)
|
|
4294
|
-
const removable = iOwn && p.role === 'member' && !!p.user?.id
|
|
4306
|
+
const removable = iOwn && p.role === 'member' && !!p.user?.id && p.user.id !== this.keptUserId
|
|
4295
4307
|
return html`<span
|
|
4296
4308
|
class="roster-chip ${on ? 'online' : 'offline'}"
|
|
4297
4309
|
title=${[
|
|
@@ -314,7 +314,7 @@ export class AssistantDock extends localize(i18next)(LitElement) {
|
|
|
314
314
|
@state() private failure = ''
|
|
315
315
|
@state() private showingHistory = false
|
|
316
316
|
@state() private conversationView = 0
|
|
317
|
-
@state() private asking?: { ask?: string; draft?: string; requestId: string }
|
|
317
|
+
@state() private asking?: { ask?: string; draft?: string; to?: { id: string; name: string }; requestId: string }
|
|
318
318
|
private openedIdentity = ''
|
|
319
319
|
|
|
320
320
|
private app = new AppController(this)
|
|
@@ -608,6 +608,19 @@ export class AssistantDock extends localize(i18next)(LitElement) {
|
|
|
608
608
|
const ask: AssistantAsk | undefined = takeAssistantAsk()
|
|
609
609
|
if (!ask) return
|
|
610
610
|
|
|
611
|
+
/*
|
|
612
|
+
* A request for one conversation - a to-do that came from it (ADR-0200 decision 3). It is listed on its subject's
|
|
613
|
+
* screen; until the dock stands there the request waits, and the conversation is opened when it does.
|
|
614
|
+
*/
|
|
615
|
+
if (ask.sessionId) {
|
|
616
|
+
if (!this.sessions.some(one => one.id === ask.sessionId)) await this.reloadSessions()
|
|
617
|
+
if (!this.controller.select(ask.sessionId)) return holdAssistantAsk(ask)
|
|
618
|
+
this.conversationView++
|
|
619
|
+
this.asking = ask.ask || ask.draft || ask.to ? { ask: ask.ask, draft: ask.draft, to: ask.to, requestId: String(Date.now()) } : undefined
|
|
620
|
+
settleAssistantAsk(ask, { sent: true })
|
|
621
|
+
return
|
|
622
|
+
}
|
|
623
|
+
|
|
611
624
|
if (!ask.continueCurrent && (ask.name || ask.context || ask.transcript?.length)) {
|
|
612
625
|
const id = await this.startCarried(ask).catch(() => {
|
|
613
626
|
notify({ level: 'error', message: t('carry-failed', 'The selected context could not be attached. Nothing was sent. Try again from the original screen.') })
|
|
@@ -994,6 +1007,7 @@ export class AssistantDock extends localize(i18next)(LitElement) {
|
|
|
994
1007
|
.autoAsk=${this.asking?.ask}
|
|
995
1008
|
.autoAskRequestId=${this.asking?.requestId}
|
|
996
1009
|
.draft=${this.asking?.draft}
|
|
1010
|
+
.draftTo=${this.asking?.to}
|
|
997
1011
|
.draftRequestId=${this.asking?.requestId}
|
|
998
1012
|
@assistant-proposal-execute=${this.onProposal}
|
|
999
1013
|
@assistant-proposal-check=${this.onProposalCheck}
|
|
@@ -55,8 +55,19 @@ it('the chat reads stored proposals from history and from the broadcast', () =>
|
|
|
55
55
|
it('a failed page-context handoff never sends the request into the previous conversation', () => {
|
|
56
56
|
const take = body(dock, 'private async takeAsk()')
|
|
57
57
|
expect(take.indexOf('if (!id) return')).toBeGreaterThan(take.indexOf('await this.startCarried(ask)'))
|
|
58
|
-
expect(take.indexOf('if (!id) return')).toBeLessThan(take.indexOf('this.asking ='))
|
|
58
|
+
expect(take.indexOf('if (!id) return')).toBeLessThan(take.indexOf('this.asking =', take.indexOf('await this.startCarried(ask)')))
|
|
59
59
|
const carry = body(dock, 'private async startCarried(')
|
|
60
60
|
expect(carry).toContain('if (created.errors?.length) throw')
|
|
61
61
|
expect(carry).toContain('if (attached.errors?.length) throw')
|
|
62
62
|
})
|
|
63
|
+
|
|
64
|
+
it('a request for one conversation opens that one - waiting until the dock lists it, never a new conversation (ADR-0200)', () => {
|
|
65
|
+
const take = body(dock, 'private async takeAsk()')
|
|
66
|
+
const branch = take.slice(take.indexOf('if (ask.sessionId) {'), take.indexOf('if (!ask.continueCurrent'))
|
|
67
|
+
expect(branch).toContain('await this.reloadSessions()')
|
|
68
|
+
expect(branch).toContain('if (!this.controller.select(ask.sessionId)) return holdAssistantAsk(ask)')
|
|
69
|
+
expect(branch).toContain('settleAssistantAsk(ask, { sent: true })')
|
|
70
|
+
expect(branch).not.toContain('newConversation')
|
|
71
|
+
expect(branch).not.toContain('startCarried')
|
|
72
|
+
expect(take.indexOf('if (ask.sessionId) {')).toBeLessThan(take.indexOf('await this.startCarried(ask)'))
|
|
73
|
+
})
|
|
@@ -40,23 +40,32 @@ export class AssistantDockButton extends LitElement {
|
|
|
40
40
|
align-items: center;
|
|
41
41
|
justify-content: center;
|
|
42
42
|
gap: 6px;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
/* an icon alone: the band's 32px square (app-header-band .ctl.icon) */
|
|
44
|
+
height: 32px;
|
|
45
|
+
min-width: 32px;
|
|
46
|
+
padding: 0;
|
|
46
47
|
box-sizing: border-box;
|
|
47
|
-
|
|
48
|
-
border
|
|
49
|
-
|
|
48
|
+
/* the header band's control shape (apptool-ui app-header-band .ctl): no plate, no edge, a soft tint on hover */
|
|
49
|
+
border: 0;
|
|
50
|
+
border-radius: 999px;
|
|
51
|
+
background-color: transparent;
|
|
52
|
+
transition: background-color 120ms ease;
|
|
50
53
|
color: var(--md-sys-color-on-surface-variant);
|
|
51
54
|
font: inherit;
|
|
52
55
|
cursor: pointer;
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
button:hover {
|
|
56
|
-
|
|
59
|
+
background-color: var(--header-band-control-hover, color-mix(in srgb, var(--md-sys-color-on-surface) 7%, transparent));
|
|
57
60
|
color: var(--md-sys-color-primary);
|
|
58
61
|
}
|
|
59
62
|
|
|
63
|
+
/* The count hangs on the icon's top right, as the bell's does. */
|
|
64
|
+
.icon-with-count {
|
|
65
|
+
position: relative;
|
|
66
|
+
display: inline-flex;
|
|
67
|
+
}
|
|
68
|
+
|
|
60
69
|
button:focus-visible {
|
|
61
70
|
outline: 2px solid var(--md-sys-color-primary);
|
|
62
71
|
outline-offset: 2px;
|
|
@@ -70,16 +79,20 @@ export class AssistantDockButton extends LitElement {
|
|
|
70
79
|
}
|
|
71
80
|
|
|
72
81
|
.count {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
position: absolute;
|
|
83
|
+
top: -6px;
|
|
84
|
+
left: 10px;
|
|
85
|
+
min-width: 14px;
|
|
86
|
+
height: 14px;
|
|
87
|
+
padding: 0 3px;
|
|
76
88
|
box-sizing: border-box;
|
|
77
|
-
border-radius:
|
|
89
|
+
border-radius: 7px;
|
|
90
|
+
box-shadow: 0 0 0 1.5px var(--header-band-surface, var(--md-sys-color-surface-container-lowest, var(--md-sys-color-surface)));
|
|
78
91
|
background-color: var(--header-band-count-background, var(--md-sys-color-error));
|
|
79
92
|
color: var(--header-band-count-color, var(--md-sys-color-on-error));
|
|
80
|
-
font-size:
|
|
93
|
+
font-size: 9.5px;
|
|
81
94
|
font-weight: 700;
|
|
82
|
-
line-height:
|
|
95
|
+
line-height: 14px;
|
|
83
96
|
text-align: center;
|
|
84
97
|
}
|
|
85
98
|
`
|
|
@@ -108,8 +121,10 @@ export class AssistantDockButton extends LitElement {
|
|
|
108
121
|
const label = i18next.t('ai-assistant.dock.open', { defaultValue: 'Ask AI' })
|
|
109
122
|
return html`
|
|
110
123
|
<button title=${label} aria-label=${label} @click=${() => openOverlay(this.viewpart, { backdrop: false })}>
|
|
111
|
-
<
|
|
112
|
-
|
|
124
|
+
<span class="icon-with-count">
|
|
125
|
+
<md-icon aria-hidden="true">forum</md-icon>
|
|
126
|
+
${this.unread ? html`<span class="count">${this.unread > 99 ? '99+' : this.unread}</span>` : nothing}
|
|
127
|
+
</span>
|
|
113
128
|
</button>
|
|
114
129
|
`
|
|
115
130
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* A draft said to a person (ADR-0200 decision 3) - the answer to a question handed on goes to the one who asked, through
|
|
3
|
+
* the room. Sent to the assistant it reached nobody and the to-do stayed open (2026-11-12, :4730).
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync } from 'fs'
|
|
6
|
+
import { join } from 'path'
|
|
7
|
+
|
|
8
|
+
import { addressedDraft } from './assistant-request-context'
|
|
9
|
+
|
|
10
|
+
describe('a draft said to someone', () => {
|
|
11
|
+
it('★ carries their name as a mention, so sending it goes to the people of the conversation', () => {
|
|
12
|
+
expect(addressedDraft('금요일까지 가능합니다', { id: 'u-1', name: 'Admin' })).toEqual({ input: '@Admin 금요일까지 가능합니다 ', mention: ['Admin', 'u-1'] })
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('an empty draft still names them; a draft already naming them is left as it is', () => {
|
|
16
|
+
expect(addressedDraft('', { id: 'u-1', name: 'Admin' }).input).toBe('@Admin ')
|
|
17
|
+
expect(addressedDraft('@Admin 네', { id: 'u-1', name: 'Admin' }).input).toBe('@Admin 네')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('said to nobody, it is the draft as it was - for the assistant', () => {
|
|
21
|
+
expect(addressedDraft('정리해 줘')).toEqual({ input: '정리해 줘' })
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('★ the chat keeps the mention it puts in, and the dock hands the addressee on with the conversation', () => {
|
|
25
|
+
const chat = readFileSync(join(__dirname, '..', 'components', 'assistant-chat.ts'), 'utf8')
|
|
26
|
+
expect(chat).toMatch(/if \(addressed\.mention\) this\.pickedUserMentions\.set\(\.\.\.addressed\.mention\)/)
|
|
27
|
+
const dock = readFileSync(join(__dirname, '..', 'components', 'assistant-dock.ts'), 'utf8')
|
|
28
|
+
expect(dock).toMatch(/draft: ask\.draft, to: ask\.to, requestId/)
|
|
29
|
+
expect(dock).toMatch(/\.draftTo=\$\{this\.asking\?\.to\}/)
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -11,8 +11,15 @@ export interface AssistantAsk {
|
|
|
11
11
|
ask?: string
|
|
12
12
|
/** Put in the input, not sent. */
|
|
13
13
|
draft?: string
|
|
14
|
+
/** Whom the draft is said to - one of the people of the conversation, not the assistant (`addressedDraft`). */
|
|
15
|
+
to?: { id: string; name: string }
|
|
14
16
|
/** Ask in the open conversation instead of a new one. */
|
|
15
17
|
continueCurrent?: boolean
|
|
18
|
+
/**
|
|
19
|
+
* Open this conversation - one listed on the screen the dock stands on (a person's 360 for a question handed to them,
|
|
20
|
+
* ADR-0200). The request waits until the dock lists it.
|
|
21
|
+
*/
|
|
22
|
+
sessionId?: string
|
|
16
23
|
/** A new conversation's name. */
|
|
17
24
|
name?: string
|
|
18
25
|
/** Turns carried into the new conversation before the question. */
|
|
@@ -44,6 +44,16 @@ export function assistantDraftDecision(input: {
|
|
|
44
44
|
|
|
45
45
|
return { fill: true, consumed: key }
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* A draft said to a person, not to the assistant - `@name draft`, with the name kept as a mention so sending it goes to
|
|
49
|
+
* the people of the conversation. An answer to a question handed on is said to the one who asked (ADR-0200 decision 3):
|
|
50
|
+
* sent to the assistant, it reached nobody and the to-do stayed open (2026-11-12, :4730).
|
|
51
|
+
*/
|
|
52
|
+
export function addressedDraft(draft: string, to?: { id: string; name: string }): { input: string; mention?: [string, string] } {
|
|
53
|
+
if (!to?.id || !to.name) return { input: draft }
|
|
54
|
+
const said = `@${to.name}`
|
|
55
|
+
return { input: draft.startsWith(said) ? draft : `${said} ${draft.trim()}`.trimEnd() + ' ', mention: [to.name, to.id] }
|
|
56
|
+
}
|
|
47
57
|
export function assistantRecentSessions<T extends { id: string }>(sessions: T[], selected: string, limit: number): T[] {
|
|
48
58
|
const count = Math.max(1, Math.floor(limit) || 5)
|
|
49
59
|
const recent = sessions.slice(0, count)
|
|
@@ -187,6 +187,11 @@ export declare class OxAssistantChat extends LitElement {
|
|
|
187
187
|
*/
|
|
188
188
|
draft?: string;
|
|
189
189
|
draftRequestId?: string;
|
|
190
|
+
/** Whom the draft is said to - a person of the conversation; sending it goes to the room (`addressedDraft`). */
|
|
191
|
+
draftTo?: {
|
|
192
|
+
id: string;
|
|
193
|
+
name: string;
|
|
194
|
+
};
|
|
190
195
|
contextProvider?: () => AssistantRequestContext;
|
|
191
196
|
/**
|
|
192
197
|
* 빈 화면의 제목·부제 — **호스트가 자기 말로 준다.**
|
|
@@ -326,6 +331,7 @@ export declare class OxAssistantChat extends LitElement {
|
|
|
326
331
|
private rosterLoaded;
|
|
327
332
|
/** May I bring someone in here - the server's answer (`mayInviteToAISession`); unknown until the roster is read. */
|
|
328
333
|
private mayInvite?;
|
|
334
|
+
private keptUserId?;
|
|
329
335
|
/** The name box under the roster is open. */
|
|
330
336
|
private inviting;
|
|
331
337
|
/** Who is typing now, by name - kept by `typingRoom`, redrawn on each notice and as they fade. */
|
|
@@ -24,7 +24,7 @@ import { noteForDisplay } from '../utils/assistant-selection.js';
|
|
|
24
24
|
*/
|
|
25
25
|
import '@material/web/icon/icon.js';
|
|
26
26
|
import './assistant-session-toolbar.js';
|
|
27
|
-
import { assistantAutoAskKey, assistantDraftDecision, assistantModelFingerprint } from '../utils/assistant-request-context.js';
|
|
27
|
+
import { addressedDraft, assistantAutoAskKey, assistantDraftDecision, assistantModelFingerprint } from '../utils/assistant-request-context.js';
|
|
28
28
|
import { LitElement, css, html, nothing } from 'lit';
|
|
29
29
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
30
30
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
@@ -245,6 +245,7 @@ const CHAT_MESSAGE_SUBSCRIPTION = gql `
|
|
|
245
245
|
const CHAT_PARTICIPANTS_QUERY = gql `
|
|
246
246
|
query ChatSessionParticipants($sessionId: String!) {
|
|
247
247
|
mayInviteToAISession(sessionId: $sessionId)
|
|
248
|
+
keptInAISession(sessionId: $sessionId)
|
|
248
249
|
chatSessionParticipants(sessionId: $sessionId) {
|
|
249
250
|
id
|
|
250
251
|
role
|
|
@@ -2753,6 +2754,7 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
|
|
|
2753
2754
|
this.participants = [];
|
|
2754
2755
|
this.rosterLoaded = false;
|
|
2755
2756
|
this.mayInvite = undefined;
|
|
2757
|
+
this.keptUserId = undefined;
|
|
2756
2758
|
this.inviting = false;
|
|
2757
2759
|
this.typingRoom.clear();
|
|
2758
2760
|
this.typingNames = [];
|
|
@@ -2774,9 +2776,13 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
|
|
|
2774
2776
|
this.input = this.autoAsk;
|
|
2775
2777
|
void this.send();
|
|
2776
2778
|
}
|
|
2777
|
-
/*
|
|
2779
|
+
/*
|
|
2780
|
+
* A draft fills the input and waits for the person — it is never sent from here. One said to a person carries their
|
|
2781
|
+
* name as a mention, so it goes to the room; an empty one still puts the name in the input (`addressedDraft`).
|
|
2782
|
+
*/
|
|
2783
|
+
const addressed = this.draft || this.draftTo ? addressedDraft(this.draft ?? '', this.draftTo) : undefined;
|
|
2778
2784
|
const draft = assistantDraftDecision({
|
|
2779
|
-
draft:
|
|
2785
|
+
draft: addressed?.input,
|
|
2780
2786
|
draftRequestId: this.draftRequestId,
|
|
2781
2787
|
drafted: this._drafted,
|
|
2782
2788
|
typed: this.input,
|
|
@@ -2785,8 +2791,10 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
|
|
|
2785
2791
|
});
|
|
2786
2792
|
if (draft.consumed)
|
|
2787
2793
|
this._drafted = draft.consumed;
|
|
2788
|
-
if (draft.fill) {
|
|
2789
|
-
|
|
2794
|
+
if (draft.fill && addressed) {
|
|
2795
|
+
if (addressed.mention)
|
|
2796
|
+
this.pickedUserMentions.set(...addressed.mention);
|
|
2797
|
+
this.input = addressed.input;
|
|
2790
2798
|
this.updateComplete.then(() => this.renderRoot.querySelector('textarea')?.focus());
|
|
2791
2799
|
}
|
|
2792
2800
|
// 자동 스크롤
|
|
@@ -2930,6 +2938,7 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
|
|
|
2930
2938
|
return;
|
|
2931
2939
|
this.participants = result.data?.chatSessionParticipants ?? [];
|
|
2932
2940
|
this.mayInvite = result.data?.mayInviteToAISession === true;
|
|
2941
|
+
this.keptUserId = result.data?.keptInAISession ?? undefined;
|
|
2933
2942
|
this.rosterLoaded = true;
|
|
2934
2943
|
}
|
|
2935
2944
|
catch {
|
|
@@ -3874,7 +3883,7 @@ let OxAssistantChat = class OxAssistantChat extends LitElement {
|
|
|
3874
3883
|
${this.participants.map(p => {
|
|
3875
3884
|
const name = rosterName(p, String(i18next.t('ai-assistant.text.participant-unavailable')));
|
|
3876
3885
|
const on = this._isOnline(p.lastSeenAt);
|
|
3877
|
-
const removable = iOwn && p.role === 'member' && !!p.user?.id;
|
|
3886
|
+
const removable = iOwn && p.role === 'member' && !!p.user?.id && p.user.id !== this.keptUserId;
|
|
3878
3887
|
return html `<span
|
|
3879
3888
|
class="roster-chip ${on ? 'online' : 'offline'}"
|
|
3880
3889
|
title=${[
|
|
@@ -5181,6 +5190,10 @@ __decorate([
|
|
|
5181
5190
|
property(),
|
|
5182
5191
|
__metadata("design:type", String)
|
|
5183
5192
|
], OxAssistantChat.prototype, "draftRequestId", void 0);
|
|
5193
|
+
__decorate([
|
|
5194
|
+
property({ attribute: false }),
|
|
5195
|
+
__metadata("design:type", Object)
|
|
5196
|
+
], OxAssistantChat.prototype, "draftTo", void 0);
|
|
5184
5197
|
__decorate([
|
|
5185
5198
|
property({ attribute: false }),
|
|
5186
5199
|
__metadata("design:type", Function)
|
|
@@ -5273,6 +5286,10 @@ __decorate([
|
|
|
5273
5286
|
state(),
|
|
5274
5287
|
__metadata("design:type", Boolean)
|
|
5275
5288
|
], OxAssistantChat.prototype, "mayInvite", void 0);
|
|
5289
|
+
__decorate([
|
|
5290
|
+
state(),
|
|
5291
|
+
__metadata("design:type", String)
|
|
5292
|
+
], OxAssistantChat.prototype, "keptUserId", void 0);
|
|
5276
5293
|
__decorate([
|
|
5277
5294
|
state(),
|
|
5278
5295
|
__metadata("design:type", Object)
|