@things-factory/ai-assistant 10.1.27 → 10.1.29
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 +701 -63
- package/client/components/assistant-mode.test.ts +105 -55
- package/client/components/assistant-mode.ts +144 -82
- package/client/components/chat-echo-dedup.test.ts +23 -0
- package/client/components/chat-echo-dedup.ts +29 -3
- package/client/components/chat-input-builder.test.ts +20 -20
- package/client/components/chat-input-builder.ts +16 -14
- package/client/components/chat-proposal-survival.test.ts +73 -0
- package/client/components/mention-popup.ts +31 -8
- package/client/components/panel-aria.test.ts +54 -0
- package/client/components/proposal-outcome-line.ts +33 -0
- package/client/utils/assistant-session-controller.test.ts +75 -0
- package/client/utils/assistant-session-controller.ts +37 -1
- package/client/utils/assistant-session-transport.ts +13 -5
- package/dist-client/components/assistant-chat.d.ts +140 -13
- package/dist-client/components/assistant-chat.js +659 -71
- package/dist-client/components/assistant-chat.js.map +1 -1
- package/dist-client/components/assistant-mode.d.ts +102 -68
- package/dist-client/components/assistant-mode.js +79 -19
- package/dist-client/components/assistant-mode.js.map +1 -1
- package/dist-client/components/assistant-mode.test.js +90 -53
- package/dist-client/components/assistant-mode.test.js.map +1 -1
- package/dist-client/components/chat-echo-dedup.d.ts +2 -0
- package/dist-client/components/chat-echo-dedup.js +27 -4
- package/dist-client/components/chat-echo-dedup.js.map +1 -1
- package/dist-client/components/chat-echo-dedup.test.js +20 -0
- package/dist-client/components/chat-echo-dedup.test.js.map +1 -1
- package/dist-client/components/chat-input-builder.d.ts +12 -7
- package/dist-client/components/chat-input-builder.js +8 -10
- package/dist-client/components/chat-input-builder.js.map +1 -1
- package/dist-client/components/chat-input-builder.test.js +17 -18
- package/dist-client/components/chat-input-builder.test.js.map +1 -1
- package/dist-client/components/chat-proposal-survival.test.d.ts +1 -0
- package/dist-client/components/chat-proposal-survival.test.js +61 -0
- package/dist-client/components/chat-proposal-survival.test.js.map +1 -0
- package/dist-client/components/mention-popup.js +28 -8
- package/dist-client/components/mention-popup.js.map +1 -1
- package/dist-client/components/panel-aria.test.d.ts +1 -0
- package/dist-client/components/panel-aria.test.js +49 -0
- package/dist-client/components/panel-aria.test.js.map +1 -0
- package/dist-client/components/proposal-outcome-line.d.ts +9 -0
- package/dist-client/components/proposal-outcome-line.js +15 -0
- package/dist-client/components/proposal-outcome-line.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/assistant-session-controller.d.ts +20 -0
- package/dist-client/utils/assistant-session-controller.js +16 -0
- package/dist-client/utils/assistant-session-controller.js.map +1 -1
- package/dist-client/utils/assistant-session-controller.test.d.ts +1 -0
- package/dist-client/utils/assistant-session-controller.test.js +56 -0
- package/dist-client/utils/assistant-session-controller.test.js.map +1 -0
- package/dist-client/utils/assistant-session-transport.js +13 -5
- package/dist-client/utils/assistant-session-transport.js.map +1 -1
- package/dist-server/door-declaration-report.d.ts +14 -0
- package/dist-server/door-declaration-report.js +54 -0
- package/dist-server/door-declaration-report.js.map +1 -0
- package/dist-server/service/assistant-capability-resolver.d.ts +17 -0
- package/dist-server/service/assistant-capability-resolver.js +88 -0
- package/dist-server/service/assistant-capability-resolver.js.map +1 -0
- package/dist-server/service/assistant-chat-resolver.d.ts +6 -6
- package/dist-server/service/assistant-chat-resolver.js +185 -44
- package/dist-server/service/assistant-chat-resolver.js.map +1 -1
- package/dist-server/service/assistant-mode/assistant-mode-resolver.d.ts +33 -0
- package/dist-server/service/assistant-mode/assistant-mode-resolver.js +148 -0
- package/dist-server/service/assistant-mode/assistant-mode-resolver.js.map +1 -0
- package/dist-server/service/assistant-mode/index.d.ts +9 -0
- package/dist-server/service/assistant-mode/index.js +19 -0
- package/dist-server/service/assistant-mode/index.js.map +1 -0
- package/dist-server/service/assistant-mode/registry.d.ts +18 -0
- package/dist-server/service/assistant-mode/registry.js +136 -0
- package/dist-server/service/assistant-mode/registry.js.map +1 -0
- package/dist-server/service/assistant-mode/resolve.d.ts +43 -0
- package/dist-server/service/assistant-mode/resolve.js +65 -0
- package/dist-server/service/assistant-mode/resolve.js.map +1 -0
- package/dist-server/service/assistant-mode/types.d.ts +120 -0
- package/dist-server/service/assistant-mode/types.js +12 -0
- package/dist-server/service/assistant-mode/types.js.map +1 -0
- package/dist-server/service/chat-message/carried-turns.d.ts +48 -0
- package/dist-server/service/chat-message/carried-turns.js +92 -0
- package/dist-server/service/chat-message/carried-turns.js.map +1 -0
- package/dist-server/service/chat-message/chat-message-subscription.d.ts +1 -1
- package/dist-server/service/chat-message/chat-message-subscription.js +24 -6
- package/dist-server/service/chat-message/chat-message-subscription.js.map +1 -1
- package/dist-server/service/chat-message/chat-message.d.ts +32 -0
- package/dist-server/service/chat-message/chat-message.js +17 -0
- package/dist-server/service/chat-message/chat-message.js.map +1 -1
- package/dist-server/service/chat-message/door-access.d.ts +27 -0
- package/dist-server/service/chat-message/door-access.js +34 -0
- package/dist-server/service/chat-message/door-access.js.map +1 -0
- package/dist-server/service/chat-message/fold-session-history.d.ts +30 -0
- package/dist-server/service/chat-message/fold-session-history.js +133 -0
- package/dist-server/service/chat-message/fold-session-history.js.map +1 -0
- package/dist-server/service/chat-message/llm-history.d.ts +7 -0
- package/dist-server/service/chat-message/llm-history.js +23 -11
- package/dist-server/service/chat-message/llm-history.js.map +1 -1
- package/dist-server/service/chat-message/message-doors.d.ts +29 -0
- package/dist-server/service/chat-message/message-doors.js +107 -0
- package/dist-server/service/chat-message/message-doors.js.map +1 -0
- package/dist-server/service/chat-message/proposal-outcome.d.ts +18 -0
- package/dist-server/service/chat-message/proposal-outcome.js +31 -0
- package/dist-server/service/chat-message/proposal-outcome.js.map +1 -0
- package/dist-server/service/chat-message/reader-gate.d.ts +3 -0
- package/dist-server/service/chat-message/reader-gate.js +39 -0
- package/dist-server/service/chat-message/reader-gate.js.map +1 -0
- package/dist-server/service/chat-message/room-message.d.ts +4 -0
- package/dist-server/service/chat-message/room-message.js +25 -0
- package/dist-server/service/chat-message/room-message.js.map +1 -0
- package/dist-server/service/chat-session/chat-session.d.ts +36 -0
- package/dist-server/service/chat-session/chat-session.js +27 -2
- package/dist-server/service/chat-session/chat-session.js.map +1 -1
- package/dist-server/service/chat-session/session-anchor.d.ts +10 -1
- package/dist-server/service/chat-session/session-anchor.js +12 -4
- package/dist-server/service/chat-session/session-anchor.js.map +1 -1
- package/dist-server/service/chat-session/session-inbox.d.ts +6 -1
- package/dist-server/service/chat-session/session-inbox.js +3 -2
- package/dist-server/service/chat-session/session-inbox.js.map +1 -1
- package/dist-server/service/chat-session/session-kind.d.ts +14 -0
- package/dist-server/service/chat-session/session-kind.js +30 -0
- package/dist-server/service/chat-session/session-kind.js.map +1 -0
- package/dist-server/service/chat-session/session-visibility.d.ts +15 -0
- package/dist-server/service/chat-session/session-visibility.js +35 -0
- package/dist-server/service/chat-session/session-visibility.js.map +1 -0
- package/dist-server/service/chat-session/station-session-guard.d.ts +1 -5
- package/dist-server/service/chat-session/station-session-guard.js +7 -2
- package/dist-server/service/chat-session/station-session-guard.js.map +1 -1
- package/dist-server/service/chat-session-participant/mention-invite.d.ts +29 -0
- package/dist-server/service/chat-session-participant/mention-invite.js +103 -0
- package/dist-server/service/chat-session-participant/mention-invite.js.map +1 -0
- package/dist-server/service/chat-session-resolver.d.ts +17 -0
- package/dist-server/service/chat-session-resolver.js +271 -15
- package/dist-server/service/chat-session-resolver.js.map +1 -1
- package/dist-server/service/grounding-sources.d.ts +14 -0
- package/dist-server/service/grounding-sources.js +26 -0
- package/dist-server/service/grounding-sources.js.map +1 -0
- package/dist-server/service/index.d.ts +9 -1
- package/dist-server/service/index.js +21 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/request-translator.d.ts +2 -0
- package/dist-server/service/request-translator.js +20 -0
- package/dist-server/service/request-translator.js.map +1 -0
- package/dist-server/service/testing/conversation-script.d.ts +123 -0
- package/dist-server/service/testing/conversation-script.js +202 -0
- package/dist-server/service/testing/conversation-script.js.map +1 -0
- package/dist-server/service/testing/mode-conformance.d.ts +50 -0
- package/dist-server/service/testing/mode-conformance.js +103 -0
- package/dist-server/service/testing/mode-conformance.js.map +1 -0
- package/dist-server/tool-registry-boot-report.d.ts +3 -0
- package/dist-server/tool-registry-boot-report.js +32 -2
- package/dist-server/tool-registry-boot-report.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/server/door-declaration-report.test.ts +53 -0
- package/server/door-declaration-report.ts +61 -0
- package/server/explicit-graphql-types.test.ts +56 -0
- package/server/service/assistant-capability-resolver.ts +66 -0
- package/server/service/assistant-chat-resolver.ts +205 -42
- package/server/service/assistant-mode/assistant-mode-resolver.ts +108 -0
- package/server/service/assistant-mode/index.ts +16 -0
- package/server/service/assistant-mode/registry.test.ts +105 -0
- package/server/service/assistant-mode/registry.ts +147 -0
- package/server/service/assistant-mode/resolve.test.ts +120 -0
- package/server/service/assistant-mode/resolve.ts +105 -0
- package/server/service/assistant-mode/subject-defaults.test.ts +86 -0
- package/server/service/assistant-mode/types.ts +121 -0
- package/server/service/chat-message/carried-turns.test.ts +80 -0
- package/server/service/chat-message/carried-turns.ts +112 -0
- package/server/service/chat-message/chat-message-subscription.ts +20 -4
- package/server/service/chat-message/chat-message.ts +44 -0
- package/server/service/chat-message/door-access.test.ts +72 -0
- package/server/service/chat-message/door-access.ts +65 -0
- package/server/service/chat-message/fold-history-window.test.ts +184 -0
- package/server/service/chat-message/fold-session-history.test.ts +98 -0
- package/server/service/chat-message/fold-session-history.ts +115 -0
- package/server/service/chat-message/llm-history.test.ts +58 -7
- package/server/service/chat-message/llm-history.ts +30 -11
- package/server/service/chat-message/message-doors.test.ts +87 -0
- package/server/service/chat-message/message-doors.ts +117 -0
- package/server/service/chat-message/proposal-outcome.test.ts +48 -0
- package/server/service/chat-message/proposal-outcome.ts +42 -0
- package/server/service/chat-message/reader-gate.ts +44 -0
- package/server/service/chat-message/room-message.test.ts +21 -0
- package/server/service/chat-message/room-message.ts +22 -0
- package/server/service/chat-session/chat-session.ts +46 -1
- package/server/service/chat-session/session-anchor.ts +12 -3
- package/server/service/chat-session/session-inbox.test.ts +18 -0
- package/server/service/chat-session/session-inbox.ts +11 -2
- package/server/service/chat-session/session-kind.test.ts +24 -0
- package/server/service/chat-session/session-kind.ts +32 -0
- package/server/service/chat-session/session-visibility.test.ts +52 -0
- package/server/service/chat-session/session-visibility.ts +34 -0
- package/server/service/chat-session/station-session-guard.ts +10 -2
- package/server/service/chat-session-participant/mention-invite.test.ts +125 -0
- package/server/service/chat-session-participant/mention-invite.ts +121 -0
- package/server/service/chat-session-resolver.ts +276 -15
- package/server/service/grounding-sources.test.ts +55 -0
- package/server/service/grounding-sources.ts +46 -0
- package/server/service/index.ts +21 -0
- package/server/service/request-translator.test.ts +45 -0
- package/server/service/request-translator.ts +33 -0
- package/server/service/station-session-guard.test.ts +12 -5
- package/server/service/testing/conversation-scenario.test.ts +163 -0
- package/server/service/testing/conversation-script.test.ts +131 -0
- package/server/service/testing/conversation-script.ts +288 -0
- package/server/service/testing/mode-conformance.ts +122 -0
- package/server/tool-registry-boot-report.ts +31 -2
- package/test/assistant-chat-call-sites.test.ts +82 -0
- package/translations/en.json +46 -3
- package/translations/ja.json +46 -3
- package/translations/ko.json +46 -3
- package/translations/ms.json +46 -3
- package/translations/zh.json +46 -3
|
@@ -59,7 +59,8 @@ import {
|
|
|
59
59
|
* 뜨지 않는 것이 맞다.
|
|
60
60
|
*/
|
|
61
61
|
import { chatDefaults } from './chat-defaults.js'
|
|
62
|
-
import { isDifferentConversation, resolveConversation, type AssistantMode } from './assistant-mode.js'
|
|
62
|
+
import { isDifferentConversation, resolveConversation, type AssistantMode, type AssistantModeView, pickInitialMode } from './assistant-mode.js'
|
|
63
|
+
import { parseProposalOutcomeLine, type ParsedProposalOutcome } from './proposal-outcome-line.js'
|
|
63
64
|
import { availableTriggers, type TriggerChip } from './chat-triggers.js'
|
|
64
65
|
|
|
65
66
|
interface ChatLine {
|
|
@@ -80,6 +81,13 @@ interface ChatLine {
|
|
|
80
81
|
followUp?: string
|
|
81
82
|
patchId?: string
|
|
82
83
|
pending?: boolean
|
|
84
|
+
/**
|
|
85
|
+
* 서버가 이 사람에게 값을 안 내준 줄 — ADR-0073 판정 1.
|
|
86
|
+
*
|
|
87
|
+
* `content` 에 온 것은 「이 답은 <문> 권한이 필요합니다」 한 줄이다. 줄을 지우지 않는 이유는, 방에
|
|
88
|
+
* 무슨 일이 있었는지는 알 수 있어야 하기 때문이다. 값만 안 보인다.
|
|
89
|
+
*/
|
|
90
|
+
redacted?: boolean
|
|
83
91
|
/** AI 가 응답을 만드는 동안 호출한 도구 trace — fold-able 박스에서 노출. */
|
|
84
92
|
toolUsages?: Array<{
|
|
85
93
|
name: string
|
|
@@ -172,10 +180,82 @@ const ASSISTANT_CHAT_MUTATION = gql`
|
|
|
172
180
|
offeredTools
|
|
173
181
|
proposals
|
|
174
182
|
groundingWarnings
|
|
183
|
+
historyFolded
|
|
175
184
|
}
|
|
176
185
|
}
|
|
177
186
|
`
|
|
178
187
|
|
|
188
|
+
/*
|
|
189
|
+
* What this conversation offers on screen, in this person's language.
|
|
190
|
+
*
|
|
191
|
+
* The `/` sentences, the `@` catalog and the two notices are declared with the mode on the server
|
|
192
|
+
* (ADR-0061 decision 7) and translated there, so the panel and the door cannot describe different
|
|
193
|
+
* conversations, and a host does not carry a second copy of the words.
|
|
194
|
+
*/
|
|
195
|
+
/*
|
|
196
|
+
* 이 화면에 설 수 있는 대화들 — ADR-0072 A17 ①.
|
|
197
|
+
*
|
|
198
|
+
* 화면은 자기가 무엇을 보여 주는지만 말하고, 그 위에 어느 대화가 서는지는 앱 서버가 답한다.
|
|
199
|
+
*/
|
|
200
|
+
const ASSISTANT_MODES_QUERY = gql`
|
|
201
|
+
query AssistantModes($subject: String!) {
|
|
202
|
+
assistantModes(subject: $subject) {
|
|
203
|
+
kind
|
|
204
|
+
label
|
|
205
|
+
isDefault
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
`
|
|
209
|
+
|
|
210
|
+
const ASSISTANT_MODE_QUERY = gql`
|
|
211
|
+
query AssistantMode($kind: String!) {
|
|
212
|
+
assistantMode(kind: $kind) {
|
|
213
|
+
kind
|
|
214
|
+
slashTemplates {
|
|
215
|
+
name
|
|
216
|
+
description
|
|
217
|
+
template
|
|
218
|
+
}
|
|
219
|
+
catalogEntries
|
|
220
|
+
proposalChoices
|
|
221
|
+
placeholder
|
|
222
|
+
intro
|
|
223
|
+
examples
|
|
224
|
+
footerNotice
|
|
225
|
+
stagedNotice
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
`
|
|
229
|
+
|
|
230
|
+
/*
|
|
231
|
+
* 방에 말하는 문 — 사람에게 하는 말이고 모델을 부르지 않는다(ADR-0070 A15).
|
|
232
|
+
*
|
|
233
|
+
* 이 문이 서기 전에는 화면에서 나가는 모든 말이 어시스턴트를 향했다. 옆 사람에게 한마디 하려면
|
|
234
|
+
* 어시스턴트가 반드시 대답했고, 그 대답이 다시 대화에 남았다.
|
|
235
|
+
*/
|
|
236
|
+
/*
|
|
237
|
+
* `@` 가 고를 수 있는 사람들 — 이 도메인의 사용자.
|
|
238
|
+
*
|
|
239
|
+
* 호스트가 `userProvider` 를 주지 않으면 여기서 직접 묻는다. 주지 않는 것이 기본이었고, 그래서 앱 셋
|
|
240
|
+
* 어디에서도 `@이름` 을 **고를 수가 없었다** — 멘션이 사람을 불러들이는 기전(ADR-0071 결정 1)을 세워
|
|
241
|
+
* 놓고 부르는 자리가 없는 상태였다. 이 문은 `ai-assistant` 의 것이고 대화창이 그 문의 화면이다.
|
|
242
|
+
*/
|
|
243
|
+
const DOMAIN_USERS_FOR_MENTION_QUERY = gql`
|
|
244
|
+
query DomainUsersForMention($query: String) {
|
|
245
|
+
domainUsersForMention(query: $query) {
|
|
246
|
+
id
|
|
247
|
+
name
|
|
248
|
+
email
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
`
|
|
252
|
+
|
|
253
|
+
const SAY_TO_ROOM_MUTATION = gql`
|
|
254
|
+
mutation SayToRoom($sessionId: String!, $content: String!) {
|
|
255
|
+
sayToRoom(sessionId: $sessionId, content: $content)
|
|
256
|
+
}
|
|
257
|
+
`
|
|
258
|
+
|
|
179
259
|
const CHAT_MESSAGES_QUERY = gql`
|
|
180
260
|
query ChatMessages($sessionId: String!, $limit: Int, $offset: Int) {
|
|
181
261
|
chatMessages(sessionId: $sessionId, limit: $limit, offset: $offset) {
|
|
@@ -186,6 +266,7 @@ const CHAT_MESSAGES_QUERY = gql`
|
|
|
186
266
|
toolUsagesJson
|
|
187
267
|
groundingWarningsJson
|
|
188
268
|
createdAt
|
|
269
|
+
redacted
|
|
189
270
|
creator {
|
|
190
271
|
name
|
|
191
272
|
email
|
|
@@ -206,6 +287,7 @@ const CHAT_MESSAGE_SUBSCRIPTION = gql`
|
|
|
206
287
|
toolUsagesJson
|
|
207
288
|
groundingWarningsJson
|
|
208
289
|
createdAt
|
|
290
|
+
redacted
|
|
209
291
|
creator {
|
|
210
292
|
name
|
|
211
293
|
email
|
|
@@ -305,8 +387,10 @@ export class OxAssistantChat extends LitElement {
|
|
|
305
387
|
* `@` mention 도메인 사용자 공급자 (선택). 호스트가 `domainUsersForMention` query 로 wrap.
|
|
306
388
|
*
|
|
307
389
|
* 호스트는 query 문자열을 받아 도메인 사용자 후보 (id/name/email) 배열을 돌려준다.
|
|
308
|
-
*
|
|
309
|
-
*
|
|
390
|
+
*
|
|
391
|
+
* **미설정이면 대화창이 이 패키지의 문(`domainUsersForMention`)에 직접 묻는다.** 예전에는 빈
|
|
392
|
+
* 결과였고, 그래서 앱 셋에서는 `@이름` 을 고를 수 없었다 — 멘션이 사람을 불러들이는 길을 세워도
|
|
393
|
+
* 부르는 자리가 없었다. 자기 목록을 따로 쓰는 호스트만 이것을 준다.
|
|
310
394
|
*/
|
|
311
395
|
@property({ attribute: false })
|
|
312
396
|
userProvider?: (
|
|
@@ -352,34 +436,38 @@ export class OxAssistantChat extends LitElement {
|
|
|
352
436
|
* returns patches and scene actions
|
|
353
437
|
* assistantChat a surface with no document of its own — lives here, runs registered tools only
|
|
354
438
|
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
* chat calls a mutation that lives in a package it may not even load — which is how
|
|
360
|
-
* operato-figure got `Cannot query field "boardAIChat" on type "Mutation"` (2026-09-11).
|
|
439
|
+
* **There is no default** (ADR-0061 decision 7). It was `boardAIChat`, which meant a surface that
|
|
440
|
+
* said nothing talked to a package it may not even load — operato-figure got
|
|
441
|
+
* `Cannot query field "boardAIChat" on type "Mutation"` that way (2026-09-11). A surface that
|
|
442
|
+
* declares a mode talks to `assistantChat`; one that declares no mode names this itself.
|
|
361
443
|
*/
|
|
362
444
|
@property({ type: String, attribute: 'chat-endpoint' })
|
|
363
|
-
chatEndpoint
|
|
445
|
+
chatEndpoint?: 'boardAIChat' | 'assistantChat'
|
|
364
446
|
|
|
365
|
-
/**
|
|
366
|
-
* Who the assistant is on this surface, in the host's words. Required by `assistantChat`; the
|
|
367
|
-
* board conversation carries its own persona on the server and ignores this.
|
|
368
|
-
*/
|
|
369
447
|
/**
|
|
370
448
|
* What this conversation is — see `AssistantMode`.
|
|
371
449
|
*
|
|
372
|
-
* A host that sets this
|
|
373
|
-
*
|
|
374
|
-
*
|
|
450
|
+
* A host that sets this sets nothing else about the conversation: the persona, the tool
|
|
451
|
+
* categories, the model and the limits belong to the mode its app server registered, and what
|
|
452
|
+
* `@` and `/` offer comes from that same declaration, translated. They cannot disagree because
|
|
453
|
+
* there is one of them.
|
|
375
454
|
*
|
|
376
|
-
* When `
|
|
455
|
+
* When `kind` or `target` changes the conversation on screen is closed and a new one begins.
|
|
377
456
|
*/
|
|
378
457
|
@property({ attribute: false })
|
|
379
458
|
mode?: AssistantMode
|
|
380
459
|
|
|
381
|
-
|
|
382
|
-
|
|
460
|
+
/**
|
|
461
|
+
* 이 화면이 보여 주는 것의 **종류** — `'board'`, `'space'`, `'station'`, `'figure'` (ADR-0072 A17 ①).
|
|
462
|
+
*
|
|
463
|
+
* `mode` 가 「지금 어느 대화인가」라면 이것은 「그 자리에 어떤 대화들이 설 수 있나」이다. 서버가
|
|
464
|
+
* `assistantModes(subject)` 로 답하고, 둘 이상이면 고르개가 뜬다. 하나면 고르개를 내지 않는다 —
|
|
465
|
+
* 고를 것이 없는 고르개는 자리만 차지한다.
|
|
466
|
+
*
|
|
467
|
+
* 화면이 이것을 안 주면 고르개는 없고 host 가 정한 대화 하나만 산다. 그것이 오늘까지의 모양이다.
|
|
468
|
+
*/
|
|
469
|
+
@property({ type: String })
|
|
470
|
+
subject?: string
|
|
383
471
|
|
|
384
472
|
/**
|
|
385
473
|
* 라이브 상태를 다루는 대화면인가 — true 면 **첫 턴에 도구 호출을 강제**한다.
|
|
@@ -408,8 +496,10 @@ export class OxAssistantChat extends LitElement {
|
|
|
408
496
|
@property({ type: Array, attribute: false })
|
|
409
497
|
componentSchemas?: Array<{ type: string; description?: string; group?: string; properties?: Record<string, any> }>
|
|
410
498
|
|
|
499
|
+
/* No default here — the render falls back to `ai-assistant.text.input-placeholder`, which every locale has.
|
|
500
|
+
* A literal default is one language for every reader, and it hid the key that already existed. */
|
|
411
501
|
@property({ type: String })
|
|
412
|
-
placeholder
|
|
502
|
+
placeholder?: string
|
|
413
503
|
|
|
414
504
|
@state()
|
|
415
505
|
private lines: ChatLine[] = []
|
|
@@ -475,6 +565,22 @@ export class OxAssistantChat extends LitElement {
|
|
|
475
565
|
@state()
|
|
476
566
|
private dragOver = false
|
|
477
567
|
|
|
568
|
+
/*
|
|
569
|
+
* ── 왜 이미지만 받나 ──────────────────────────────────────────────────────
|
|
570
|
+
* `.json` · `.txt` · `.csv` 도 받고 있었다. 그 파일들은 `hostContext.attachments` 로 실려 갔고
|
|
571
|
+
* **그것을 읽어 모델에 붙이는 코드가 없었다.** 사람이 CSV 를 붙이고 「이 표 좀 봐줘」라고 하면 화면에
|
|
572
|
+
* 파일 칩이 뜨고 답도 왔다. 그 답은 파일을 본 적이 없고, 오류도 안 났다(2026-09-18 표면 조사).
|
|
573
|
+
*
|
|
574
|
+
* 이미지는 길이 있다 — `assistant-chat-resolver.ts` 가 `hostContext.image` 를 마지막 사람 턴에
|
|
575
|
+
* 붙인다. 그래서 되는 것만 남기고 좁혔다. 못 하는 일을 화면이 권하지 않는다.
|
|
576
|
+
*
|
|
577
|
+
* ── 글 파일을 청하는 제품이 설 때의 모양 (수석 아키텍트, ADR-0071 보탬) ───
|
|
578
|
+
* 이미지와 **같은 자리**(사람 턴)에 붙인다. 크기 상한은 모드가 선언하고, 넘으면 보내기 전에 사실 한
|
|
579
|
+
* 줄로 거절한다 — 조용히 자르지 않는다. 비용은 사용량의 축이다(ADR-0061 결정 6).
|
|
580
|
+
*
|
|
581
|
+
* `attachments` 짐 자체는 그대로 둔다: figure 의 도구가 거기서 이미지를 찾는다
|
|
582
|
+
* (`figure-tools.ts` — `ctx.host.image` 가 없을 때의 갈래).
|
|
583
|
+
*/
|
|
478
584
|
private async onAttachFiles(files: FileList | File[] | null | undefined) {
|
|
479
585
|
if (!files || files.length === 0) return
|
|
480
586
|
const list = Array.from(files)
|
|
@@ -607,11 +713,12 @@ export class OxAssistantChat extends LitElement {
|
|
|
607
713
|
The screen still shows nothing either way. There is no sentence to show, and inventing one is
|
|
608
714
|
what this whole correction removed.
|
|
609
715
|
*/
|
|
610
|
-
if (!this.conversation.
|
|
716
|
+
if (!this.conversation.stagedNotice && !OxAssistantChat.warnedMissingStagedNotice) {
|
|
611
717
|
OxAssistantChat.warnedMissingStagedNotice = true
|
|
612
718
|
console.warn(
|
|
613
|
-
'[assistant-chat] a host reported a proposal staged but
|
|
614
|
-
'
|
|
719
|
+
'[assistant-chat] a host reported a proposal staged but declared no staged notice, so the card can ' +
|
|
720
|
+
'say nothing. Declare `stagedNoticeKey` on the mode (the server translates it), or pass one to ' +
|
|
721
|
+
'`registerChatDefaults` from a host with no mode.'
|
|
615
722
|
)
|
|
616
723
|
}
|
|
617
724
|
|
|
@@ -663,6 +770,10 @@ export class OxAssistantChat extends LitElement {
|
|
|
663
770
|
return (auth.credential as any)?.email
|
|
664
771
|
}
|
|
665
772
|
|
|
773
|
+
private get _myUserId(): string | undefined {
|
|
774
|
+
return (auth.credential as any)?.id
|
|
775
|
+
}
|
|
776
|
+
|
|
666
777
|
/** Mention popup — `#` (컴포넌트) / `@` (카탈로그) / `/` (slash) 트리거 시 활성.
|
|
667
778
|
* 단일 popup 재사용 — mentionTrigger 로 활성 trigger 추적. */
|
|
668
779
|
@state()
|
|
@@ -716,15 +827,130 @@ export class OxAssistantChat extends LitElement {
|
|
|
716
827
|
return resolveConversation(
|
|
717
828
|
this.mode,
|
|
718
829
|
{
|
|
719
|
-
systemPrompt: this.systemPrompt,
|
|
720
|
-
toolCategories: this.toolCategories,
|
|
721
830
|
hostContext: this.hostContext,
|
|
722
|
-
chatEndpoint: this.chatEndpoint
|
|
723
|
-
|
|
724
|
-
|
|
831
|
+
chatEndpoint: this.chatEndpoint,
|
|
832
|
+
/* A host with no mode still registers its wording as keys; it is translated here. */
|
|
833
|
+
footerNotice: chatDefaults.footerNoticeKey ? i18next.t(chatDefaults.footerNoticeKey) : undefined,
|
|
834
|
+
stagedNotice: chatDefaults.stagedNoticeKey ? i18next.t(chatDefaults.stagedNoticeKey) : undefined
|
|
835
|
+
} as any,
|
|
836
|
+
chatDefaults as any,
|
|
837
|
+
this.modeView
|
|
725
838
|
)
|
|
726
839
|
}
|
|
727
840
|
|
|
841
|
+
/**
|
|
842
|
+
* What the server said this mode offers, in this person's language.
|
|
843
|
+
*
|
|
844
|
+
* Fetched when the mode changes and kept until the next one answers. Until it arrives the panel
|
|
845
|
+
* offers nothing rather than the list some other package registered globally.
|
|
846
|
+
*/
|
|
847
|
+
@state() private modeView?: AssistantModeView
|
|
848
|
+
|
|
849
|
+
private modeViewToken = 0
|
|
850
|
+
|
|
851
|
+
/** 이 subject 에 설 수 있는 대화들 — 기본이 먼저. 하나뿐이면 고르개를 그리지 않는다. */
|
|
852
|
+
@state() private modeChoices: { kind: string; label: string; isDefault: boolean }[] = []
|
|
853
|
+
|
|
854
|
+
private modeChoicesToken = 0
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* 이 화면에 설 수 있는 대화를 서버에 묻는다.
|
|
858
|
+
*
|
|
859
|
+
* 화면이 종류 목록을 손에 들고 있으면, 대화를 하나 더 세운 날 그 화면만 모른 채로 남는다. 목록은
|
|
860
|
+
* 앱 서버의 선언에서 나온다(ADR-0072 A17 ①).
|
|
861
|
+
*/
|
|
862
|
+
private async loadModeChoices() {
|
|
863
|
+
const subject = this.subject
|
|
864
|
+
if (!subject) {
|
|
865
|
+
this.modeChoices = []
|
|
866
|
+
return
|
|
867
|
+
}
|
|
868
|
+
const token = ++this.modeChoicesToken
|
|
869
|
+
try {
|
|
870
|
+
const result = await client.query({
|
|
871
|
+
query: ASSISTANT_MODES_QUERY,
|
|
872
|
+
variables: { subject },
|
|
873
|
+
fetchPolicy: 'cache-first'
|
|
874
|
+
})
|
|
875
|
+
if (token !== this.modeChoicesToken) return
|
|
876
|
+
this.modeChoices = result.data?.assistantModes ?? []
|
|
877
|
+
} catch {
|
|
878
|
+
/*
|
|
879
|
+
* 못 물어봤다고 화면을 막지 않는다 — host 가 준 대화는 그대로 산다. 고르개만 안 나온다.
|
|
880
|
+
* 여기서 오류 문구를 띄우면 고를 것이 하나뿐인 화면에서도 빨간 줄이 뜬다.
|
|
881
|
+
*/
|
|
882
|
+
if (token !== this.modeChoicesToken) return
|
|
883
|
+
this.modeChoices = []
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* 사람이 다른 대화를 골랐다.
|
|
889
|
+
*
|
|
890
|
+
* 고른 것은 **이 subject 종류에 대해** 기억한다 — 보드를 열 때마다 저작 대화로 돌아가면, 현장을
|
|
891
|
+
* 물으려던 사람은 화면을 열 때마다 같은 손질을 다시 해야 한다. 기억은 이 브라우저에만 남는다
|
|
892
|
+
* (서버에 칸을 만들지 않는다 — A17 ①). 세션 자체는 자기가 어느 대화였는지 이미 안다.
|
|
893
|
+
*/
|
|
894
|
+
private onModePick(kind: string) {
|
|
895
|
+
if (!this.mode || kind === this.mode.kind) return
|
|
896
|
+
try {
|
|
897
|
+
if (this.subject) localStorage.setItem(`assistant-mode:${this.subject}`, kind)
|
|
898
|
+
} catch {
|
|
899
|
+
/* 저장이 막힌 브라우저에서도 고르기 자체는 된다 — 다음에 다시 고르면 될 뿐이다. */
|
|
900
|
+
}
|
|
901
|
+
this.askHostForMode(kind)
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* **고르는 것은 청하는 일이다** — `mode` 를 여기서 바꾸지 않는다.
|
|
906
|
+
*
|
|
907
|
+
* host 는 렌더마다 `mode` 를 다시 내려 준다. 패널이 자기 손으로 고쳐 두면 다음 렌더가 그것을 덮고,
|
|
908
|
+
* 더 나쁜 것은 host 가 **자기가 무엇을 열었는지 모르는 채로 남는다**는 것이다. host 는 대화의 세션을
|
|
909
|
+
* 대상별로 들고 있으므로, 대화가 바뀐 것을 모르면 앞 대화의 세션을 그대로 넘긴다 — 그러면 새 말이 앞
|
|
910
|
+
* 대화에 붙는다(2026-09-18 Figure 레인이 :3300 에서 본 것이 이것이다).
|
|
911
|
+
*
|
|
912
|
+
* 그래서 주인은 하나다: host 가 `mode` 를 갖고, 패널은 「이것으로 바꿔 달라」고 말한다. 기억은 패널이
|
|
913
|
+
* 진다(브라우저마다 다른 값이라 host 가 질 것이 아니다) — 기억한 것을 되살릴 때도 같은 청으로 나간다.
|
|
914
|
+
*/
|
|
915
|
+
private askHostForMode(kind: string) {
|
|
916
|
+
this.dispatchEvent(
|
|
917
|
+
new CustomEvent('assistant-mode-change', { detail: { kind, subject: this.subject }, bubbles: true, composed: true })
|
|
918
|
+
)
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/** 이 subject 에서 지난번에 고른 대화 — 없으면 undefined. */
|
|
922
|
+
private rememberedMode(subject: string): string | undefined {
|
|
923
|
+
try {
|
|
924
|
+
return localStorage.getItem(`assistant-mode:${subject}`) ?? undefined
|
|
925
|
+
} catch {
|
|
926
|
+
return undefined
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
private async loadModeView() {
|
|
931
|
+
const mode = this.mode
|
|
932
|
+
if (!mode?.kind) {
|
|
933
|
+
this.modeView = undefined
|
|
934
|
+
return
|
|
935
|
+
}
|
|
936
|
+
const token = ++this.modeViewToken
|
|
937
|
+
try {
|
|
938
|
+
const result = await client.query({ query: ASSISTANT_MODE_QUERY, variables: { kind: mode.kind }, fetchPolicy: 'cache-first' })
|
|
939
|
+
/* A late answer for a conversation the person has already left is dropped. */
|
|
940
|
+
if (token !== this.modeViewToken) return
|
|
941
|
+
this.modeView = result.data?.assistantMode
|
|
942
|
+
this.rebuildMentionCaches()
|
|
943
|
+
} catch (error) {
|
|
944
|
+
if (token !== this.modeViewToken) return
|
|
945
|
+
this.modeView = undefined
|
|
946
|
+
/*
|
|
947
|
+
* A kind this server does not have is a mismatched deployment, and the person should read it
|
|
948
|
+
* rather than watch an empty `/` list.
|
|
949
|
+
*/
|
|
950
|
+
this.errorMessage = error instanceof Error ? error.message : String(error)
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
|
|
728
954
|
/*
|
|
729
955
|
* The `@` and `/` candidates, built once per mode.
|
|
730
956
|
*
|
|
@@ -775,6 +1001,52 @@ export class OxAssistantChat extends LitElement {
|
|
|
775
1001
|
}
|
|
776
1002
|
|
|
777
1003
|
/* ── C4 Roster (participants + presence) ───────────── */
|
|
1004
|
+
/* 이 대화의 주어 — 같은 화면 위에 두 대화가 설 때만 나온다(ADR-0072 A17 ①).
|
|
1005
|
+
지금 대화가 제목 굵기로 서고, 바꿀 자리가 그 옆에 붙는다. 세션 탭과 같은 무게로 그리지 않는다
|
|
1006
|
+
(UX 레인, 2026-09-18) — 한쪽은 화제를 바꾸고 한쪽은 실타래를 바꾼다. */
|
|
1007
|
+
.mode-subject {
|
|
1008
|
+
display: flex;
|
|
1009
|
+
align-items: baseline;
|
|
1010
|
+
gap: 8px;
|
|
1011
|
+
padding: 6px 12px;
|
|
1012
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant, #e2e8f0);
|
|
1013
|
+
}
|
|
1014
|
+
.mode-now {
|
|
1015
|
+
/* 고른 상태의 색은 세션 탭과 같은 계열이다 — 한 패널 안에서 「골랐다」가 두 색으로 나오면 읽는
|
|
1016
|
+
사람은 두 색이 서로 다른 뜻인 줄 안다.
|
|
1017
|
+
|
|
1018
|
+
12px 이었다가 한 단 내렸다. 도크 제목(figure 의 .scope-title 이 12.5px / 650)과 0.5px ·
|
|
1019
|
+
굵기 50 차이는 눈에 닿지 않아서, 거의 같은 제목 줄이 둘 포개졌다. 도크 제목은 그 도크 전체를
|
|
1020
|
+
거느리고 이 줄은 그 안 대화 하나의 성질이다 — 11px 이면 이 패널의 다른 조작부와 같은 단이고,
|
|
1021
|
+
「이것이 주어다」는 색이 계속 진다(UX 레인, 2026-09-18). */
|
|
1022
|
+
color: var(--primary-color, #007f87);
|
|
1023
|
+
font-size: 11px;
|
|
1024
|
+
font-weight: 600;
|
|
1025
|
+
}
|
|
1026
|
+
.mode-switch,
|
|
1027
|
+
.mode-select {
|
|
1028
|
+
appearance: none;
|
|
1029
|
+
background: transparent;
|
|
1030
|
+
border: 1px solid var(--md-sys-color-outline-variant, #cbd5e1);
|
|
1031
|
+
border-radius: 999px;
|
|
1032
|
+
color: var(--md-sys-color-on-surface-variant, #475569);
|
|
1033
|
+
cursor: pointer;
|
|
1034
|
+
font: inherit;
|
|
1035
|
+
font-size: 11px;
|
|
1036
|
+
padding: 2px 10px;
|
|
1037
|
+
white-space: nowrap;
|
|
1038
|
+
}
|
|
1039
|
+
.mode-switch:hover:not([disabled]) {
|
|
1040
|
+
background: color-mix(in srgb, var(--primary-color, #007f87) 7%, transparent);
|
|
1041
|
+
color: var(--primary-color, #007f87);
|
|
1042
|
+
}
|
|
1043
|
+
/* 답하는 동안에도 「내가 지금 무엇에 대해 말하고 있나」는 또렷해야 한다 — 흐려지는 것은 바꿀
|
|
1044
|
+
자리뿐이다. 지금 대화까지 흐리면 그 한 줄이 가장 안 보인다. */
|
|
1045
|
+
.mode-subject [disabled] {
|
|
1046
|
+
cursor: default;
|
|
1047
|
+
opacity: 0.5;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
778
1050
|
.roster {
|
|
779
1051
|
display: flex;
|
|
780
1052
|
align-items: center;
|
|
@@ -1325,6 +1597,29 @@ export class OxAssistantChat extends LitElement {
|
|
|
1325
1597
|
overflow: visible;
|
|
1326
1598
|
}
|
|
1327
1599
|
|
|
1600
|
+
/* 값이 안 온 줄 — ADR-0073 판정 1.
|
|
1601
|
+
말풍선의 자리와 「AI」 딱지는 지킨다 — 그 줄은 어시스턴트의 답이 맞고, 읽는 사람이 못 지나간
|
|
1602
|
+
것이다. 점선 테두리와 흐린 색이 「이것은 그가 쓴 문장이 아니다」를 말한다.
|
|
1603
|
+
|
|
1604
|
+
기울임은 쓰지 않는다. 이 앱의 글꼴 묶음에 한글 이탤릭 자소가 없어 브라우저가 합성으로 기울이고,
|
|
1605
|
+
획 균형이 무너져 작은 글자가 먼저 안 읽힌다. UX 레인이 :4000 에서 재 보았다 — 「권한」의 진행
|
|
1606
|
+
폭이 normal·italic 둘 다 27.6875px 로 같다(2026-09-18). */
|
|
1607
|
+
.msg.redacted {
|
|
1608
|
+
background: transparent;
|
|
1609
|
+
border: 1px dashed var(--md-sys-color-outline-variant, #cbd5e1);
|
|
1610
|
+
color: var(--md-sys-color-outline, #94a3b8);
|
|
1611
|
+
}
|
|
1612
|
+
.redacted-body {
|
|
1613
|
+
align-items: center;
|
|
1614
|
+
display: flex;
|
|
1615
|
+
gap: 6px;
|
|
1616
|
+
}
|
|
1617
|
+
.redacted-body md-icon {
|
|
1618
|
+
/* md-icon 은 자기 크기를 이 변수로 잡는다 — width/height 만 주면 아무 일도 안 일어난다. */
|
|
1619
|
+
--md-icon-size: 14px;
|
|
1620
|
+
font-size: 14px;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1328
1623
|
.msg.pending {
|
|
1329
1624
|
opacity: 0.5;
|
|
1330
1625
|
}
|
|
@@ -2185,6 +2480,20 @@ export class OxAssistantChat extends LitElement {
|
|
|
2185
2480
|
cursor: not-allowed;
|
|
2186
2481
|
}
|
|
2187
2482
|
|
|
2483
|
+
/* 보내기 전에 보이는 초대 안내 — 누르기 전에 알아야 하는 사실이다. */
|
|
2484
|
+
.invite-notice {
|
|
2485
|
+
display: flex;
|
|
2486
|
+
align-items: center;
|
|
2487
|
+
gap: 6px;
|
|
2488
|
+
margin: 0 2px 4px;
|
|
2489
|
+
color: var(--md-sys-color-on-surface-variant, #475569);
|
|
2490
|
+
font-size: 11.5px;
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
.invite-notice md-icon {
|
|
2494
|
+
--md-icon-size: 15px;
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2188
2497
|
/* ── Send button — ChatGPT 스타일 원형 ↑ (.input-row 안의 button 만) ─── */
|
|
2189
2498
|
.input-row > button {
|
|
2190
2499
|
width: 32px;
|
|
@@ -2206,6 +2515,15 @@ export class OxAssistantChat extends LitElement {
|
|
|
2206
2515
|
align-self: flex-end;
|
|
2207
2516
|
margin-bottom: 2px;
|
|
2208
2517
|
}
|
|
2518
|
+
/*
|
|
2519
|
+
방에 말하는 자리는 **두 번째 행동**이다 — 이 화면의 첫 행동은 어시스턴트에게 묻는 것이다.
|
|
2520
|
+
같은 무게로 두면 무엇이 기본인지 화면이 말하지 않게 된다(ADR-0070 A15 의 자리 둘).
|
|
2521
|
+
*/
|
|
2522
|
+
.input-row > button.say-to-room {
|
|
2523
|
+
background: var(--md-sys-color-surface-container-highest, #e2e8f0);
|
|
2524
|
+
color: var(--md-sys-color-on-surface-variant, #475569);
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2209
2527
|
.input-row > button:disabled {
|
|
2210
2528
|
background: var(--md-sys-color-surface-container-highest, #e2e8f0);
|
|
2211
2529
|
color: var(--md-sys-color-outline, #94a3b8);
|
|
@@ -2241,6 +2559,23 @@ export class OxAssistantChat extends LitElement {
|
|
|
2241
2559
|
// 첫 마운트 시 sessionId 가 이미 set 돼있어도 loadHistory 는 첫 render 후 updated()
|
|
2242
2560
|
// 가 처리 — 단일 진입점으로 일관 (이전엔 connectedCallback 과 updated 양쪽이 호출 →
|
|
2243
2561
|
// 동시 fetch race 발생).
|
|
2562
|
+
/* 모드가 이미 붙어 있으면 무엇을 주는지 먼저 묻는다 — 바뀔 때는 updated 가 다시 묻는다. */
|
|
2563
|
+
if (this.mode?.kind) this.loadModeView()
|
|
2564
|
+
if (this.subject) this.onSubjectChanged()
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
/**
|
|
2568
|
+
* 화면이 보여 주는 것의 종류가 바뀌었다 — 설 수 있는 대화를 다시 묻고, 지난번 고른 것을 되살린다.
|
|
2569
|
+
*
|
|
2570
|
+
* 되살리는 것은 **고른 대화**이지 세션이 아니다. 세션은 자기가 어느 대화였는지 이미 알고, 다른
|
|
2571
|
+
* 대화로 가면 그때 새로 난다(ADR-0072 A17 ①).
|
|
2572
|
+
*/
|
|
2573
|
+
private async onSubjectChanged() {
|
|
2574
|
+
await this.loadModeChoices()
|
|
2575
|
+
if (this.modeChoices.length < 2 || !this.subject || !this.mode) return
|
|
2576
|
+
|
|
2577
|
+
const kind = pickInitialMode(this.mode.kind, this.modeChoices, this.rememberedMode(this.subject))
|
|
2578
|
+
if (kind && kind !== this.mode.kind) this.askHostForMode(kind)
|
|
2244
2579
|
}
|
|
2245
2580
|
|
|
2246
2581
|
updated(changed: Map<string, any>) {
|
|
@@ -2268,8 +2603,14 @@ export class OxAssistantChat extends LitElement {
|
|
|
2268
2603
|
* The host still owns `sessionId`; it hears `assistant-mode-changed` and decides whether
|
|
2269
2604
|
* this subject gets a stored session of its own.
|
|
2270
2605
|
*/
|
|
2606
|
+
/* 보는 것의 종류가 바뀌면 설 수 있는 대화도 달라진다 — 보드에서 현장으로 넘어간 자리. */
|
|
2607
|
+
if (changed.has('subject')) this.onSubjectChanged()
|
|
2608
|
+
|
|
2271
2609
|
if (changed.has('mode') && isDifferentConversation(changed.get('mode'), this.mode)) {
|
|
2610
|
+
/* What this conversation offers is the new mode's; ask before drawing the panel again. */
|
|
2611
|
+
this.modeView = undefined
|
|
2272
2612
|
this.rebuildMentionCaches()
|
|
2613
|
+
this.loadModeView()
|
|
2273
2614
|
this.lines = []
|
|
2274
2615
|
this.pickedMentions.clear()
|
|
2275
2616
|
this.pickedUserMentions.clear()
|
|
@@ -2319,6 +2660,10 @@ export class OxAssistantChat extends LitElement {
|
|
|
2319
2660
|
disconnectedCallback() {
|
|
2320
2661
|
this._stopPresence()
|
|
2321
2662
|
this._stopMessageSubscription()
|
|
2663
|
+
if (this.elapsedTimer) {
|
|
2664
|
+
clearInterval(this.elapsedTimer)
|
|
2665
|
+
this.elapsedTimer = undefined
|
|
2666
|
+
}
|
|
2322
2667
|
super.disconnectedCallback()
|
|
2323
2668
|
}
|
|
2324
2669
|
|
|
@@ -2455,6 +2800,7 @@ export class OxAssistantChat extends LitElement {
|
|
|
2455
2800
|
${this.toastMessage
|
|
2456
2801
|
? html`<div class="toast show">${this.toastMessage}</div>`
|
|
2457
2802
|
: nothing}
|
|
2803
|
+
${this.renderModeSubject()}
|
|
2458
2804
|
${this.renderSessionTabs()}
|
|
2459
2805
|
${this.renderRoster()}
|
|
2460
2806
|
<div class="messages" @click=${this.onBubbleClick}>
|
|
@@ -2472,8 +2818,12 @@ export class OxAssistantChat extends LitElement {
|
|
|
2472
2818
|
const prevSameSender = !!prev && prev.role === 'user' && prev.senderEmail === line.senderEmail
|
|
2473
2819
|
const showSenderLabel = isOther && !prevSameSender
|
|
2474
2820
|
const content = (line.content ?? '').trim()
|
|
2475
|
-
|
|
2476
|
-
|
|
2821
|
+
/*
|
|
2822
|
+
* 가려진 줄은 어시스턴트의 말이 아니다 — 마크다운으로 그리지 않고, 복사·재실행 같은 손잡이도
|
|
2823
|
+
* 달지 않는다(ADR-0073 판정 1). 그 손잡이들은 있지도 않은 답을 다룬다.
|
|
2824
|
+
*/
|
|
2825
|
+
const isMarkdown = line.role !== 'system' && content.length > 0 && !line.redacted
|
|
2826
|
+
const showActions = line.role !== 'system' && !line.pending && content.length > 0 && !line.redacted
|
|
2477
2827
|
return html`
|
|
2478
2828
|
${showLabel
|
|
2479
2829
|
? html`<div class="msg-label">${i18next.t('ai-assistant.label.ai')}</div>`
|
|
@@ -2484,9 +2834,11 @@ export class OxAssistantChat extends LitElement {
|
|
|
2484
2834
|
<div
|
|
2485
2835
|
class="msg ${line.role} ${isOther ? 'other' : ''} ${line.pending ? 'pending' : ''} ${line.systemOpen
|
|
2486
2836
|
? 'open'
|
|
2487
|
-
: ''}">
|
|
2837
|
+
: ''} ${line.redacted ? 'redacted' : ''}">
|
|
2488
2838
|
${line.pending
|
|
2489
2839
|
? html`<span class="typing-dots"><span></span><span></span><span></span></span>`
|
|
2840
|
+
: line.redacted
|
|
2841
|
+
? html`<div class="redacted-body"><md-icon>lock</md-icon><span>${content}</span></div>`
|
|
2490
2842
|
: isMarkdown
|
|
2491
2843
|
? html`<div class="md-body">${unsafeHTML(renderMarkdown(content))}</div>`
|
|
2492
2844
|
: line.role === 'system'
|
|
@@ -2587,7 +2939,7 @@ export class OxAssistantChat extends LitElement {
|
|
|
2587
2939
|
id="chat-file-input"
|
|
2588
2940
|
type="file"
|
|
2589
2941
|
multiple
|
|
2590
|
-
accept="image
|
|
2942
|
+
accept="image/*"
|
|
2591
2943
|
style="display: none"
|
|
2592
2944
|
@change=${(e: Event) => {
|
|
2593
2945
|
const input = e.target as HTMLInputElement
|
|
@@ -2601,7 +2953,7 @@ export class OxAssistantChat extends LitElement {
|
|
|
2601
2953
|
type="button"
|
|
2602
2954
|
class="action"
|
|
2603
2955
|
@click=${() => this.renderRoot.querySelector<HTMLInputElement>('#chat-file-input')?.click()}
|
|
2604
|
-
title=${i18next.t('ai-assistant.tooltip.attach-file', { defaultValue: '
|
|
2956
|
+
title=${i18next.t('ai-assistant.tooltip.attach-file', { defaultValue: 'attach an image (drag & drop or paste supported)' })}>
|
|
2605
2957
|
<md-icon>attach_file</md-icon>
|
|
2606
2958
|
${i18next.t('ai-assistant.button.attach', { defaultValue: 'Attach' })}
|
|
2607
2959
|
</button>
|
|
@@ -2647,6 +2999,7 @@ export class OxAssistantChat extends LitElement {
|
|
|
2647
2999
|
</div>
|
|
2648
3000
|
`
|
|
2649
3001
|
: nothing}
|
|
3002
|
+
${this.renderInviteNotice()}
|
|
2650
3003
|
<div class="input-row">
|
|
2651
3004
|
<div class="textarea-wrap">
|
|
2652
3005
|
<textarea
|
|
@@ -2660,7 +3013,9 @@ export class OxAssistantChat extends LitElement {
|
|
|
2660
3013
|
}}
|
|
2661
3014
|
?disabled=${this.busy}
|
|
2662
3015
|
rows="1"
|
|
2663
|
-
placeholder=${this.placeholder ??
|
|
3016
|
+
placeholder=${this.conversation.placeholder ??
|
|
3017
|
+
this.placeholder ??
|
|
3018
|
+
i18next.t('ai-assistant.text.input-placeholder')}></textarea>
|
|
2664
3019
|
${this.mentionOpen
|
|
2665
3020
|
? html`
|
|
2666
3021
|
<ox-mention-popup
|
|
@@ -2681,6 +3036,27 @@ export class OxAssistantChat extends LitElement {
|
|
|
2681
3036
|
`
|
|
2682
3037
|
: nothing}
|
|
2683
3038
|
</div>
|
|
3039
|
+
${/*
|
|
3040
|
+
두 자리다 — 어시스턴트에게 묻는 자리와 **방에 말하는 자리**. 누른 자리가 그 말의 대상을
|
|
3041
|
+
정하고, 서버는 어느 문이 불렸는지로 그 사실을 저장한다(ADR-0070 A15 결정 ①).
|
|
3042
|
+
|
|
3043
|
+
**방에 사람이 있을 때만 보인다.** 혼자 쓰는 대화에서 「방에 말하기」는 아무에게도 하지 않는
|
|
3044
|
+
말이고, 누를 일이 없는 단추는 무엇이 기본인지 흐린다. 조건은 참여자 목록과 같다(둘 이상) —
|
|
3045
|
+
둘째 사람은 멘션으로 들어오고, 그 순간 이 자리도 함께 선다.
|
|
3046
|
+
*/ ''}
|
|
3047
|
+
${this.sessionId && this.participants.length >= 2
|
|
3048
|
+
? html`
|
|
3049
|
+
<button
|
|
3050
|
+
class="say-to-room"
|
|
3051
|
+
?disabled=${this.busy || !this.input.trim()}
|
|
3052
|
+
@click=${() => this.sayToRoom()}
|
|
3053
|
+
title=${i18next.t('ai-assistant.text.say-to-room-tooltip', {
|
|
3054
|
+
defaultValue: 'say this to the people here — the assistant does not answer'
|
|
3055
|
+
})}>
|
|
3056
|
+
<md-icon>forum</md-icon>
|
|
3057
|
+
</button>
|
|
3058
|
+
`
|
|
3059
|
+
: nothing}
|
|
2684
3060
|
<button
|
|
2685
3061
|
?disabled=${this.busy || (!this.input.trim() && this.attachments.length === 0)}
|
|
2686
3062
|
@click=${this.send}
|
|
@@ -2694,6 +3070,83 @@ export class OxAssistantChat extends LitElement {
|
|
|
2694
3070
|
`
|
|
2695
3071
|
}
|
|
2696
3072
|
|
|
3073
|
+
/**
|
|
3074
|
+
* 방에 말한다 — 어시스턴트는 답하지 않는다.
|
|
3075
|
+
*
|
|
3076
|
+
* 저장되는 대화가 있을 때만 할 수 있다. 세션이 없는 즉석 질문에는 「방」이 없다 — 그 자리에서
|
|
3077
|
+
* 한 말은 누구에게도 남지 않는다.
|
|
3078
|
+
*/
|
|
3079
|
+
private async sayToRoom() {
|
|
3080
|
+
const body = this.input.trim()
|
|
3081
|
+
if (!body || this.busy) return
|
|
3082
|
+
if (!this.sessionId) {
|
|
3083
|
+
/* 말할 방이 없다는 사실을 말한다 — 조용히 버리면 사람은 말했다고 믿는다. */
|
|
3084
|
+
this.errorMessage = i18next.t('ai-assistant.text.no-room-yet', {
|
|
3085
|
+
defaultValue: 'this conversation is not saved yet, so there is nobody else in it to talk to'
|
|
3086
|
+
})
|
|
3087
|
+
return
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3090
|
+
const localId = `local-${++this._localSeq}-r`
|
|
3091
|
+
this.lines = [...this.lines, { role: 'user', content: body, _localId: localId, senderEmail: this._myEmail }]
|
|
3092
|
+
this.input = ''
|
|
3093
|
+
this.busy = true
|
|
3094
|
+
try {
|
|
3095
|
+
const result = await client.mutate({
|
|
3096
|
+
mutation: SAY_TO_ROOM_MUTATION,
|
|
3097
|
+
variables: { sessionId: this.sessionId, content: body }
|
|
3098
|
+
})
|
|
3099
|
+
/* 방송 에코와 겹치지 않게 서버 id 로 맞춘다 — 보낸 말이 두 줄로 보이지 않게. */
|
|
3100
|
+
this._reconcileSentLine(localId, result.data?.sayToRoom ?? undefined, {})
|
|
3101
|
+
} catch (error) {
|
|
3102
|
+
this.lines = this.lines.filter(line => line._localId !== localId)
|
|
3103
|
+
this.input = body
|
|
3104
|
+
this.errorMessage = error instanceof Error ? error.message : String(error)
|
|
3105
|
+
} finally {
|
|
3106
|
+
this.busy = false
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
/**
|
|
3111
|
+
* 보내기 전에 말한다 — 「이 사람은 이 대화에 들어옵니다」(ADR-0071 결정 1 ④).
|
|
3112
|
+
*
|
|
3113
|
+
* 멘션은 사람을 불러들인다. 누른 뒤에 알면 이미 들어와 있고, 협의의 공개 범위는 되돌리기 어려운
|
|
3114
|
+
* 종류의 일이다. 그래서 **아직 보내지 않은 상태에서** 누가 들어오게 되는지 보인다.
|
|
3115
|
+
*
|
|
3116
|
+
* 초대할 수 없는 자리(보기 권한 · 아직 참여자가 아님)라면 그 사실을 말한다 — 눌렀는데 아무 일도
|
|
3117
|
+
* 일어나지 않는 것이 가장 나쁘다.
|
|
3118
|
+
*/
|
|
3119
|
+
private renderInviteNotice() {
|
|
3120
|
+
if (!this.sessionId) return nothing
|
|
3121
|
+
|
|
3122
|
+
const here = new Set(this.participants.map(p => p.user?.id).filter(Boolean) as string[])
|
|
3123
|
+
const incoming = [...this.pickedUserMentions.entries()]
|
|
3124
|
+
.filter(([token, userId]) => this.input.includes(`@${token}`) && !here.has(userId))
|
|
3125
|
+
.map(([token]) => token)
|
|
3126
|
+
if (incoming.length === 0) return nothing
|
|
3127
|
+
|
|
3128
|
+
const myRole = this.participants.find(p => p.user?.id && p.user.id === this._myUserId)?.role
|
|
3129
|
+
const mayInvite = myRole === 'owner' || myRole === 'member'
|
|
3130
|
+
const names = incoming.map(token => `@${token}`).join(', ')
|
|
3131
|
+
|
|
3132
|
+
return html`
|
|
3133
|
+
<div class="invite-notice">
|
|
3134
|
+
<md-icon>person_add</md-icon>
|
|
3135
|
+
<span>
|
|
3136
|
+
${mayInvite
|
|
3137
|
+
? i18next.t('ai-assistant.text.will-be-invited', {
|
|
3138
|
+
names,
|
|
3139
|
+
defaultValue: '{names} will join this conversation when you send'
|
|
3140
|
+
})
|
|
3141
|
+
: i18next.t('ai-assistant.text.cannot-invite', {
|
|
3142
|
+
names,
|
|
3143
|
+
defaultValue: '{names} will not join — only the people already in this conversation can bring someone in'
|
|
3144
|
+
})}
|
|
3145
|
+
</span>
|
|
3146
|
+
</div>
|
|
3147
|
+
`
|
|
3148
|
+
}
|
|
3149
|
+
|
|
2697
3150
|
private onKeyDown(e: KeyboardEvent) {
|
|
2698
3151
|
// Mention popup 활성 시 — 화살표/Enter/Tab/Esc 가로채서 popup 네비게이션
|
|
2699
3152
|
if (this.mentionOpen) {
|
|
@@ -2815,13 +3268,32 @@ export class OxAssistantChat extends LitElement {
|
|
|
2815
3268
|
this.highlightMatchedCandidates()
|
|
2816
3269
|
}
|
|
2817
3270
|
|
|
3271
|
+
/**
|
|
3272
|
+
* 호스트가 목록을 주지 않을 때 이 도메인의 사용자를 직접 묻는다.
|
|
3273
|
+
*
|
|
3274
|
+
* 실패는 빈 목록이다 — 멘션을 못 고르는 것이지 대화가 막힐 일은 아니다.
|
|
3275
|
+
*/
|
|
3276
|
+
private async fetchDomainUsers(query: string): Promise<Array<{ id: string; name?: string | null; email?: string | null }>> {
|
|
3277
|
+
try {
|
|
3278
|
+
const result = await client.query({
|
|
3279
|
+
query: DOMAIN_USERS_FOR_MENTION_QUERY,
|
|
3280
|
+
variables: { query },
|
|
3281
|
+
fetchPolicy: 'network-only'
|
|
3282
|
+
})
|
|
3283
|
+
return result.data?.domainUsersForMention ?? []
|
|
3284
|
+
} catch {
|
|
3285
|
+
return []
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
|
|
2818
3289
|
/** `@` query 에 대한 userProvider 비동기 호출 — 응답 도착 시 popup 결과 갱신.
|
|
2819
3290
|
* race 방지: token 으로 최신 호출 식별 (늦게 도착한 응답 무시). */
|
|
2820
3291
|
private async refreshUserCandidatesAsync(query: string, hashPos: number) {
|
|
2821
|
-
if (!this.userProvider) return
|
|
2822
3292
|
const token = ++this.userFetchToken
|
|
2823
3293
|
try {
|
|
2824
|
-
const users =
|
|
3294
|
+
const users = this.userProvider
|
|
3295
|
+
? await Promise.resolve(this.userProvider(query))
|
|
3296
|
+
: await this.fetchDomainUsers(query)
|
|
2825
3297
|
if (token !== this.userFetchToken) return // 더 최신 호출이 있음
|
|
2826
3298
|
// popup 이 닫혔거나 trigger / hashPos 가 바뀌면 무시
|
|
2827
3299
|
if (!this.mentionOpen || this.mentionTrigger !== '@' || this.mentionHashPos !== hashPos) {
|
|
@@ -3006,6 +3478,11 @@ export class OxAssistantChat extends LitElement {
|
|
|
3006
3478
|
* 읽었고, 그러면 호스트 값을 한쪽만 반영하는 상태가 만들어질 수 있었다.
|
|
3007
3479
|
*/
|
|
3008
3480
|
private get exampleGroups(): Array<{ label: string; items: string[] }> {
|
|
3481
|
+
/*
|
|
3482
|
+
* 대화가 자기 예시를 가지면 그것이 먼저다 — 자리표·`/` 와 같은 차례(ADR-0061 결정 7). host 속성은
|
|
3483
|
+
* 대화를 모르므로, 한 화면에 대화가 둘 서면 한쪽에 맞는 글이 다른 쪽에도 뜬다.
|
|
3484
|
+
*/
|
|
3485
|
+
if (this.modeView?.examples?.length) return this.modeView.examples
|
|
3009
3486
|
if (this.examples?.length) return this.examples
|
|
3010
3487
|
return OxAssistantChat.EXAMPLE_GROUPS.map(group => ({
|
|
3011
3488
|
label: i18next.t(group.labelKey),
|
|
@@ -3051,6 +3528,63 @@ export class OxAssistantChat extends LitElement {
|
|
|
3051
3528
|
|
|
3052
3529
|
/** 보드의 세션 탭 — 다중 세션 활성화 시 패널 상단. host 가 sessions 비워두면 표시 X.
|
|
3053
3530
|
* 레이블은 session.name 우선, 없으면 fallback "세션 N". */
|
|
3531
|
+
/**
|
|
3532
|
+
* 이 대화의 **주어** — 같은 화면 위에 두 대화가 설 때만 나온다(ADR-0072 A17 ①).
|
|
3533
|
+
*
|
|
3534
|
+
* 하나뿐이면 아무것도 그리지 않는다. 고를 것이 없는 고르개는 자리만 차지하고, 사람에게 「무언가
|
|
3535
|
+
* 고를 것이 있다」는 잘못된 신호를 준다.
|
|
3536
|
+
*
|
|
3537
|
+
* ── 왜 탭 줄이 아닌가 (UX 레인, 2026-09-18) ───────────────────────────────
|
|
3538
|
+
* 처음에는 칩 줄에 `role="tablist"` 를 달았다. 바로 아래가 세션 탭이고 그쪽도 tablist 라서, 화면
|
|
3539
|
+
* 낭독기로 들으면 「탭 목록, 대화」 다음에 「탭 목록, Conversation history」 가 이어졌다 — 고르는
|
|
3540
|
+
* 축이 둘인데 둘 다 「탭」이라고 말한다. 게다가 ARIA 탭은 좌우 화살표 이동과 `tabpanel` 이 함께
|
|
3541
|
+
* 있어야 성립하고, 둘 다 없으면 낭독기는 「2 중 1번째 탭」이라 말하고 화살표는 아무 일도 안 한다.
|
|
3542
|
+
*
|
|
3543
|
+
* 무게도 다르다. 세션은 「어느 지난 대화냐」이고 모드는 「이 대화가 무엇에 대한 것이냐」이다. 같은
|
|
3544
|
+
* 무게로 그리면 어느 쪽이 화제를 바꾸고 어느 쪽이 실타래를 바꾸는지 구별되지 않는다. 그래서 지금
|
|
3545
|
+
* 대화가 제목 굵기로 서고, 바꿀 자리는 그 옆에 붙는다.
|
|
3546
|
+
*
|
|
3547
|
+
* ── 왜 도크 제목 줄로 안 올리나 (UX 레인 판정, 2026-09-18) ────────────────
|
|
3548
|
+
* 도크 제목은 「지금 어디에 있나」(이 도형 · 이 현장 · 이 스테이션 화면)이고 이 줄은 「이 대화가
|
|
3549
|
+
* 무엇에 대한 것이냐」이다. 대화의 주어는 대화 안에 있다. 그리고 세 도크가 각자 그리면 세 벌이 되고
|
|
3550
|
+
* 그 세 벌은 갈린다 — `modeChoices` 를 아는 것도 여기다. 올리면 목록과 고른 것이 세 자리로 나갔다
|
|
3551
|
+
* 돌아온다.
|
|
3552
|
+
*/
|
|
3553
|
+
private renderModeSubject() {
|
|
3554
|
+
if (this.modeChoices.length < 2) return nothing
|
|
3555
|
+
|
|
3556
|
+
const current = this.modeChoices.find(choice => choice.kind === this.mode?.kind)
|
|
3557
|
+
const others = this.modeChoices.filter(choice => choice.kind !== this.mode?.kind)
|
|
3558
|
+
|
|
3559
|
+
return html`
|
|
3560
|
+
<div class="mode-subject">
|
|
3561
|
+
<span class="mode-now">${current?.label ?? this.mode?.kind ?? ''}</span>
|
|
3562
|
+
${others.length === 1
|
|
3563
|
+
? html`
|
|
3564
|
+
<button
|
|
3565
|
+
class="mode-switch"
|
|
3566
|
+
title=${i18next.t('ai-assistant.text.switch-conversation', { name: others[0].label })}
|
|
3567
|
+
aria-label=${i18next.t('ai-assistant.text.switch-conversation', { name: others[0].label })}
|
|
3568
|
+
?disabled=${this.busy}
|
|
3569
|
+
@click=${() => this.onModePick(others[0].kind)}>
|
|
3570
|
+
${others[0].label}
|
|
3571
|
+
</button>
|
|
3572
|
+
`
|
|
3573
|
+
: html`
|
|
3574
|
+
<select
|
|
3575
|
+
class="mode-select"
|
|
3576
|
+
aria-label=${i18next.t('ai-assistant.label.conversation')}
|
|
3577
|
+
?disabled=${this.busy}
|
|
3578
|
+
@change=${(event: Event) => this.onModePick((event.target as HTMLSelectElement).value)}>
|
|
3579
|
+
${this.modeChoices.map(
|
|
3580
|
+
choice => html`<option value=${choice.kind} ?selected=${choice.kind === this.mode?.kind}>${choice.label}</option>`
|
|
3581
|
+
)}
|
|
3582
|
+
</select>
|
|
3583
|
+
`}
|
|
3584
|
+
</div>
|
|
3585
|
+
`
|
|
3586
|
+
}
|
|
3587
|
+
|
|
3054
3588
|
private renderSessionTabs() {
|
|
3055
3589
|
if (!this.sessions || this.sessions.length === 0) return nothing
|
|
3056
3590
|
return html`
|
|
@@ -3110,8 +3644,13 @@ export class OxAssistantChat extends LitElement {
|
|
|
3110
3644
|
<div class="empty">
|
|
3111
3645
|
<div class="header">
|
|
3112
3646
|
<md-icon class="icon">auto_awesome</md-icon>
|
|
3113
|
-
|
|
3114
|
-
<div class="
|
|
3647
|
+
<!-- 대화가 자기 글을 가지면 그것이 먼저다 — host 속성은 대화를 모른다. -->
|
|
3648
|
+
<div class="title">
|
|
3649
|
+
${this.modeView?.intro?.title ?? this.intro?.title ?? i18next.t('ai-assistant.text.empty-title')}
|
|
3650
|
+
</div>
|
|
3651
|
+
<div class="subtitle">
|
|
3652
|
+
${this.modeView?.intro?.subtitle ?? this.intro?.subtitle ?? i18next.t('ai-assistant.text.empty-subtitle')}
|
|
3653
|
+
</div>
|
|
3115
3654
|
</div>
|
|
3116
3655
|
|
|
3117
3656
|
${this.triggerChips.length > 0
|
|
@@ -3154,8 +3693,8 @@ export class OxAssistantChat extends LitElement {
|
|
|
3154
3693
|
<span class="badge">${i18next.t('ai-assistant.label.korean-supported')}</span>
|
|
3155
3694
|
<span class="badge">${i18next.t('ai-assistant.label.multi-command')}</span>
|
|
3156
3695
|
<span class="badge">${i18next.t('ai-assistant.label.review-able')}</span>
|
|
3157
|
-
${this.conversation.
|
|
3158
|
-
? html`<br />${
|
|
3696
|
+
${this.conversation.footerNotice
|
|
3697
|
+
? html`<br />${this.conversation.footerNotice}`
|
|
3159
3698
|
: ''}
|
|
3160
3699
|
</div>
|
|
3161
3700
|
</div>
|
|
@@ -3334,8 +3873,9 @@ export class OxAssistantChat extends LitElement {
|
|
|
3334
3873
|
class="run"
|
|
3335
3874
|
?disabled=${sent}
|
|
3336
3875
|
@click=${() => this.executeProposal(p, key)}>
|
|
3337
|
-
${sent
|
|
3338
|
-
|
|
3876
|
+
${sent
|
|
3877
|
+
? this.proposalStateText(key)
|
|
3878
|
+
: i18next.t('ai-assistant.button.run-proposal', { defaultValue: 'run' })}
|
|
3339
3879
|
</button>
|
|
3340
3880
|
${/*
|
|
3341
3881
|
Drawn only where the host has said it staged this candidate, in the host's own
|
|
@@ -3343,15 +3883,15 @@ export class OxAssistantChat extends LitElement {
|
|
|
3343
3883
|
This badge used to read "there are chips" as "the model is in the 3D viewer" and
|
|
3344
3884
|
say so, in a component that plant and twin also use.
|
|
3345
3885
|
*/ ''}
|
|
3346
|
-
${this.stagedProposals.has(key) && this.conversation.
|
|
3886
|
+
${this.stagedProposals.has(key) && this.conversation.stagedNotice ? html`
|
|
3347
3887
|
<span class="staged-badge">
|
|
3348
3888
|
<md-icon>check_circle</md-icon>
|
|
3349
|
-
<span>${
|
|
3889
|
+
<span>${this.conversation.stagedNotice}</span>
|
|
3350
3890
|
</span>
|
|
3351
3891
|
` : nothing}
|
|
3352
3892
|
</div>
|
|
3353
3893
|
${rawChoices.length ? html`
|
|
3354
|
-
<div class="proposal-choices" role="group" aria-label
|
|
3894
|
+
<div class="proposal-choices" role="group" aria-label=${i18next.t('ai-assistant.text.proposal-choices', { defaultValue: 'follow-up choices' })}>
|
|
3355
3895
|
${rawChoices.map((c: any) => html`
|
|
3356
3896
|
<button
|
|
3357
3897
|
class="choice-chip ${c.primary ? 'primary' : ''}"
|
|
@@ -3369,6 +3909,51 @@ export class OxAssistantChat extends LitElement {
|
|
|
3369
3909
|
`
|
|
3370
3910
|
}
|
|
3371
3911
|
|
|
3912
|
+
/**
|
|
3913
|
+
* 눌린 카드가 말하는 것 — **호스트가 한 일**이고, 아직 모르면 모른다고 말한다.
|
|
3914
|
+
*
|
|
3915
|
+
* 예전에는 누른 순간 「실행됨」이었다. 09-18 트윈에서 아무 일도 일어나지 않은 채 「✓ 반영했습니다」가
|
|
3916
|
+
* 떴다(ADR-0070 A12-a).
|
|
3917
|
+
*/
|
|
3918
|
+
private proposalStateText(key: string): string {
|
|
3919
|
+
const outcome = this.proposalOutcomes.get(key)
|
|
3920
|
+
|
|
3921
|
+
if (!outcome) {
|
|
3922
|
+
/* 답이 오기 전 — 아는 사실은 「보냈고 아직 답이 없다」뿐이다. 경과 시간을 함께 보인다. */
|
|
3923
|
+
const since = this.proposalSentAt.get(key)
|
|
3924
|
+
const seconds = since ? Math.max(0, Math.round((Date.now() - since) / 1000)) : 0
|
|
3925
|
+
return i18next.t('ai-assistant.text.proposal-waiting', {
|
|
3926
|
+
seconds,
|
|
3927
|
+
defaultValue: 'sending — {seconds}s, no answer yet'
|
|
3928
|
+
})
|
|
3929
|
+
}
|
|
3930
|
+
|
|
3931
|
+
const counted =
|
|
3932
|
+
typeof outcome.applied === 'number' && typeof outcome.total === 'number' && outcome.total > 0
|
|
3933
|
+
? i18next.t('ai-assistant.text.proposal-applied-count', {
|
|
3934
|
+
applied: outcome.applied,
|
|
3935
|
+
total: outcome.total,
|
|
3936
|
+
defaultValue: ' {applied} of {total}'
|
|
3937
|
+
})
|
|
3938
|
+
: ''
|
|
3939
|
+
|
|
3940
|
+
/* 사유는 호스트가 준 코드 그대로다 — 문장으로 바꾸지 않는다(ADR-0042). */
|
|
3941
|
+
const reason = outcome.errorCode ? ` (${outcome.errorCode})` : ''
|
|
3942
|
+
|
|
3943
|
+
const verdict = i18next.t(`ai-assistant.verdict.${outcome.verdict}`, {
|
|
3944
|
+
defaultValue:
|
|
3945
|
+
outcome.verdict === 'accepted'
|
|
3946
|
+
? 'done'
|
|
3947
|
+
: outcome.verdict === 'refused'
|
|
3948
|
+
? 'refused'
|
|
3949
|
+
: outcome.verdict === 'declined'
|
|
3950
|
+
? 'cancelled'
|
|
3951
|
+
: 'could not run'
|
|
3952
|
+
})
|
|
3953
|
+
|
|
3954
|
+
return `${verdict}${counted}${reason}`
|
|
3955
|
+
}
|
|
3956
|
+
|
|
3372
3957
|
private onChoiceClick(choice: any, proposal: any, key: string) {
|
|
3373
3958
|
if (choice.action === 'save') {
|
|
3374
3959
|
this.dispatchEvent(
|
|
@@ -3420,10 +4005,17 @@ export class OxAssistantChat extends LitElement {
|
|
|
3420
4005
|
.map(k => `${JSON.stringify(k)}:${stable(v[k])}`)
|
|
3421
4006
|
.join(',')}}`
|
|
3422
4007
|
}
|
|
4008
|
+
/*
|
|
4009
|
+
* 서버가 실어 보낸 키가 정본이다 — 무엇이 같은 조치인가는 제안을 만든 쪽이 안다(ADR-0061 결정
|
|
4010
|
+
* 7 뒤 정리). 예전에는 여기서 `command|instanceId|args` 로 다시 셌는데, 명령이 없는 제안(선언 ·
|
|
4011
|
+
* 새 트윈 초안)은 그 셋이 모두 비어 **서로 다른 제안이 한 카드로 접혔고**, 하나를 누르면 나머지가
|
|
4012
|
+
* 함께 「요청됨」이 됐다.
|
|
4013
|
+
*/
|
|
4014
|
+
if (typeof p?.key === 'string' && p.key) return p.key
|
|
3423
4015
|
try {
|
|
3424
|
-
return `${p?.command ?? ''}|${p?.instanceId ?? ''}|${stable(p?.args)}`
|
|
4016
|
+
return `${p?.tool ?? ''}|${p?.command ?? ''}|${p?.instanceId ?? ''}|${stable(p?.args)}|${stable(p?.ops)}`
|
|
3425
4017
|
} catch {
|
|
3426
|
-
return `${p?.command ?? ''}|${p?.instanceId ?? ''}`
|
|
4018
|
+
return `${p?.tool ?? ''}|${p?.command ?? ''}|${p?.instanceId ?? ''}`
|
|
3427
4019
|
}
|
|
3428
4020
|
}
|
|
3429
4021
|
|
|
@@ -3431,17 +4023,64 @@ export class OxAssistantChat extends LitElement {
|
|
|
3431
4023
|
* 실행은 호스트가 한다 — 이 컴포넌트는 도메인(트윈 명령 채널)을 모른다.
|
|
3432
4024
|
* 확인 대화·명령 전송·결과 기록은 호스트의 몫이고, 여기서는 중복 클릭만 막는다.
|
|
3433
4025
|
*/
|
|
4026
|
+
/**
|
|
4027
|
+
* 누른 시각 — 「보내는 중」 옆의 경과 시간용.
|
|
4028
|
+
*
|
|
4029
|
+
* 시간으로 실패를 판정하지 않는다(ADR-0070 A12-a 결정 ②). 아는 사실은 「아직 답을 받지 못했다」
|
|
4030
|
+
* 하나이고, 시간이 지났다고 실패로 바꾸면 그것이 지어낸 원인이다.
|
|
4031
|
+
*/
|
|
4032
|
+
private proposalSentAt = new Map<string, number>()
|
|
4033
|
+
|
|
4034
|
+
private elapsedTimer?: ReturnType<typeof setInterval>
|
|
4035
|
+
|
|
3434
4036
|
private executeProposal(p: any, key: string) {
|
|
3435
4037
|
this.sentProposals = new Set(this.sentProposals).add(key)
|
|
4038
|
+
this.proposalSentAt.set(key, Date.now())
|
|
4039
|
+
this._startElapsedTicker()
|
|
3436
4040
|
this.dispatchEvent(
|
|
3437
4041
|
new CustomEvent('assistant-proposal-execute', {
|
|
3438
|
-
|
|
4042
|
+
/*
|
|
4043
|
+
* `proposalKey` 를 함께 준다 — 호스트가 `reportProposalOutcome` 으로 답할 때 쓰는 이름이다.
|
|
4044
|
+
* 호스트가 자기 규칙으로 키를 다시 만들면 카드가 못 찾는 답이 생긴다(원본은 하나).
|
|
4045
|
+
*/
|
|
4046
|
+
detail: { proposal: p, sessionId: this.sessionId, proposalKey: key },
|
|
3439
4047
|
bubbles: true,
|
|
3440
4048
|
composed: true
|
|
3441
4049
|
})
|
|
3442
4050
|
)
|
|
3443
4051
|
}
|
|
3444
4052
|
|
|
4053
|
+
/**
|
|
4054
|
+
* 호스트가 무엇을 했는지 — 대화에 남은 `system` 행에서 읽는다(ADR-0070 A12-a 결정 ①).
|
|
4055
|
+
*
|
|
4056
|
+
* 카드가 자기 기억으로 상태를 들고 있으면 새로 고치는 순간 사라지고, 다른 창에서 실행한 것은
|
|
4057
|
+
* 애초에 보이지 않는다. 그래서 상태의 자리는 이력이다.
|
|
4058
|
+
*/
|
|
4059
|
+
private get proposalOutcomes(): Map<string, ParsedProposalOutcome> {
|
|
4060
|
+
const outcomes = new Map<string, ParsedProposalOutcome>()
|
|
4061
|
+
for (const line of this.lines) {
|
|
4062
|
+
if (line.role !== 'system') continue
|
|
4063
|
+
const parsed = parseProposalOutcomeLine(line.content ?? '')
|
|
4064
|
+
if (parsed) outcomes.set(parsed.key, parsed)
|
|
4065
|
+
}
|
|
4066
|
+
return outcomes
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
/** 경과 시간을 보이는 동안에만 돈다 — 답이 오면 멈춘다. */
|
|
4070
|
+
private _startElapsedTicker() {
|
|
4071
|
+
if (this.elapsedTimer) return
|
|
4072
|
+
this.elapsedTimer = setInterval(() => {
|
|
4073
|
+
const outcomes = this.proposalOutcomes
|
|
4074
|
+
const waiting = [...this.proposalSentAt.keys()].some(key => !outcomes.has(key))
|
|
4075
|
+
if (!waiting) {
|
|
4076
|
+
clearInterval(this.elapsedTimer)
|
|
4077
|
+
this.elapsedTimer = undefined
|
|
4078
|
+
return
|
|
4079
|
+
}
|
|
4080
|
+
this.requestUpdate()
|
|
4081
|
+
}, 1000)
|
|
4082
|
+
}
|
|
4083
|
+
|
|
3445
4084
|
/**
|
|
3446
4085
|
* 접지 경고 — 답이 언급했지만 **근거에 없던** 대상을 알린다.
|
|
3447
4086
|
*
|
|
@@ -3569,12 +4208,12 @@ export class OxAssistantChat extends LitElement {
|
|
|
3569
4208
|
/** 배지 문구 — 코드가 아니라 사람 말로. */
|
|
3570
4209
|
private outcomeLabel(outcome: string): string {
|
|
3571
4210
|
const map: Record<string, [string, string]> = {
|
|
3572
|
-
ok: ['ai-assistant.text.outcome-ok', '
|
|
3573
|
-
rejected: ['ai-assistant.text.outcome-rejected', '
|
|
3574
|
-
queued: ['ai-assistant.text.outcome-queued', '
|
|
3575
|
-
proposed: ['ai-assistant.text.outcome-proposed', '
|
|
3576
|
-
folded: ['ai-assistant.text.outcome-folded', '
|
|
3577
|
-
error: ['ai-assistant.text.outcome-error', '
|
|
4211
|
+
ok: ['ai-assistant.text.outcome-ok', 'read'],
|
|
4212
|
+
rejected: ['ai-assistant.text.outcome-rejected', 'rejected'],
|
|
4213
|
+
queued: ['ai-assistant.text.outcome-queued', 'to apply'],
|
|
4214
|
+
proposed: ['ai-assistant.text.outcome-proposed', 'proposed'],
|
|
4215
|
+
folded: ['ai-assistant.text.outcome-folded', 'duplicate'],
|
|
4216
|
+
error: ['ai-assistant.text.outcome-error', 'error']
|
|
3578
4217
|
}
|
|
3579
4218
|
const [key, fallback] = map[outcome] ?? map.ok
|
|
3580
4219
|
return i18next.t(key, { defaultValue: fallback })
|
|
@@ -3719,8 +4358,8 @@ export class OxAssistantChat extends LitElement {
|
|
|
3719
4358
|
|
|
3720
4359
|
const promptText = text || (attachmentsToSend.length > 0
|
|
3721
4360
|
? (attachmentsToSend[0].type.startsWith('image/')
|
|
3722
|
-
? '
|
|
3723
|
-
: '
|
|
4361
|
+
? i18next.t('ai-assistant.text.attached-image-ask', { defaultValue: 'here is an image — go by it.' })
|
|
4362
|
+
: i18next.t('ai-assistant.text.attached-file-ask', { defaultValue: 'here is a file — take a look.' }))
|
|
3724
4363
|
: '')
|
|
3725
4364
|
if (!this.sessionId && this.prepareSession) {
|
|
3726
4365
|
this.busy = true
|
|
@@ -3740,7 +4379,7 @@ export class OxAssistantChat extends LitElement {
|
|
|
3740
4379
|
let requestBase: any
|
|
3741
4380
|
try {
|
|
3742
4381
|
const provided = this.contextProvider?.() || {}
|
|
3743
|
-
requestContext = structuredClone({
|
|
4382
|
+
requestContext = structuredClone({ hostContext: this.conversation.hostContext, ...provided })
|
|
3744
4383
|
liveBoard = structuredClone(this.boardProvider ? this.boardProvider() : this.currentBoard)
|
|
3745
4384
|
requestBase = { version: 1, sessionId: this.sessionId, hostContext: requestContext.hostContext,
|
|
3746
4385
|
modelFingerprint: assistantModelFingerprint(liveBoard) }
|
|
@@ -3825,11 +4464,9 @@ export class OxAssistantChat extends LitElement {
|
|
|
3825
4464
|
? buildAssistantChatInput({
|
|
3826
4465
|
sessionId: this.sessionId,
|
|
3827
4466
|
history,
|
|
3828
|
-
|
|
4467
|
+
mode: { kind: this.conversation.kind!, target: this.conversation.target },
|
|
3829
4468
|
truncateAfterMessageId: this._truncateAfterId,
|
|
3830
|
-
hostContext: requestContext.hostContext
|
|
3831
|
-
toolCategories: this.conversation.toolCategories,
|
|
3832
|
-
requireGroundingTools: this.requireGroundingTools
|
|
4469
|
+
hostContext: requestContext.hostContext
|
|
3833
4470
|
})
|
|
3834
4471
|
: buildChatMutationInput({
|
|
3835
4472
|
sessionId: this.sessionId,
|
|
@@ -3838,7 +4475,8 @@ export class OxAssistantChat extends LitElement {
|
|
|
3838
4475
|
scopes: this.scopes,
|
|
3839
4476
|
truncateAfterMessageId: this._truncateAfterId,
|
|
3840
4477
|
hostContext: requestContext.hostContext,
|
|
3841
|
-
|
|
4478
|
+
/* The board door still takes its categories from the element — it declares no mode. */
|
|
4479
|
+
toolCategories: this.toolCategories,
|
|
3842
4480
|
boardTools: this.boardTools,
|
|
3843
4481
|
requireGroundingTools: this.requireGroundingTools,
|
|
3844
4482
|
knownTypes: this.knownTypes,
|