mattermost-claude-code 0.3.3 → 0.3.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.
- package/dist/claude/session.d.ts +2 -0
- package/dist/claude/session.js +16 -0
- package/dist/index.js +7 -0
- package/package.json +1 -1
package/dist/claude/session.d.ts
CHANGED
|
@@ -87,6 +87,8 @@ export declare class SessionManager {
|
|
|
87
87
|
sendFollowUp(threadId: string, message: string): Promise<void>;
|
|
88
88
|
/** Kill a specific session */
|
|
89
89
|
killSession(threadId: string): void;
|
|
90
|
+
/** Cancel a session with user feedback */
|
|
91
|
+
cancelSession(threadId: string, username: string): Promise<void>;
|
|
90
92
|
/** Kill all active sessions (for graceful shutdown) */
|
|
91
93
|
killAllSessions(): void;
|
|
92
94
|
/** Cleanup idle sessions that have exceeded timeout */
|
package/dist/claude/session.js
CHANGED
|
@@ -129,6 +129,7 @@ export class SessionManager {
|
|
|
129
129
|
};
|
|
130
130
|
// Register session
|
|
131
131
|
this.sessions.set(actualThreadId, session);
|
|
132
|
+
this.registerPost(post.id, actualThreadId); // For cancel reactions on session start post
|
|
132
133
|
const shortId = actualThreadId.substring(0, 8);
|
|
133
134
|
console.log(` ▶ Session #${this.sessions.size} started (${shortId}…) by @${username}`);
|
|
134
135
|
// Start typing indicator immediately so user sees activity
|
|
@@ -388,6 +389,11 @@ export class SessionManager {
|
|
|
388
389
|
const session = this.getSessionByPost(postId);
|
|
389
390
|
if (!session)
|
|
390
391
|
return;
|
|
392
|
+
// Handle cancel reactions (❌ or 🛑) on any post in the session
|
|
393
|
+
if (emojiName === 'x' || emojiName === 'octagonal_sign' || emojiName === 'stop_sign') {
|
|
394
|
+
await this.cancelSession(session.threadId, username);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
391
397
|
// Handle approval reactions
|
|
392
398
|
if (session.pendingApproval && session.pendingApproval.postId === postId) {
|
|
393
399
|
await this.handleApprovalReaction(session, emojiName, username);
|
|
@@ -708,6 +714,16 @@ export class SessionManager {
|
|
|
708
714
|
const shortId = threadId.substring(0, 8);
|
|
709
715
|
console.log(` ✖ Session killed (${shortId}…) — ${this.sessions.size} active`);
|
|
710
716
|
}
|
|
717
|
+
/** Cancel a session with user feedback */
|
|
718
|
+
async cancelSession(threadId, username) {
|
|
719
|
+
const session = this.sessions.get(threadId);
|
|
720
|
+
if (!session)
|
|
721
|
+
return;
|
|
722
|
+
const shortId = threadId.substring(0, 8);
|
|
723
|
+
console.log(` 🛑 Session (${shortId}…) cancelled by @${username}`);
|
|
724
|
+
await this.mattermost.createPost(`🛑 **Session cancelled** by @${username}`, threadId);
|
|
725
|
+
this.killSession(threadId);
|
|
726
|
+
}
|
|
711
727
|
/** Kill all active sessions (for graceful shutdown) */
|
|
712
728
|
killAllSessions() {
|
|
713
729
|
const count = this.sessions.size;
|
package/dist/index.js
CHANGED
|
@@ -50,6 +50,13 @@ Usage: cd /your/project && mm-claude`);
|
|
|
50
50
|
const content = mattermost.isBotMentioned(message)
|
|
51
51
|
? mattermost.extractPrompt(message)
|
|
52
52
|
: message.trim();
|
|
53
|
+
// Check for stop/cancel commands
|
|
54
|
+
const lowerContent = content.toLowerCase();
|
|
55
|
+
if (lowerContent === '/stop' || lowerContent === 'stop' ||
|
|
56
|
+
lowerContent === '/cancel' || lowerContent === 'cancel') {
|
|
57
|
+
await session.cancelSession(threadRoot, username);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
53
60
|
if (content)
|
|
54
61
|
await session.sendFollowUp(threadRoot, content);
|
|
55
62
|
return;
|