feat(telegram): display thread ID for DM topics in Sessions tab
- Add ThreadLabel for DM threads (format: 'Thread: N') - Add unit tests for ThreadLabel in DM threads - Fix UI: read URL session param before syncTabWithLocation overwrites it
This commit is contained in:
parent
6372242da7
commit
5cad6d3f9d
@ -56,6 +56,33 @@ describe("buildTelegramMessageContext dm thread sessions", () => {
|
||||
expect(ctx?.ctxPayload?.SessionKey).toBe("agent:main:main:thread:42");
|
||||
});
|
||||
|
||||
it("sets ThreadLabel for dm topics for display in Sessions tab", async () => {
|
||||
const ctx = await buildContext({
|
||||
message_id: 1,
|
||||
chat: { id: 1234, type: "private" },
|
||||
date: 1700000000,
|
||||
text: "hello",
|
||||
message_thread_id: 42,
|
||||
from: { id: 42, first_name: "Alice" },
|
||||
});
|
||||
|
||||
expect(ctx).not.toBeNull();
|
||||
expect(ctx?.ctxPayload?.ThreadLabel).toBe("Thread: 42");
|
||||
});
|
||||
|
||||
it("does not set ThreadLabel for dm without thread id", async () => {
|
||||
const ctx = await buildContext({
|
||||
message_id: 1,
|
||||
chat: { id: 1234, type: "private" },
|
||||
date: 1700000000,
|
||||
text: "hello",
|
||||
from: { id: 42, first_name: "Alice" },
|
||||
});
|
||||
|
||||
expect(ctx).not.toBeNull();
|
||||
expect(ctx?.ctxPayload?.ThreadLabel).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps legacy dm session key when no thread id", async () => {
|
||||
const ctx = await buildContext({
|
||||
message_id: 2,
|
||||
|
||||
@ -606,6 +606,8 @@ export const buildTelegramMessageContext = async ({
|
||||
// For groups: use resolvedThreadId (forum topics only); for DMs: use raw messageThreadId
|
||||
MessageThreadId: isGroup ? resolvedThreadId : messageThreadId,
|
||||
IsForum: isForum,
|
||||
// DM thread label for display in Sessions tab (e.g., "Sender Name (Thread: 42)")
|
||||
ThreadLabel: !isGroup && messageThreadId != null ? `Thread: ${messageThreadId}` : undefined,
|
||||
// Originating channel for reply routing.
|
||||
OriginatingChannel: "telegram" as const,
|
||||
OriginatingTo: `telegram:${chatId}`,
|
||||
|
||||
@ -35,6 +35,8 @@ type LifecycleHost = {
|
||||
|
||||
export function handleConnected(host: LifecycleHost) {
|
||||
host.basePath = inferBasePath();
|
||||
// Apply URL settings FIRST so sessionKey is read before syncTabWithLocation
|
||||
// overwrites it with the localStorage value
|
||||
applySettingsFromUrl(
|
||||
host as unknown as Parameters<typeof applySettingsFromUrl>[0],
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user