Skip to content

Commit 375c146

Browse files
authored
Merge pull request #71 from odefun/feat/optional-github-token-1770588
Make GitHub token optional in Slack modal
2 parents 4d1654c + c87260c commit 375c146

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ode",
3-
"version": "0.0.43",
3+
"version": "0.0.44",
44
"description": "Ode - OpenCode chat controller for Slack",
55
"module": "packages/core/index.ts",
66
"type": "module",

packages/config/local/ode.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ export function getChannelDetails(channelId: string): ChannelDetail | null {
441441
}
442442

443443
export type GitHubInfo = {
444-
token: string;
444+
token?: string;
445445
gitName?: string;
446446
gitEmail?: string;
447447
};
@@ -454,11 +454,15 @@ export type UserGeneralSettings = {
454454
export function getGitHubInfoForUser(userId: string): GitHubInfo | null {
455455
const info = loadOdeConfig().githubInfos?.[userId];
456456
if (!info) return null;
457-
const token = info.token?.trim();
458-
if (!token) return null;
459-
const gitName = info.gitName?.trim() || undefined;
460-
const gitEmail = info.gitEmail?.trim() || undefined;
461-
return { token, gitName, gitEmail };
457+
const token = info.token?.trim() || "";
458+
const gitName = info.gitName?.trim() || "";
459+
const gitEmail = info.gitEmail?.trim() || "";
460+
if (!token && !gitName && !gitEmail) return null;
461+
return {
462+
token: token || undefined,
463+
gitName: gitName || undefined,
464+
gitEmail: gitEmail || undefined,
465+
};
462466
}
463467

464468
export function getUserGeneralSettings(): UserGeneralSettings {
@@ -487,14 +491,16 @@ export function setUserGeneralSettings(settings: UserGeneralSettings): void {
487491
export function setGitHubInfoForUser(userId: string, info: GitHubInfo): void {
488492
const config = loadOdeConfig();
489493
const githubInfos = { ...(config.githubInfos ?? {}) };
490-
const token = info.token.trim();
491-
if (token.length === 0) {
494+
const token = info.token?.trim() || "";
495+
const gitName = info.gitName?.trim() || "";
496+
const gitEmail = info.gitEmail?.trim() || "";
497+
if (!token && !gitName && !gitEmail) {
492498
delete githubInfos[userId];
493499
} else {
494500
githubInfos[userId] = {
495501
token,
496-
gitName: info.gitName?.trim() || "",
497-
gitEmail: info.gitEmail?.trim() || "",
502+
gitName,
503+
gitEmail,
498504
};
499505
}
500506
saveOdeConfig({ ...config, githubInfos });

packages/ims/slack/commands.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ function buildGitHubTokenModal(params: {
257257
}) {
258258
const { channelId, hasToken, token, gitName, gitEmail } = params;
259259
const statusText = hasToken
260-
? "A GitHub token is already set for your account. Submit a new value to update it."
261-
: "Set a GitHub token to enable GitHub CLI actions and git identity.";
260+
? "A GitHub token is already set for your account. Update it if needed; git name/email are used for commits."
261+
: "GitHub token is optional and only needed for GitHub CLI actions. Git name/email are used for commits.";
262262

263263
return {
264264
type: "modal" as const,
@@ -276,6 +276,7 @@ function buildGitHubTokenModal(params: {
276276
type: "input" as const,
277277
block_id: GITHUB_TOKEN_BLOCK,
278278
label: { type: "plain_text" as const, text: "GitHub Token" },
279+
optional: true,
279280
element: {
280281
type: "plain_text_input" as const,
281282
action_id: GITHUB_TOKEN_ACTION,
@@ -638,16 +639,6 @@ export function setupInteractiveHandlers(): void {
638639
const gitName = values?.[GITHUB_NAME_BLOCK]?.[GITHUB_NAME_ACTION]?.value || "";
639640
const gitEmail = values?.[GITHUB_EMAIL_BLOCK]?.[GITHUB_EMAIL_ACTION]?.value || "";
640641
const trimmed = token.trim();
641-
const errors: Record<string, string> = {};
642-
643-
if (!trimmed) {
644-
errors[GITHUB_TOKEN_BLOCK] = "Enter a GitHub token.";
645-
}
646-
647-
if (Object.keys(errors).length > 0) {
648-
await ack({ response_action: "errors", errors });
649-
return;
650-
}
651642

652643
await ack();
653644

0 commit comments

Comments
 (0)