clay-server 2.11.0-beta.8 → 2.11.0-beta.9
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/lib/project.js +20 -1
- package/package.json +1 -1
package/lib/project.js
CHANGED
|
@@ -1138,7 +1138,20 @@ function createProjectContext(opts) {
|
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
1140
|
}
|
|
1141
|
-
if
|
|
1141
|
+
// Auto-create a session if none exist for this client
|
|
1142
|
+
var autoCreated = false;
|
|
1143
|
+
if (!active) {
|
|
1144
|
+
var autoOpts = {};
|
|
1145
|
+
if (wsUser) autoOpts.ownerId = wsUser.id;
|
|
1146
|
+
active = sm.createSession(autoOpts, ws);
|
|
1147
|
+
autoCreated = true;
|
|
1148
|
+
}
|
|
1149
|
+
if (active && !autoCreated) {
|
|
1150
|
+
// Backfill ownerId for legacy sessions restored without one
|
|
1151
|
+
if (!active.ownerId && wsUser) {
|
|
1152
|
+
active.ownerId = wsUser.id;
|
|
1153
|
+
sm.saveSessionFile(active);
|
|
1154
|
+
}
|
|
1142
1155
|
ws._clayActiveSession = active.localId;
|
|
1143
1156
|
sendTo(ws, { type: "session_switched", id: active.localId, cliSessionId: active.cliSessionId || null, loop: active.loop || null });
|
|
1144
1157
|
|
|
@@ -2902,6 +2915,12 @@ function createProjectContext(opts) {
|
|
|
2902
2915
|
var session = getSessionForWs(ws);
|
|
2903
2916
|
if (!session) return;
|
|
2904
2917
|
|
|
2918
|
+
// Backfill ownerId for legacy sessions restored without one
|
|
2919
|
+
if (!session.ownerId && ws._clayUser) {
|
|
2920
|
+
session.ownerId = ws._clayUser.id;
|
|
2921
|
+
sm.saveSessionFile(session);
|
|
2922
|
+
}
|
|
2923
|
+
|
|
2905
2924
|
var userMsg = { type: "user_message", text: msg.text || "" };
|
|
2906
2925
|
if (msg.images && msg.images.length > 0) {
|
|
2907
2926
|
userMsg.imageCount = msg.images.length;
|