lazy-gravity 0.5.3 ā 0.5.4
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.
|
@@ -97,13 +97,22 @@ class JoinCommandHandler {
|
|
|
97
97
|
// Step 1: Check if a channel already exists for this session
|
|
98
98
|
const existingSession = this.chatSessionRepo.findByDisplayName(projectName, selectedTitle);
|
|
99
99
|
if (existingSession) {
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
const channel = await guild.channels.fetch(existingSession.channelId).catch(() => null);
|
|
101
|
+
if (channel) {
|
|
102
|
+
const embed = new discord_js_1.EmbedBuilder()
|
|
103
|
+
.setTitle((0, i18n_1.t)('š Session Already Connected'))
|
|
104
|
+
.setDescription((0, i18n_1.t)(`This session already has a channel:\nā <#${existingSession.channelId}>`))
|
|
105
|
+
.setColor(0x3498DB)
|
|
106
|
+
.setTimestamp();
|
|
107
|
+
await interaction.editReply({ embeds: [embed], components: [] });
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
// Clean up stale bindings since the channel is gone
|
|
112
|
+
logger_1.logger.info(`[Cleanup] Removed stale session binding for deleted channel ${existingSession.channelId}`);
|
|
113
|
+
this.chatSessionRepo.deleteByChannelId(existingSession.channelId);
|
|
114
|
+
this.bindingRepo.deleteByChannelId(existingSession.channelId);
|
|
115
|
+
}
|
|
107
116
|
}
|
|
108
117
|
// Step 2: Connect to CDP
|
|
109
118
|
let cdp;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.WorkspaceCommandHandler = exports.WORKSPACE_SELECT_ID = exports.PROJECT_SELECT_ID = void 0;
|
|
7
7
|
const i18n_1 = require("../utils/i18n");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const logger_1 = require("../utils/logger");
|
|
9
10
|
const discord_js_1 = require("discord.js");
|
|
10
11
|
const projectListUi_1 = require("../ui/projectListUi");
|
|
11
12
|
// Re-export for backward compatibility
|
|
@@ -22,6 +23,41 @@ class WorkspaceCommandHandler {
|
|
|
22
23
|
workspaceService;
|
|
23
24
|
channelManager;
|
|
24
25
|
processingWorkspaces = new Set();
|
|
26
|
+
/**
|
|
27
|
+
* Filters out stale bindings where the Discord channel no longer exists.
|
|
28
|
+
* Deletes stale bindings from the repository.
|
|
29
|
+
*/
|
|
30
|
+
async getValidBindings(bindings, guild) {
|
|
31
|
+
const validBindings = [];
|
|
32
|
+
for (const b of bindings) {
|
|
33
|
+
try {
|
|
34
|
+
// Try fetching the channel from Discord API
|
|
35
|
+
try {
|
|
36
|
+
const channel = await guild.channels.fetch(b.channelId);
|
|
37
|
+
if (channel)
|
|
38
|
+
validBindings.push(b);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
// Only cleanup for confirmed deleted channels (code 10003)
|
|
42
|
+
if (error instanceof discord_js_1.DiscordAPIError && error.code === 10003) {
|
|
43
|
+
logger_1.logger.info(`[Cleanup] Removed stale binding for deleted channel ${b.channelId}`);
|
|
44
|
+
this.chatSessionRepo.deleteByChannelId(b.channelId);
|
|
45
|
+
this.bindingRepo.deleteByChannelId(b.channelId);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
// Transient failures: preserve binding for next validation attempt
|
|
49
|
+
logger_1.logger.error(`[Cleanup] Failed to validate binding for channel ${b.channelId}`, error);
|
|
50
|
+
validBindings.push(b);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
logger_1.logger.error(`[Cleanup] Failed to remove stale binding for channel ${b.channelId}`, error);
|
|
55
|
+
this.chatSessionRepo.deleteByChannelId(b.channelId);
|
|
56
|
+
this.bindingRepo.deleteByChannelId(b.channelId);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return validBindings;
|
|
60
|
+
}
|
|
25
61
|
constructor(bindingRepo, chatSessionRepo, workspaceService, channelManager) {
|
|
26
62
|
this.bindingRepo = bindingRepo;
|
|
27
63
|
this.chatSessionRepo = chatSessionRepo;
|
|
@@ -61,7 +97,8 @@ class WorkspaceCommandHandler {
|
|
|
61
97
|
return;
|
|
62
98
|
}
|
|
63
99
|
// Check if the same project is already bound (prevent duplicates)
|
|
64
|
-
|
|
100
|
+
let existingBindings = this.bindingRepo.findByWorkspacePathAndGuildId(workspacePath, guild.id);
|
|
101
|
+
existingBindings = await this.getValidBindings(existingBindings, guild);
|
|
65
102
|
if (existingBindings.length > 0) {
|
|
66
103
|
const channelLinks = existingBindings.map(b => `<#${b.channelId}>`).join(', ');
|
|
67
104
|
const fullPath = this.workspaceService.getWorkspacePath(workspacePath);
|
|
@@ -148,7 +185,8 @@ class WorkspaceCommandHandler {
|
|
|
148
185
|
}
|
|
149
186
|
// Check for existing project
|
|
150
187
|
if (this.workspaceService.exists(name)) {
|
|
151
|
-
|
|
188
|
+
let existingBindings = this.bindingRepo.findByWorkspacePathAndGuildId(name, guild.id);
|
|
189
|
+
existingBindings = await this.getValidBindings(existingBindings, guild);
|
|
152
190
|
if (existingBindings.length > 0) {
|
|
153
191
|
const channelLinks = existingBindings.map(b => `<#${b.channelId}>`).join(', ');
|
|
154
192
|
await interaction.editReply({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lazy-gravity",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
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": {
|