Skip to content

feat(chat): add sessionId to chat sessions#453

Merged
mhaack merged 11 commits into
mainfrom
ew-session
May 22, 2026
Merged

feat(chat): add sessionId to chat sessions#453
mhaack merged 11 commits into
mainfrom
ew-session

Conversation

@mhaack
Copy link
Copy Markdown
Contributor

@mhaack mhaack commented May 20, 2026

Summary

  • Adds a sessionId (UUID) to every chat conversation, stored in IndexedDB
    alongside messages so it survives page reloads and is shared across tabs
    on the same room
  • New session ID is generated on first open (no existing record) and
    regenerated when the user clears the chat; sent to the agent in every
    POST body so it can scope server-side state per session
  • persistence.js updated: loadMessages now returns { messages, sessionId },
    saveMessages accepts sessionId, new resetSession writes empty messages
    • new ID atomically (replaces clearMessages in the reset flow)

Sample Chat message:

{
  "messages": [
    {
      "role": "user",
      "content": "Please summarize the content of this page in a few sentences."
    }
  ],
  "pageContext": {
    "org": "exp-workspace",
    "site": "frescopa",
    "path": "coffee",
    "view": "drafts/hhertach/canvas"
  },
  "imsToken": "....",
  "room": "exp-workspace--frescopa--84361F84631C33D60A495C11@7eeb20f8631c0cb7495c06.e",
  "sessionId": "348c84e6-4eec-4dde-a7c4-7b2583bb194a"
}

URL: https://ew-session--da-nx--adobe.aem.live/

Test Plan

  • 8 new unit tests for the persistence layer pass (npx wtr test/nx2/blocks/chat/persistence.test.js --node-resolve)
  • Verify IDB record contains sessionId after first message in browser DevTools (Application → IndexedDB → da-chat → conversations)
  • Reload page — same sessionId appears in next agent POST (Network tab)
  • Open second tab on same URL — same sessionId used
  • Click "Clear chat" — new sessionId written to IDB, old one gone

@aem-code-sync
Copy link
Copy Markdown

aem-code-sync Bot commented May 20, 2026

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

Comment thread nx2/blocks/chat/chat-controller.js Outdated
Comment thread nx2/blocks/chat/persistence.js Outdated
Comment thread nx2/blocks/chat/persistence.js
Comment thread test/nx2/blocks/chat/persistence.test.js
Comment thread test/nx2/blocks/chat/persistence.test.js Outdated
@sharanyavinod
Copy link
Copy Markdown
Contributor

@mhaack Could you please update docs/chat-ui-component.md to reflect the changes?

@mhaack
Copy link
Copy Markdown
Contributor Author

mhaack commented May 21, 2026

@mhaack Could you please update docs/chat-ui-component.md to reflect the changes?

@sharanyavinod yes good point, done

@anfibiacreativa anfibiacreativa self-requested a review May 22, 2026 10:20
@mhaack mhaack merged commit bc9d582 into main May 22, 2026
3 checks passed
@mhaack mhaack deleted the ew-session branch May 22, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants