[NELO-1102] feat(im): add thread-based session mode for IM channels

Add session_mode ("user" | "thread") to IM channel config. In thread
mode, each message thread gets its own session, enabling multi-user
collaboration within the same thread context.

Backend:
- Add SessionMode type constants and validation
- Add ThreadID field to IncomingMessage and ChannelSession
- Split resolveSession into resolveUserSession/resolveThreadSession
- Update makeUserKey to include threadID only in thread mode
- Extract ThreadID in Slack, Mattermost, Feishu, Telegram adapters
- Add message_thread_id to Telegram SendReply/StartStream for Forums
- DB migration 000028: session_mode column + thread_id column + index

Frontend:
- Add session_mode radio group to IMChannelPanel dialog
- Auto-reset session_mode when switching to non-thread platform
- Show thread badge on channel card for thread-mode channels
- Add i18n keys for en-US, ko-KR, zh-CN, ru-RU
This commit is contained in:
ochan.kwon
2026-03-27 20:49:10 +09:00
committed by lyingbug
parent 930a953f41
commit 2d5782992e
22 changed files with 1015 additions and 22 deletions
@@ -37,6 +37,10 @@
<t-icon name="play-circle" class="meta-icon" />
{{ channel.output_mode === 'stream' ? $t('agentEditor.im.outputStream') : $t('agentEditor.im.outputFull') }}
</span>
<span v-if="channel.session_mode === 'thread'" class="meta-tag">
<t-icon name="chat" class="meta-icon" />
{{ $t('agentEditor.im.sessionModeThread') }}
</span>
</div>
<div v-if="channel.mode === 'webhook'" class="callback-url-row">
<span class="url-label">{{ $t('agentEditor.im.callbackUrl') }}:</span>
@@ -121,6 +125,19 @@
</t-radio-group>
</div>
<!-- Session Mode -->
<div class="form-item">
<label class="form-label">{{ $t('agentEditor.im.sessionMode') }}</label>
<t-radio-group v-model="formData.session_mode">
<t-radio-button value="user">{{ $t('agentEditor.im.sessionModeUser') }}</t-radio-button>
<t-radio-button value="thread"
:disabled="!platformSupportsThread(formData.platform)">
{{ $t('agentEditor.im.sessionModeThread') }}
</t-radio-button>
</t-radio-group>
<p class="form-hint">{{ $t('agentEditor.im.sessionModeHint') }}</p>
</div>
<!-- Knowledge base for file messages -->
<div class="form-item">
<label class="form-label">{{ $t('agentEditor.im.fileKnowledgeBase') }}</label>
@@ -356,6 +373,7 @@ const formData = ref({
name: '',
mode: 'websocket' as 'webhook' | 'websocket',
output_mode: 'stream' as 'stream' | 'full',
session_mode: 'user' as 'user' | 'thread',
knowledge_base_id: '',
credentials: defaultCredentials(),
});
@@ -365,6 +383,10 @@ function platformLabel(platform: string): string {
return t(key);
}
function platformSupportsThread(platform: string): boolean {
return ['slack', 'mattermost', 'feishu', 'telegram'].includes(platform);
}
watch(
() => formData.value.platform,
(p) => {
@@ -374,6 +396,9 @@ watch(
formData.value.credentials.post_to_main = false;
}
}
if (!platformSupportsThread(p)) {
formData.value.session_mode = 'user';
}
},
);
@@ -427,6 +452,7 @@ function editChannel(channel: IMChannel) {
name: channel.name,
mode: channel.mode,
output_mode: channel.output_mode,
session_mode: channel.session_mode || 'user',
knowledge_base_id: channel.knowledge_base_id || '',
credentials: { ...channel.credentials },
};
@@ -440,6 +466,7 @@ function resetForm() {
name: '',
mode: 'websocket',
output_mode: 'stream',
session_mode: 'user',
knowledge_base_id: '',
credentials: defaultCredentials(),
};
@@ -452,6 +479,7 @@ async function handleSave() {
name: formData.value.name,
mode: formData.value.mode,
output_mode: formData.value.output_mode,
session_mode: formData.value.session_mode,
knowledge_base_id: formData.value.knowledge_base_id,
credentials: formData.value.credentials,
});
@@ -462,6 +490,7 @@ async function handleSave() {
name: formData.value.name,
mode: formData.value.mode,
output_mode: formData.value.output_mode,
session_mode: formData.value.session_mode,
knowledge_base_id: formData.value.knowledge_base_id,
credentials: formData.value.credentials,
});