feat: add GitHub issue picker and API endpoints
Add GitHubIssuePickerDialog UI for selecting issues Enable new session from GitHub issue from session sidebar Implement GitHub issues/list/get/comments APIs across desktop, web, and VS Code
This commit is contained in:
@@ -29,6 +29,12 @@ import {
|
||||
mergePullRequest,
|
||||
} from './githubPr';
|
||||
|
||||
import {
|
||||
getIssue,
|
||||
listIssueComments,
|
||||
listIssues,
|
||||
} from './githubIssues';
|
||||
|
||||
export interface BridgeRequest {
|
||||
id: string;
|
||||
type: string;
|
||||
@@ -1171,6 +1177,77 @@ export async function handleBridgeMessage(message: BridgeRequest, ctx?: BridgeCo
|
||||
}
|
||||
}
|
||||
|
||||
case 'api:github/issues:list': {
|
||||
const context = ctx?.context;
|
||||
if (!context) return { id, type, success: false, error: 'Missing VS Code context' };
|
||||
const stored = await readGitHubAuth(context);
|
||||
if (!stored?.accessToken) {
|
||||
return { id, type, success: true, data: { connected: false } };
|
||||
}
|
||||
const directory = readStringField(payload, 'directory');
|
||||
if (!directory) {
|
||||
return { id, type, success: false, error: 'directory is required' };
|
||||
}
|
||||
try {
|
||||
const result = await listIssues(stored.accessToken, directory);
|
||||
if (result.connected === false) {
|
||||
await clearGitHubAuth(context);
|
||||
}
|
||||
return { id, type, success: true, data: result };
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
return { id, type, success: false, error: message };
|
||||
}
|
||||
}
|
||||
|
||||
case 'api:github/issues:get': {
|
||||
const context = ctx?.context;
|
||||
if (!context) return { id, type, success: false, error: 'Missing VS Code context' };
|
||||
const stored = await readGitHubAuth(context);
|
||||
if (!stored?.accessToken) {
|
||||
return { id, type, success: true, data: { connected: false } };
|
||||
}
|
||||
const directory = readStringField(payload, 'directory');
|
||||
const number = readNumberField(payload, 'number') ?? 0;
|
||||
if (!directory || !number) {
|
||||
return { id, type, success: false, error: 'directory and number are required' };
|
||||
}
|
||||
try {
|
||||
const result = await getIssue(stored.accessToken, directory, number);
|
||||
if (result.connected === false) {
|
||||
await clearGitHubAuth(context);
|
||||
}
|
||||
return { id, type, success: true, data: result };
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
return { id, type, success: false, error: message };
|
||||
}
|
||||
}
|
||||
|
||||
case 'api:github/issues:comments': {
|
||||
const context = ctx?.context;
|
||||
if (!context) return { id, type, success: false, error: 'Missing VS Code context' };
|
||||
const stored = await readGitHubAuth(context);
|
||||
if (!stored?.accessToken) {
|
||||
return { id, type, success: true, data: { connected: false } };
|
||||
}
|
||||
const directory = readStringField(payload, 'directory');
|
||||
const number = readNumberField(payload, 'number') ?? 0;
|
||||
if (!directory || !number) {
|
||||
return { id, type, success: false, error: 'directory and number are required' };
|
||||
}
|
||||
try {
|
||||
const result = await listIssueComments(stored.accessToken, directory, number);
|
||||
if (result.connected === false) {
|
||||
await clearGitHubAuth(context);
|
||||
}
|
||||
return { id, type, success: true, data: result };
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
return { id, type, success: false, error: message };
|
||||
}
|
||||
}
|
||||
|
||||
case 'api:config/reload': {
|
||||
await ctx?.manager?.restart();
|
||||
return { id, type, success: true, data: { restarted: true } };
|
||||
|
||||
Reference in New Issue
Block a user