@djangocfg/layouts 2.1.8 → 2.1.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/layouts",
3
- "version": "2.1.8",
3
+ "version": "2.1.10",
4
4
  "description": "Simple, straightforward layout components for Next.js - import and use with props",
5
5
  "keywords": [
6
6
  "layouts",
@@ -92,9 +92,9 @@
92
92
  "check": "tsc --noEmit"
93
93
  },
94
94
  "peerDependencies": {
95
- "@djangocfg/api": "^2.1.8",
96
- "@djangocfg/centrifugo": "^2.1.8",
97
- "@djangocfg/ui-nextjs": "^2.1.8",
95
+ "@djangocfg/api": "^2.1.10",
96
+ "@djangocfg/centrifugo": "^2.1.10",
97
+ "@djangocfg/ui-nextjs": "^2.1.10",
98
98
  "@hookform/resolvers": "^5.2.0",
99
99
  "consola": "^3.4.2",
100
100
  "lucide-react": "^0.545.0",
@@ -114,7 +114,7 @@
114
114
  "uuid": "^11.1.0"
115
115
  },
116
116
  "devDependencies": {
117
- "@djangocfg/typescript-config": "^2.1.8",
117
+ "@djangocfg/typescript-config": "^2.1.10",
118
118
  "@types/node": "^24.7.2",
119
119
  "@types/react": "^19.1.0",
120
120
  "@types/react-dom": "^19.1.0",
@@ -86,9 +86,13 @@ async function saveMessageToServer(threadId: string, userId: string, message: AI
86
86
  /**
87
87
  * Load conversation from server
88
88
  */
89
- async function loadConversationFromServer(threadId: string): Promise<AIChatMessage[]> {
89
+ async function loadConversationFromServer(threadId: string): Promise<AIChatMessage[] | null> {
90
90
  try {
91
91
  const response = await fetch(`${mcpEndpoints.conversations}/${threadId}`);
92
+
93
+ // If conversation not found (404), return null to signal reset needed
94
+ if (response.status === 404) return null;
95
+
92
96
  if (!response.ok) return [];
93
97
 
94
98
  const data = await response.json();
@@ -170,13 +174,22 @@ export function useAIChat(options: UseAIChatOptions): UseAIChatReturn {
170
174
 
171
175
  const loadHistory = async () => {
172
176
  const serverMessages = await loadConversationFromServer(threadId);
173
- if (serverMessages.length > 0) {
177
+
178
+ // If server returned null (404), session is expired/invalid
179
+ if (serverMessages === null) {
180
+ console.log('[Chat] Session expired or invalid, starting new session');
181
+ const newThreadId = generateThreadId();
182
+ setThreadId(newThreadId);
183
+ persistThreadId(newThreadId, userId);
184
+ setMessages([]); // Ensure empty state
185
+ } else if (serverMessages.length > 0) {
174
186
  setMessages(serverMessages);
175
187
  }
188
+
176
189
  setIsLoadingHistory(false);
177
190
  };
178
191
  loadHistory();
179
- }, [threadId]);
192
+ }, [threadId, userId]);
180
193
 
181
194
  /**
182
195
  * Send message with streaming support