lazy-gravity 0.5.4 → 0.5.5

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.
@@ -177,12 +177,37 @@ function createMessageCreateHandler(deps) {
177
177
  registerApprovalSessionChannel(deps.bridge, projectName, session.displayName, platformChannel);
178
178
  }
179
179
  if (session?.isRenamed && session.displayName) {
180
- const activationResult = await deps.chatSessionService.activateSessionByTitle(cdp, session.displayName);
180
+ let activationResult = await deps.chatSessionService.activateSessionByTitle(cdp, session.displayName);
181
181
  if (!activationResult.ok) {
182
- const reason = activationResult.error ? ` (${activationResult.error})` : '';
183
- await message.reply(`⚠️ Could not route this message to the bound session (${session.displayName}). ` +
184
- `Please open /chat and verify the session${reason}.`).catch(() => { });
185
- return;
182
+ // Recovery: Antigravity may have renamed the session.
183
+ // Check if the currently active chat is the renamed version.
184
+ const currentInfo = await deps.chatSessionService.getCurrentSessionInfo(cdp);
185
+ const isRecoverable = currentInfo.hasActiveChat
186
+ && currentInfo.title.trim() !== ''
187
+ && currentInfo.title !== session.displayName;
188
+ if (isRecoverable) {
189
+ const siblings = deps.chatSessionRepo.findByCategoryId(session.categoryId);
190
+ const ownedByOther = siblings.some((s) => s.channelId !== message.channelId
191
+ && s.displayName === currentInfo.title);
192
+ if (!ownedByOther) {
193
+ const recoveredTitle = currentInfo.title;
194
+ const retryResult = await deps.chatSessionService.activateSessionByTitle(cdp, recoveredTitle);
195
+ if (retryResult.ok) {
196
+ logger_1.logger.info(`[SessionRecovery] Adopting renamed title: ` +
197
+ `"${session.displayName}" -> "${recoveredTitle}" ` +
198
+ `(channel: ${message.channelId})`);
199
+ deps.chatSessionRepo.updateDisplayName(message.channelId, recoveredTitle);
200
+ registerApprovalSessionChannel(deps.bridge, projectName, recoveredTitle, platformChannel);
201
+ }
202
+ activationResult = retryResult;
203
+ }
204
+ }
205
+ if (!activationResult.ok) {
206
+ const reason = activationResult.error ? ` (${activationResult.error})` : '';
207
+ await message.reply(`⚠️ Could not route this message to the bound session (${session.displayName}). ` +
208
+ `Please open /chat and verify the session${reason}.`).catch(() => { });
209
+ return;
210
+ }
186
211
  }
187
212
  }
188
213
  else if (session && !session.isRenamed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lazy-gravity",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Control Antigravity from anywhere — a local, secure bot (Discord + Telegram) that lets you remotely operate Antigravity on your home PC from your smartphone.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {