Skip to content

Commit cddf841

Browse files
committed
0.18.2: setup pairing start hotfix
1 parent c122805 commit cddf841

6 files changed

Lines changed: 55 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.18.2: setup pairing start hotfix
4+
5+
- `[Setup]` `/telegram-setup` now updates the live in-memory config immediately after persisting the validated bot token and before starting polling. Impact: first-time setup no longer shows `Send /start...` followed by `Telegram bot is not configured`, and `/start` can be received without restarting Pi.
6+
37
## 0.18.1: Windows setup transport hotfix
48

59
- `[Setup]` `/telegram-setup` token validation now uses the same fallback-aware Telegram transport as normal API calls. Impact: Windows/QEMU hosts that fail native `fetch` during bot-token validation can retry through IPv4 fallback instead of failing before config is saved.

lib/setup.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,21 @@ export function createTelegramSetupPromptRuntime<
172172
return async (ctx: TContext): Promise<void> => {
173173
if (!ctx.hasUI || !deps.setupGuard.start()) return;
174174
try {
175-
const nextConfig = await runTelegramSetup({
175+
await runTelegramSetup({
176176
hasUI: ctx.hasUI,
177177
env: deps.env ?? process.env,
178178
config: deps.getConfig(),
179179
promptInput: (label, value) => ctx.ui.input(label, value),
180180
promptEditor: (label, value) => ctx.ui.editor(label, value),
181181
getMe: deps.getMe,
182-
persistConfig: deps.persistConfig,
182+
persistConfig: async (config) => {
183+
await deps.persistConfig(config);
184+
deps.setConfig(config);
185+
},
183186
notify: (message, level) => ctx.ui.notify(message, level),
184187
startPolling: () => deps.startPolling(ctx),
185188
updateStatus: () => deps.updateStatus(ctx),
186189
});
187-
if (nextConfig) deps.setConfig(nextConfig);
188190
} catch (error) {
189191
deps.recordRuntimeEvent?.("setup", error);
190192
throw error;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@llblab/pi-telegram",
3-
"version": "0.18.1",
3+
"version": "0.18.2",
44
"private": false,
55
"publishConfig": {
66
"access": "public"

tests/config.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,11 +662,11 @@ test("Setup prompt runtime guards concurrent setup and stores successful config"
662662
"editor:env-token",
663663
"getMe:new-token",
664664
"persist:new-token",
665+
"set:demo_bot",
665666
"notify:info:Telegram bot connected: @demo_bot",
666667
"notify:info:Send /start to your bot in Telegram to pair this extension with your account.",
667668
"poll",
668669
"status",
669-
"set:demo_bot",
670670
"finish",
671671
"start",
672672
]);

tests/setup.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,48 @@ test("Setup runner reports invalid tokens without persisting or starting polling
109109
assert.deepEqual(calls, ["error:Unauthorized"]);
110110
});
111111

112+
test("Setup prompt runtime stores config before starting polling", async () => {
113+
const calls: string[] = [];
114+
let currentToken: string | undefined;
115+
const runtime = createTelegramSetupPromptRuntime({
116+
env: {},
117+
getConfig: () => ({}),
118+
setConfig: (config) => {
119+
currentToken = config.botToken;
120+
calls.push(`set:${config.botToken}`);
121+
},
122+
setupGuard: {
123+
start: () => true,
124+
finish: () => calls.push("finish"),
125+
},
126+
getMe: async () => ({ ok: true, result: { id: 7, username: "demo_bot" } }),
127+
persistConfig: async (config) => {
128+
calls.push(`persist:${config.botToken}`);
129+
},
130+
startPolling: () => calls.push(`start:${currentToken ?? "missing"}`),
131+
updateStatus: () => calls.push("status"),
132+
});
133+
134+
await runtime({
135+
hasUI: true,
136+
ui: {
137+
input: async () => "token",
138+
editor: async () => "token",
139+
notify: (message) => calls.push(`notify:${message}`),
140+
},
141+
});
142+
143+
assert.deepEqual(calls, [
144+
"persist:token",
145+
"set:token",
146+
"notify:Telegram bot connected: @demo_bot",
147+
"notify:Send /start to your bot in Telegram to pair this extension with your account.",
148+
"start:token",
149+
"status",
150+
"finish",
151+
]);
152+
});
153+
112154
test("Setup prompt runtime reports token check errors and always finishes", async () => {
113155
const calls: string[] = [];
114156
let locked = false;

0 commit comments

Comments
 (0)