Personal Telegram developer console for GitHub

fix: consolidate repository PR navigation (#35)

Routes the existing repository PR button to the actionable advanced PR report and removes the duplicate PR entry. RED-first coverage proves drill-down behavior and preserves side-effect-free routing. PR head CI #331 passed before merge.

davoodmehraban89 committed Oct 4, 2026 at 17:57 UTC a00a6fab007cd39b868e8f60e95183ced5694ac2
3 files changed +20 -7
src/plugins/github/plugin.js
+3 -4
@@ -96,10 +96,7 @@ const addRepoAdvancedButtons = (view, repoId) => {
96 const insertAt = Math.max(0, rows.length - 1);
97 rows.splice(insertAt, 0,
98 [{ text: '🧪 CI / Actions', callback_data: `runs:${repoId}` }],
99 - [
100 - { text: '🌿 Branches', callback_data: `branches:${repoId}` },
101 - { text: '🔎 PRها', callback_data: `prs:${repoId}` }
102 - ],
99 + [{ text: '🌿 Branches', callback_data: `branches:${repoId}` }],
100 [
101 { text: '🐛 Issues', callback_data: `issues:${repoId}` },
102 { text: '🏷 Releases', callback_data: `releases:${repoId}` }
@@ -437,6 +434,8 @@ function resolveReadCallback(data) {
434 if (branches) return { actionId: 'github.branches.list', kind: 'branches', ...branches };
435 const compare = compareRef(value);
436 if (compare) return { actionId: 'github.compare.read', kind: 'compare', ...compare };
437 + const legacyPr = numericSingle(value, 'pr');
438 + if (legacyPr !== null) return { actionId: 'github.pr.advanced.list', kind: 'prs', repoId: legacyPr, page: 1 };
439 const prs = pagedSingle(value, 'prs');
440 if (prs) return { actionId: 'github.pr.advanced.list', kind: 'prs', ...prs };
441 const prdetail = numericPair(value, 'prdetail');
test/github-advanced-plugin.test.js
+12 -2
@@ -40,7 +40,8 @@ function makeMenu() {
40 async getReposListView() { return { text: 'repos', reply_markup: { inline_keyboard: [] } }; },
41 async renderByCallback(data) {
42 if (String(data).startsWith('repo:')) {
43 - return { text: 'repo', reply_markup: { inline_keyboard: [[{ text: 'back', callback_data: 'menu:repos' }]] } };
43 + const repoId = String(data).split(':')[1];
44 + return { text: 'repo', reply_markup: { inline_keyboard: [[{ text: 'PRها', callback_data: `pr:${repoId}` }], [{ text: 'back', callback_data: 'menu:repos' }]] } };
45 }
46 return { text: `legacy:${data}`, reply_markup: { inline_keyboard: [] } };
47 }
@@ -88,7 +89,8 @@ test('repository and workflow views expose Advanced READ navigation', async () =
89 const plugin = createGitHubPlugin({ github, menu: makeMenu() });
90 const repoView = await plugin.resolveCallback('repo:123').execute();
91 const repoCallbacks = callbacks(repoView);
91 - for (const expected of ['runs:123', 'branches:123', 'prs:123', 'issues:123', 'releases:123']) assert.ok(repoCallbacks.includes(expected), expected);
92 + for (const expected of ['runs:123', 'branches:123', 'pr:123', 'issues:123', 'releases:123']) assert.ok(repoCallbacks.includes(expected), expected);
93 + assert.ok(!repoCallbacks.includes('prs:123'), 'repository view must not expose a duplicate advanced PR entry');
94
95 const runView = await plugin.resolveCallback('run:123:77').execute();
96 assert.ok(callbacks(runView).includes('artifacts:123:77'));
@@ -100,6 +102,14 @@ test('repository and workflow views expose Advanced READ navigation', async () =
102 assert.ok(callbacks(jobView).includes('joblog:123:88'));
103 });
104
105 +test('legacy repository PR button resolves to the actionable advanced PR report', async () => {
106 + const plugin = createGitHubPlugin({ github: makeGitHub(), menu: makeMenu() });
107 + const route = plugin.resolveCallback('pr:123');
108 + assert.equal(route?.actionId, 'github.pr.advanced.list');
109 + const view = await route.execute();
110 + assert.ok(callbacks(view).includes('prdetail:123:19'), 'repository PR button must drill into PR detail');
111 +});
112 +
113 test('failed job log is escaped and bounded-tail state is visible', async () => {
114 const plugin = createGitHubPlugin({ github: makeGitHub(), menu: makeMenu() });
115 const view = await plugin.resolveCallback('joblog:123:88').execute();
test/github-plugin.test.js
+5 -1
@@ -35,6 +35,10 @@ function makeGitHub() {
35 calls.push(`repo:${repoId}`);
36 return { id: String(repoId), name: 'demo', fullName: 'davood/demo' };
37 },
38 + async listPullRequests(repoId) {
39 + calls.push(`pr:${repoId}`);
40 + return [{ number: 19, title: 'Feature', author: 'dev', state: 'open', merged: false }];
41 + },
42 async listWorkflowRuns(repoId) {
43 calls.push(`runs:${repoId}`);
44 return [{
@@ -131,7 +135,7 @@ test('GitHub plugin maps read callback families to declared actions without eage
135 ['files:123', 'github.files.list'],
136 ['tree:123:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'github.tree.read'],
137 ['blob:123:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', 'github.blob.read'],
134 - ['pr:123', 'github.pr.list'],
138 + ['pr:123', 'github.pr.advanced.list'],
139 ['commits:123', 'github.commits.list'],
140 ['status:123', 'github.status.read'],
141 ['runs:123', 'github.workflow.runs.list'],