Personal Telegram developer console for GitHub

fix: harden multi-file picker repository binding

davoodmehraban89 committed Oct 7, 2026 at 01:29 UTC c1337732c064309c38a966fb9d2acfe9a1b06f4c
1 file changed +3 -1
src/plugins/github/workspace.js
+3 -1
@@ -217,7 +217,9 @@ export function createWorkspaceController({ github, workspaces, editorUrl = DEFA
217
218 const pickWorkspaceFile = async (workspaceId, repoId, ownerId) => {
219 const workspace = await requireWorkspace(workspaceId, ownerId);
220 - const items = (await github.listFiles(repoId, '')).filter(item => item.type === 'file' && !(workspace.files || []).some(file => file.path === item.path)).slice(0, 20);
220 + if (Number(workspace.repoId) !== Number(repoId)) throw new Error('Workspace repository mismatch');
221 + const existingPaths = new Set((Array.isArray(workspace.files) && workspace.files.length ? workspace.files : [{ path: workspace.path }]).map(file => file.path));
222 + const items = (await github.listFiles(repoId, '')).filter(item => item.type === 'file' && !existingPaths.has(item.path)).slice(0, 20);
223 const refs = await workspaces.createNavigationRefs({ ownerId, refs: items.map(item => ({ repoId, workspaceId, path:item.path, type:'workspace-add', sha:item.sha })) });
224 return { text:`➕ <b>افزودن فایل به Change Set</b>\n${items.length ? 'یک فایل را انتخاب کنید.' : 'فایل قابل افزودن دیگری در این نما نیست.'}`, reply_markup:{inline_keyboard:items.map((item,i)=>[{text:`📄 ${short(item.path,42)}`,callback_data:`wadd:${refs[i].refId}`}]).concat([[{text:'↩️ Workspace',callback_data:`ws:${workspaceId}`} ]])} };
225 };