@@ -4,12 +4,12 @@ import {
44 getChannelModel ,
55 resolveChannelCwd ,
66 getDevServers ,
7- getGitHubTokenForUser ,
7+ getGitHubInfoForUser ,
88 isLocalMode ,
99 setChannelDevServerId ,
1010 setChannelModel ,
1111 setChannelWorkingDirectory ,
12- setGitHubTokenForUser ,
12+ setGitHubInfoForUser ,
1313} from "@ode/config" ;
1414
1515const SETTINGS_LAUNCH_ACTION = "open_settings_modal" ;
@@ -18,6 +18,10 @@ const GITHUB_LAUNCH_ACTION = "open_github_token_modal";
1818const GITHUB_MODAL_ID = "github_token_modal" ;
1919const GITHUB_TOKEN_BLOCK = "github_token" ;
2020const GITHUB_TOKEN_ACTION = "github_token_input" ;
21+ const GITHUB_NAME_BLOCK = "github_name" ;
22+ const GITHUB_NAME_ACTION = "github_name_input" ;
23+ const GITHUB_EMAIL_BLOCK = "github_email" ;
24+ const GITHUB_EMAIL_ACTION = "github_email_input" ;
2125const DEV_SERVER_BLOCK = "dev_server" ;
2226const DEV_SERVER_ACTION = "dev_server_select" ;
2327const MODEL_BLOCK = "model" ;
@@ -110,11 +114,16 @@ function buildSettingsModal(params: {
110114 } ;
111115}
112116
113- function buildGitHubTokenModal ( params : { channelId : string ; hasToken : boolean } ) {
114- const { channelId, hasToken } = params ;
117+ function buildGitHubTokenModal ( params : {
118+ channelId : string ;
119+ hasToken : boolean ;
120+ gitName ?: string ;
121+ gitEmail ?: string ;
122+ } ) {
123+ const { channelId, hasToken, gitName, gitEmail } = params ;
115124 const statusText = hasToken
116125 ? "A GitHub token is already set for your account. Submit a new value to update it."
117- : "Set a GitHub token to enable GitHub CLI actions." ;
126+ : "Set a GitHub token to enable GitHub CLI actions and git identity ." ;
118127
119128 return {
120129 type : "modal" as const ,
@@ -138,6 +147,30 @@ function buildGitHubTokenModal(params: { channelId: string; hasToken: boolean })
138147 placeholder : { type : "plain_text" as const , text : "ghp_..." } ,
139148 } ,
140149 } ,
150+ {
151+ type : "input" as const ,
152+ block_id : GITHUB_NAME_BLOCK ,
153+ optional : true ,
154+ label : { type : "plain_text" as const , text : "Git Name" } ,
155+ element : {
156+ type : "plain_text_input" as const ,
157+ action_id : GITHUB_NAME_ACTION ,
158+ initial_value : gitName ?? "" ,
159+ placeholder : { type : "plain_text" as const , text : "Jane Doe" } ,
160+ } ,
161+ } ,
162+ {
163+ type : "input" as const ,
164+ block_id : GITHUB_EMAIL_BLOCK ,
165+ optional : true ,
166+ label : { type : "plain_text" as const , text : "Git Email" } ,
167+ element : {
168+ type : "plain_text_input" as const ,
169+ action_id : GITHUB_EMAIL_ACTION ,
170+ initial_value : gitEmail ?? "" ,
171+ placeholder : { type : "plain_text" as const , text : "jane@example.com" } ,
172+ } ,
173+ } ,
141174 ] ,
142175 } ;
143176}
@@ -202,14 +235,17 @@ export function setupInteractiveHandlers(): void {
202235 await client . chat . postEphemeral ( {
203236 channel : channelId ,
204237 user : userId ,
205- text : "GitHub token updates are not implemented in cloud mode." ,
238+ text : "GitHub info updates are not implemented in cloud mode." ,
206239 } ) ;
207240 return ;
208241 }
209242
243+ const info = getGitHubInfoForUser ( userId ) ;
210244 const view = buildGitHubTokenModal ( {
211245 channelId,
212- hasToken : Boolean ( getGitHubTokenForUser ( userId ) ) ,
246+ hasToken : Boolean ( info ?. token ) ,
247+ gitName : info ?. gitName ,
248+ gitEmail : info ?. gitEmail ,
213249 } ) ;
214250
215251 await client . views . open ( {
@@ -313,6 +349,8 @@ export function setupInteractiveHandlers(): void {
313349 slackApp . view ( GITHUB_MODAL_ID , async ( { ack, view, body, client } ) => {
314350 const values = view . state . values ;
315351 const token = values ?. [ GITHUB_TOKEN_BLOCK ] ?. [ GITHUB_TOKEN_ACTION ] ?. value || "" ;
352+ const gitName = values ?. [ GITHUB_NAME_BLOCK ] ?. [ GITHUB_NAME_ACTION ] ?. value || "" ;
353+ const gitEmail = values ?. [ GITHUB_EMAIL_BLOCK ] ?. [ GITHUB_EMAIL_ACTION ] ?. value || "" ;
316354 const trimmed = token . trim ( ) ;
317355 const errors : Record < string , string > = { } ;
318356
@@ -333,20 +371,24 @@ export function setupInteractiveHandlers(): void {
333371 if ( ! userId || ! channelId ) return ;
334372
335373 try {
336- setGitHubTokenForUser ( userId , trimmed ) ;
374+ setGitHubInfoForUser ( userId , {
375+ token : trimmed ,
376+ gitName,
377+ gitEmail,
378+ } ) ;
337379 } catch ( err ) {
338380 await client . chat . postEphemeral ( {
339381 channel : channelId ,
340382 user : userId ,
341- text : `Failed to save GitHub token : ${ err instanceof Error ? err . message : String ( err ) } ` ,
383+ text : `Failed to save GitHub info : ${ err instanceof Error ? err . message : String ( err ) } ` ,
342384 } ) ;
343385 return ;
344386 }
345387
346388 await client . chat . postEphemeral ( {
347389 channel : channelId ,
348390 user : userId ,
349- text : "GitHub token updated." ,
391+ text : "GitHub info updated." ,
350392 } ) ;
351393 } ) ;
352394
0 commit comments