You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/08/13 10:58:57 UTC

[PR] feat: expose AI conversation history on Studio home [rocketmq-dashboard]

Aias00 opened a new pull request, #2111:
URL: https://github.com/apache/rocketmq-dashboard/pull/2111

   ## Summary
   
   Closes #2110
   
   - turn the home-page history icon into an accessible conversation-history drawer
   - persist AI chat history for the browser session and isolate it between Real and Mock modes
   - list recent prompts for the active mode and navigate to `/ai` to resume the saved conversation
   - provide an explicit empty state
   
   ## Verification
   
   - `npx vitest run src/stores/aiChatHistoryStore.test.ts src/pages/home/__tests__/HomePage.test.tsx src/pages/ai/__tests__/AiPage.test.tsx`
   - `npm run build`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(ai): preserve bounded conversation history [rocketmq-dashboard]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on PR #2111:
URL: https://github.com/apache/rocketmq-dashboard/pull/2111#issuecomment-5322529590

   Superseded by #2309, which consolidates this change and is CLEAN with all CI checks passing.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(ai): preserve bounded conversation history [rocketmq-dashboard]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on PR #2111:
URL: https://github.com/apache/rocketmq-dashboard/pull/2111#issuecomment-5292877126

   Follow-up hardening update:
   
   - Clears in-browser AI history on logout and authentication failure.
   - Bounds malformed/oversized persisted history, throttles stream persistence, and flushes on stream completion.
   - Cancels active streams when switching Mock/Real mode and uses collision-resistant conversation IDs.
   
   Validated with 30 targeted frontend tests and `npm run build`. User-ID partitioning remains a follow-up integration once #2162 is merged, rather than duplicating the new auth model in this PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(ai): preserve bounded conversation history [rocketmq-dashboard]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on PR #2111:
URL: https://github.com/apache/rocketmq-dashboard/pull/2111#issuecomment-5290640838

   Addressed the review feedback:
   
   - rebased onto the latest `rocketmq-studio` and squashed the branch into `1c721b8e`;
   - localized the history drawer labels and relative timestamps;
   - extracted the shared `getRecentAiChatConversations` selector;
   - capped persisted history at 20 conversations and 100 messages per conversation;
   - aborts in-flight streams before switching conversations, so stale callbacks cannot restore the old selection or leave a pending spinner.
   
   Verified with `npm run lint` (two existing warnings outside this PR), the targeted 25-test suite, and `npm run build`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(ai): preserve bounded conversation history [rocketmq-dashboard]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on PR #2111:
URL: https://github.com/apache/rocketmq-dashboard/pull/2111#issuecomment-5291585051

   Follow-up rebase complete: the branch is now based on `eb44e159` and remains a single feature commit.
   
   Revalidated after the rebase:
   - `npm test -- --run src/pages/ai/__tests__/AiPage.test.tsx src/pages/home/__tests__/HomePage.test.tsx src/stores/aiChatHistoryStore.test.ts src/utils/format.test.ts` (25 passed)
   - `npm run build`
   - `npm run lint` (no errors; one existing warning in `src/pages/instance/topic.tsx`, outside this PR)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(ai): preserve bounded conversation history [rocketmq-dashboard]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on PR #2111:
URL: https://github.com/apache/rocketmq-dashboard/pull/2111#issuecomment-5310716312

   The branch has been rebuilt as two clean commits on current `rocketmq-studio` (`eb44e159`), replacing the earlier iterative history. The current implementation addresses the requested items: locale-aware relative time via translations, shared `getRecentAiChatConversations`, bounded conversation/message/byte limits, throttled sessionStorage persistence, and pending-state cleanup on conversation changes. Re-ran the focused history suite successfully: 28/28 tests across AI page, home page, history store, and date-format tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: expose AI conversation history on Studio home [rocketmq-dashboard]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on code in PR #2111:
URL: https://github.com/apache/rocketmq-dashboard/pull/2111#discussion_r3775012020


##########
web/src/pages/ai/index.tsx:
##########
@@ -511,6 +541,7 @@ const AiPage = () => {
 

Review Comment:
   Using `Date.now()` for conversation IDs (`conversation-${Date.now()}`) is fine for single-user browser sessions, but if this store is ever shared or persisted across tabs, there's a small collision risk. For now this is acceptable since it's browser-local state.



##########
web/src/stores/aiChatHistoryStore.ts:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { create } from 'zustand';
+import { createJSONStorage, persist } from 'zustand/middleware';
+
+export interface AiChatMessage {
+  id: string;
+  role: 'user' | 'ai';
+  text?: string;
+  summary?: string;
+  thinking?: string;
+  pending?: boolean;
+}
+
+export type AiChatDataMode = 'mock' | 'real';
+
+export interface AiChatConversation {
+  id: string;
+  messages: AiChatMessage[];
+  updatedAt: number;
+}
+
+export interface AiChatHistory {
+  conversations: AiChatConversation[];
+  activeConversationId: string | null;
+}
+
+interface AiChatHistoryState {
+  histories: Record<AiChatDataMode, AiChatHistory>;
+  startConversation: (mode: AiChatDataMode, conversationId: string) => void;
+  selectConversation: (mode: AiChatDataMode, conversationId: string) => void;
+  setMessages: (
+    mode: AiChatDataMode,
+    conversationId: string,
+    messages: AiChatMessage[] | ((messages: AiChatMessage[]) => AiChatMessage[]),
+  ) => void;
+}
+
+const emptyHistory = (): AiChatHistory => ({ conversations: [], activeConversationId: null });
+
+const restoreMessages = (messages?: AiChatMessage[]): AiChatMessage[] =>
+  (messages ?? []).map((message) => (message.pending ? { ...message, pending: false } : message));
+
+const restoreHistory = (history?: Partial<AiChatHistory> & { messages?: AiChatMessage[]; conversationId?: string | null }): AiChatHistory => {
+  if (history?.conversations) {
+    const conversations = history.conversations.map((conversation) => ({
+      ...conversation,
+      messages: restoreMessages(conversation.messages),
+    }));
+    return {
+      conversations,
+      activeConversationId: conversations.some((item) => item.id === history.activeConversationId)
+        ? history.activeConversationId ?? null
+        : conversations[0]?.id ?? null,

Review Comment:
   The `restoreHistory` function handles legacy migration from a flat `messages`/`conversationId` shape to the new multi-conversation structure. This is good forward-thinking design. Consider adding a brief comment noting this is for backward compatibility with pre-multi-conversation state, so future maintainers don't remove it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(ai): preserve bounded conversation history [rocketmq-dashboard]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on PR #2111:
URL: https://github.com/apache/rocketmq-dashboard/pull/2111#issuecomment-5290630340

   Addressed the review feedback:\n\n- rebased onto the latest  and squashed the branch into ;\n- localized the history drawer labels and relative timestamps;\n- extracted the shared  selector;\n- capped persisted history at 20 conversations and 100 messages per conversation;\n- aborts in-flight streams before switching conversations, so stale callbacks cannot restore the old selection or leave a pending spinner.\n\nVerified with  (two existing warnings outside this PR), the targeted 25-test suite, and .


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(ai): preserve bounded conversation history [rocketmq-dashboard]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 closed pull request #2111: feat(ai): preserve bounded conversation history
URL: https://github.com/apache/rocketmq-dashboard/pull/2111


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org