Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion WORKLOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Worklog

## 2026-07-08

### nx2/blocks/chat — agent-id as a plain attribute (feat/chat-agent-id branch, PR #462)

Reviewer consensus (sharanyavinod + mhaack) on #462: `agentId` should not be a reactive Lit property since it is not used for rendering. Keeping it reactive re-renders `<nx-chat>` on `agent-id` changes for no benefit today.

- Removed `agentId: { type: String, attribute: 'agent-id' }` from `static properties`.
- Read the value once in `connectedCallback` via `getAttribute('agent-id')` and forward it to the controller's `setAgentId`.
- Dropped the `agentId` branch from `updated(changed)` (no longer observed).
- Controller plumbing unchanged: `setAgentId` stores `_agentId`, sent as `agentId` in the request body only when set.
- Documented the `agent-id` attribute and its request-body contract in `docs/chat-ui-component.md`.

If we later drive rendering from the agent id, reintroduce it as a reactive property then (per the review thread).

## 2026-06-26

### nx2/blocks/chat/chat.js — skill selection preserves pending attachments (feat/da-skill-attachment-fix)
Expand All @@ -14,7 +28,6 @@ Post-review follow-up (fe049a9b):
- Renamed loop variable `i` → `item` in `_onSlashSelect` callbacks
- Added regression tests in `test/nx2/blocks/chat/chat.test.js` (8 tests, all pass)


## 2026-06-23

### nx2/blocks/shared/dialog — configurable panel sizing (dialog-css-vars branch)
Expand Down
8 changes: 7 additions & 1 deletion docs/chat-ui-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ The component manages its own controller internally. No external wiring needed.
| `thinking` | `Boolean` | Agent is processing. Disables input. |
| `context` | `Object` | Page context: `{ org, site, path, view }`. Required — set by the host view. `view` must be `browse` or `edit`. |

## Attributes in

| Attribute | Type | Description |
| ---------- | -------- | ----------------------------------------------------------------------------------------------- |
| `agent-id` | `String` | Optional. Selects a specific agent/persona. Read once on mount and forwarded to the agent as `agentId` in the request body. Not a reactive property — set it before mount; later changes are not observed. |

**Message shape:**

```js
Expand All @@ -30,7 +36,7 @@ The component manages its own controller internally. No external wiring needed.
{ role: 'tool', ... } // filtered from display automatically
```

**Request body:** The controller POSTs `{ messages, pageContext, imsToken, room, sessionId }` to the agent. `sessionId` is a UUID scoped to the current conversation session — it resets when the user clears the chat. Selection context is embedded on individual user messages (see [Selection context](#selection-context)) rather than as a top-level request field.
**Request body:** The controller POSTs `{ messages, pageContext, imsToken, room, sessionId }` to the agent (plus `agentId` when the `agent-id` attribute is set). `sessionId` is a UUID scoped to the current conversation session — it resets when the user clears the chat. Selection context is embedded on individual user messages (see [Selection context](#selection-context)) rather than as a top-level request field.

## Methods

Expand Down
5 changes: 5 additions & 0 deletions nx2/blocks/chat/chat-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export default class ChatController {
this._room = null;
}

setAgentId(id) {
this._agentId = id;
}

_pageContextForAgent() {
const { org, site, path, view } = this._context ?? {};
return org && site ? { org, site, path: path ?? '', view } : undefined;
Expand Down Expand Up @@ -370,6 +374,7 @@ export default class ChatController {
pageContext,
imsToken: accessToken?.token ?? null,
room,
...(this._agentId ? { agentId: this._agentId } : {}),
sessionId: this._sessionId,
...(this._requestedSkills?.length ? { requestedSkills: this._requestedSkills } : {}),
...(this._pendingAttachments?.length ? { attachments: this._pendingAttachments } : {}),
Expand Down
2 changes: 2 additions & 0 deletions nx2/blocks/chat/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ class NxChat extends LitElement {
},
});
if (this._context) this._controller.setContext(this._context);
const agentId = this.getAttribute('agent-id');
if (agentId) this._controller.setAgentId(agentId);

this._unsubscribeHash = hashChange.subscribe((state) => {
if (!this._explicitContext) this._applyContext(state);
Expand Down
Loading