Repository navigation
feat(chat): secret card in the chat when an agent asks for a key - #1712
Conversation
admin 2026-11-24: when a user wants to hand an agent a key, show a secure input
card in the conversation instead of having them paste it. Hub request_secret
(agent-network#3864) puts {node_id,key,label,hint} on the reply's task row as
reply_secret_request; the reply bubble renders it as a card (masked input, eye
toggle, save) in place of the fallback text. Save reads the node secrets for
the revision, puts the value, then sends a normal user message saying the key
was saved (name only) so the agent continues. A later saved message marks the
card saved when the chat is reopened, with no extra request. Errors are plain
language with a next step.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b7bf59d30
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <MessageHoverActions side="reply" styles={styles} onCopy={() => void copyMessage(item.result ?? item.reply ?? '')} onMore={at => openMenuAt(at, { item, text: item.result ?? item.reply ?? '', author: alias })} /> | ||
| ) : null} | ||
| {secretCard ? ( | ||
| <ChatSecretCard cfg={cfg} request={secretCard} alreadySaved={savedSecrets.has(secretCard.key)} onSaved={sendPlainText} /> |
There was a problem hiding this comment.
Match saved confirmations to the individual secret request
If a user saves GITHUB_TOKEN and later asks to replace an expired or revoked token, the earlier confirmation remains in savedSecrets, so the new request immediately renders as saved. ChatSecretCard then hides the input and refuses further saves, preventing the replacement through chat. Because the set includes the entire loaded history without timestamps or request identity, even a confirmation predating this request satisfies it. Associate confirmations with the corresponding request, or at least require a matching confirmation after that request, rather than treating a key as permanently saved.
Useful? React with 👍 / 👎.
| <MessageHoverActions side="reply" styles={styles} onCopy={() => void copyMessage(item.result ?? item.reply ?? '')} onMore={at => openMenuAt(at, { item, text: item.result ?? item.reply ?? '', author: alias })} /> | ||
| ) : null} | ||
| {secretCard ? ( | ||
| <ChatSecretCard cfg={cfg} request={secretCard} alreadySaved={savedSecrets.has(secretCard.key)} onSaved={sendPlainText} /> |
There was a problem hiding this comment.
Exempt the secret input from the message context-menu handler
On desktop with a fine pointer, right-clicking the new secret input cannot open its native editing menu, so users cannot paste a credential through right-click → Paste. The input is now inside the reply's [data-message-key] wrapper, and handleMessageContextMenu in ChatScreen.tsx:1463–1483 intercepts every context-menu event within that wrapper at document capture phase, calls preventDefault() and stopImmediatePropagation(), and opens the message menu instead. Exempt editable input targets from that handler so the secret field retains its normal paste/edit actions.
Useful? React with 👍 / 👎.
…fter it Review on #1712 (通信客户端欧) and #463 (通信Dash欧): the saved check was a key-wide set over the whole history, so an old GITHUB_TOKEN confirmation marked a later re-request (e.g. replacing an expired token) as saved and disabled the input. Now a card is saved only by a 'saved' message the current user sent after that card; others' messages and failed sends don't count. Tests cover the re-request, other sender, other key and pending-echo cases (19/19). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review on #1712 (通信客户端欧): a missing or unparsable card/confirmation time was treated as 'after the card', so an old confirmation could still swallow a new request. Unknown times now never count; a fresh save stays saved through the card's own phase, and local echoes carry a real timestamp. Negative tests for missing/invalid confirmation and card times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…json Fixes the drive-registry.test.ts failure on #1712 (all 4 CI failures shared this single cause): test-chat-secret-card/drive.mjs is a stub-only Playwright drive (web export + Chromium, no Hub/seed env) and now registers as kind "stub" (secs: 20). Diff-Shape: +4/-0
…er & QA fixes (#1719) * chore(release): 0.2.618 chat secret card, desktop warm glow, iOS viewer & QA fixes Ships #1701-#1710, #1712 (chat secret card), #1713 (iOS ImageViewer Fabric stability), #1714 (#5420 Android Fresco EmptyDrawable), #1715 (Settings window warm yellow glow), #1716 (Windows popout ChatToolRail top offset), and #1718 (transparent Windows WinTitleBar + hollow restore glyph). Diff-Shape: +24/-10 * docs(release): clarify 618 validation and secret card availability --------- Co-authored-by: 通信欧 <comm-ou@anet.sh>
admin 需求(2026-11-24):用户在聊天里说「帮我存个 GitHub 密钥」时,不让人把值贴进对话,而是在聊天里弹一张加密输入卡(参考 Grok Bot 截图的 Secrets 卡)。
配套:Hub 侧
request_secret工具 —— sleep2agi/agent-network#3864(把{node_id,key,label,hint}作为reply_secret_request落到回复的任务行,永无值)。这个 PR(App 侧,第 2/3 步)
meta_json.reply_secret_request⇒ 渲染成密钥卡,代替兜底文字(旧 Hub / 读不出 ⇒ 照常显示兜底文字「到设置 → 密钥里添加」)scopedSecrets),成功后以用户身份走正常发送路径发一句「🔑 已在卡片里保存「GitHub 密钥」(GITHUB_TOKEN)…」——只含名字不含值,AI 收到才继续验证
src/chat-secret-request.test.ts15/15;原有secret-request-card6/6、secret-request-wiring8/8、settings-subpages56/56、ui-scale-wiring48/48、wide-layout-wiring37/37tests/test-chat-secret-card23/23:桌面 1440 / 手机 390 × 浅 / 深,卡片出现、兜底文字隐藏、默认隐藏、小眼睛可切换、值不以文本出现;后面有「已保存」⇒ 卡片显示已保存tsc本次改动文件无错误下一步:Dashboard 同款卡片(第 3/3 步);合并发版后真机(两台小米 + Mac)走一遍「说要存密钥 → 弹卡 → 保存 → AI 继续」。
🤖 Generated with Claude Code