Skip to content

Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.

fix(chatbot): clear the missing-key notice once quick access saves a key (#184)

Robert0622911e393c6298
diff --git a/chatbot/src/App.jsx b/chatbot/src/App.jsx
index e04af346..e61278a9 100644
--- a/chatbot/src/App.jsx
+++ b/chatbot/src/App.jsx
@@ -2359,6 +2359,7 @@ export default function App() {
sponsoredModels={chat.sponsoredModels}
onClose={() => setQuickAccessOpen(false)}
onOpenView={(view) => navigate(view)}
+ onCredentialsSaved={chat.refreshUser}
onCompleted={async (nextProjectId) => {
await chat.refresh();
if (nextProjectId) await chat.selectProject(nextProjectId);
diff --git a/chatbot/src/QuickAccessWizard.jsx b/chatbot/src/QuickAccessWizard.jsx
index b662186b..1ad3d378 100644
--- a/chatbot/src/QuickAccessWizard.jsx
+++ b/chatbot/src/QuickAccessWizard.jsx
@@ -771,6 +771,7 @@ export default function QuickAccessWizard({
sponsoredModels = [],
onClose,
onCompleted,
+ onCredentialsSaved,
onOpenView,
}) {
const [step, setStep] = useState(0);
@@ -1200,6 +1201,7 @@ export default function QuickAccessWizard({
setGitToken("");
setCodeBuddyApiKey("");
setCodeBuddyEnvChoice(null);
+ void onCredentialsSaved?.();
window.parent !== window &&
window.parent.postMessage(
{ type: "agentflow-credentials-changed" },
diff --git a/chatbot/src/useChat.js b/chatbot/src/useChat.js
index eeadb60d..2c82c7e0 100644
--- a/chatbot/src/useChat.js
+++ b/chatbot/src/useChat.js
@@ -546,11 +546,10 @@ export function useChat() {
},
[sponsored, sponsoredModels, executorModels],
);
- useEffect(() => {
- if (!ready) return;
- // Credential flags are omitted when false, so drop the old ones before
- // merging; otherwise a cleared key would still look configured.
- const refresh = () =>
+ // Credential flags are omitted when false, so drop the old ones before
+ // merging; otherwise a cleared key would still look configured.
+ const refreshUser = useCallback(
+ () =>
api("/api/users")
.then((rows) => {
setUsers(rows || []);
@@ -569,22 +568,26 @@ export function useChat() {
return hint && fresh?.[`${hint.field}Configured`] ? "" : old;
});
})
- .catch(() => {});
+ .catch(() => {}),
+ [],
+ );
+ useEffect(() => {
+ if (!ready) return;
const onMessage = (e) => {
if (
e.source === window.parent &&
e.origin === location.origin &&
e.data?.type === "agentflow-credentials-changed"
)
- void refresh();
+ void refreshUser();
};
window.addEventListener("message", onMessage);
- if (missingKey) window.addEventListener("focus", refresh);
+ if (missingKey) window.addEventListener("focus", refreshUser);
return () => {
window.removeEventListener("message", onMessage);
- window.removeEventListener("focus", refresh);
+ window.removeEventListener("focus", refreshUser);
};
- }, [ready, missingKey]);
+ }, [ready, missingKey, refreshUser]);
useEffect(() => writeQueues(queues), [queues]);
useEffect(() => {
const s = steeringRef.current;
@@ -1078,6 +1081,7 @@ export function useChat() {
}
return {
user,
+ refreshUser,
users,
issueId: session?.issueId || (!activeId ? draftIssueId : ""),
linkIssue,
diff --git a/chatbot/tests/quick-access-wizard.test.jsx b/chatbot/tests/quick-access-wizard.test.jsx
index a40638db..06bb5bee 100644
--- a/chatbot/tests/quick-access-wizard.test.jsx
+++ b/chatbot/tests/quick-access-wizard.test.jsx
@@ -176,6 +176,7 @@ describe("QuickAccessWizard", () => {
mockState.unconfigured = true;
writeMock.mockClear();
const userAction = userEvent.setup();
+ const credentialsSaved = vi.fn();
render(
<QuickAccessWizard
open
@@ -184,6 +185,7 @@ describe("QuickAccessWizard", () => {
projectId="p1"
onClose={vi.fn()}
onCompleted={vi.fn()}
+ onCredentialsSaved={credentialsSaved}
onOpenView={vi.fn()}
/>,
);
@@ -196,6 +198,7 @@ describe("QuickAccessWizard", () => {
{ codeBuddyApiKey: "cb-key", codeBuddyInternetEnvironment: "" },
"PUT",
);
+ expect(credentialsSaved).toHaveBeenCalledTimes(1);
mockState.unconfigured = false;
});