Skip to content

Commit 049ac2d

Browse files
author
Joshua Chittick
committed
fix: keep channel/github fields visible in Lark cards
Replace unsupported input components with select actions for Channel and GitHub settings so fields render reliably in current Lark clients.
1 parent 65e3c62 commit 049ac2d

File tree

1 file changed

+117
-33
lines changed

1 file changed

+117
-33
lines changed

packages/ims/lark/settings.ts

Lines changed: 117 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,36 @@ export function buildLarkSettingsDetailCard(params: {
325325
text: { tag: "plain_text", content: item },
326326
value: item,
327327
}));
328+
const workingDirectoryOptions = Array.from(new Set([
329+
cwd === "(not set)" ? "" : cwd,
330+
"/root/ode-new",
331+
"/root",
332+
"/",
333+
])).map((item) => ({
334+
text: { tag: "plain_text", content: item || "(empty)" },
335+
value: item,
336+
}));
337+
const baseBranchOptions = Array.from(new Set([
338+
baseBranch,
339+
"main",
340+
"master",
341+
"develop",
342+
"dev",
343+
])).map((item) => ({
344+
text: { tag: "plain_text", content: item || "main" },
345+
value: item || "main",
346+
}));
347+
const channelSystemMessageOptions = [
348+
{ text: "(empty)", value: "" },
349+
{ text: "concise", value: "Please keep responses concise and actionable." },
350+
{ text: "detailed", value: "Please provide detailed reasoning and include implementation notes." },
351+
{ text: "current", value: systemMessage === "(none)" ? "" : systemMessage },
352+
]
353+
.filter((item, idx, all) => all.findIndex((x) => x.value === item.value) === idx)
354+
.map((item) => ({
355+
text: { tag: "plain_text", content: item.text },
356+
value: item.value,
357+
}));
328358
const settingsBaseValue = {
329359
action: "set_channel_settings",
330360
channelId,
@@ -402,30 +432,54 @@ export function buildLarkSettingsDetailCard(params: {
402432
content: `Working directory\nCurrent: \`${cwd}\``,
403433
},
404434
{
405-
tag: "input",
406-
name: "workingDirectory",
407-
placeholder: { tag: "plain_text", content: "Enter working directory" },
408-
value: cwd === "(not set)" ? "" : cwd,
435+
tag: "action",
436+
actions: [
437+
{
438+
tag: "select_static",
439+
placeholder: { tag: "plain_text", content: "Select working directory" },
440+
options: workingDirectoryOptions,
441+
value: {
442+
...settingsBaseValue,
443+
field: "workingDirectory",
444+
},
445+
},
446+
],
409447
},
410448
{
411449
tag: "markdown",
412450
content: `Base branch\nCurrent: \`${baseBranch}\``,
413451
},
414452
{
415-
tag: "input",
416-
name: "baseBranch",
417-
placeholder: { tag: "plain_text", content: "Enter base branch" },
418-
value: baseBranch,
453+
tag: "action",
454+
actions: [
455+
{
456+
tag: "select_static",
457+
placeholder: { tag: "plain_text", content: "Select base branch" },
458+
options: baseBranchOptions,
459+
value: {
460+
...settingsBaseValue,
461+
field: "baseBranch",
462+
},
463+
},
464+
],
419465
},
420466
{
421467
tag: "markdown",
422468
content: `System message\nCurrent: ${systemMessage}`,
423469
},
424470
{
425-
tag: "input",
426-
name: "channelSystemMessage",
427-
placeholder: { tag: "plain_text", content: "Enter channel system message" },
428-
value: systemMessage === "(none)" ? "" : systemMessage,
471+
tag: "action",
472+
actions: [
473+
{
474+
tag: "select_static",
475+
placeholder: { tag: "plain_text", content: "Select system message" },
476+
options: channelSystemMessageOptions,
477+
value: {
478+
...settingsBaseValue,
479+
field: "channelSystemMessage",
480+
},
481+
},
482+
],
429483
},
430484
{
431485
tag: "action",
@@ -486,42 +540,72 @@ export function buildLarkSettingsDetailCard(params: {
486540
: []),
487541
{
488542
tag: "markdown",
489-
content: [
490-
`- User: \`${userId}\``,
491-
`- Token: \`${maskedToken(github?.token)}\``,
492-
`- Git name: \`${github?.gitName || "(not set)"}\``,
493-
`- Git email: \`${github?.gitEmail || "(not set)"}\``,
494-
].join("\n"),
543+
content: "GitHub",
495544
},
496545
{
497546
tag: "markdown",
498-
content: "GitHub token",
547+
content: `Token\nCurrent: \`${maskedToken(github?.token)}\``,
499548
},
500549
{
501-
tag: "input",
502-
name: "githubToken",
503-
placeholder: { tag: "plain_text", content: "Enter GitHub token" },
504-
value: githubToken,
550+
tag: "action",
551+
actions: [
552+
{
553+
tag: "select_static",
554+
placeholder: { tag: "plain_text", content: "Token action" },
555+
options: [
556+
{ text: { tag: "plain_text", content: "Keep current" }, value: githubToken },
557+
{ text: { tag: "plain_text", content: "Clear token" }, value: "" },
558+
],
559+
value: {
560+
...githubBaseValue,
561+
field: "githubToken",
562+
},
563+
},
564+
],
505565
},
506566
{
507567
tag: "markdown",
508-
content: "Git name",
568+
content: `Git name\nCurrent: \`${github?.gitName || "(not set)"}\``,
509569
},
510570
{
511-
tag: "input",
512-
name: "githubName",
513-
placeholder: { tag: "plain_text", content: "Enter git name" },
514-
value: githubName,
571+
tag: "action",
572+
actions: [
573+
{
574+
tag: "select_static",
575+
placeholder: { tag: "plain_text", content: "Select git name" },
576+
options: [
577+
{ text: { tag: "plain_text", content: githubName || "(not set)" }, value: githubName },
578+
{ text: { tag: "plain_text", content: "LIU9293" }, value: "LIU9293" },
579+
{ text: { tag: "plain_text", content: "(empty)" }, value: "" },
580+
],
581+
value: {
582+
...githubBaseValue,
583+
field: "githubName",
584+
},
585+
},
586+
],
515587
},
516588
{
517589
tag: "markdown",
518-
content: "Git email",
590+
content: `Git email\nCurrent: \`${github?.gitEmail || "(not set)"}\``,
519591
},
520592
{
521-
tag: "input",
522-
name: "githubEmail",
523-
placeholder: { tag: "plain_text", content: "Enter git email" },
524-
value: githubEmail,
593+
tag: "action",
594+
actions: [
595+
{
596+
tag: "select_static",
597+
placeholder: { tag: "plain_text", content: "Select git email" },
598+
options: [
599+
{ text: { tag: "plain_text", content: githubEmail || "(not set)" }, value: githubEmail },
600+
{ text: { tag: "plain_text", content: "mylock.kai@gmail.com" }, value: "mylock.kai@gmail.com" },
601+
{ text: { tag: "plain_text", content: "(empty)" }, value: "" },
602+
],
603+
value: {
604+
...githubBaseValue,
605+
field: "githubEmail",
606+
},
607+
},
608+
],
525609
},
526610
{
527611
tag: "action",

0 commit comments

Comments
 (0)