Multi-account GitHub auth + UI polish (model logos, markdown, scroll behavior) (#219)
* feat: display provider logos for favorite/recent models Show provider logo next to model name in favorites and recents Render provider logos in ModelControls, ModelMultiSelect, and ModelSelector lists Maintain zero-logo state for other sections to avoid clutter * feat: render user message as markdown instead of plain text Render agent mentions as markdown links in user text Apply inside list style for chat content to fix list rendering Rely on SimpleMarkdownRenderer for consistent rendering * fix(openchamber): adjust layout and overscroll behavior Enable overscroll-auto on overlay containers for smoother scrolling Move page content to full-width wrapper and preserve section borders Show AboutSettings inside its own bordered block when visible * feat: integrate GitHub auth status store and UI Introduce GitHubAuthStore to track connection status and polling Show GitHub avatar in header when connected Guard issue/pr dialogs behind GitHub auth status and show notices * feat: add GitHub multi-account support Add API and UI flow to activate a GitHub account Show and switch between multiple GitHub accounts in header Persist and normalize accounts list with current selection
This commit is contained in:
committed by
GitHub
parent
1de0ebd4fc
commit
74511abfda
@@ -0,0 +1,62 @@
|
||||
import { create } from 'zustand';
|
||||
import type { GitHubAuthStatus, RuntimeAPIs } from '@/lib/api/types';
|
||||
|
||||
type GitHubAuthStatusWithError = GitHubAuthStatus & { error?: string };
|
||||
|
||||
type GitHubAuthStore = {
|
||||
status: GitHubAuthStatusWithError | null;
|
||||
isLoading: boolean;
|
||||
hasChecked: boolean;
|
||||
setStatus: (status: GitHubAuthStatusWithError | null) => void;
|
||||
refreshStatus: (
|
||||
runtimeGitHub?: RuntimeAPIs['github'],
|
||||
options?: { force?: boolean }
|
||||
) => Promise<GitHubAuthStatusWithError | null>;
|
||||
};
|
||||
|
||||
const fetchStatus = async (
|
||||
runtimeGitHub?: RuntimeAPIs['github']
|
||||
): Promise<GitHubAuthStatusWithError> => {
|
||||
if (runtimeGitHub) {
|
||||
const payload = await runtimeGitHub.authStatus();
|
||||
return payload as GitHubAuthStatus;
|
||||
}
|
||||
|
||||
const response = await fetch('/api/github/auth/status', {
|
||||
method: 'GET',
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
const payload = (await response.json().catch(() => null)) as GitHubAuthStatusWithError | null;
|
||||
if (!response.ok || !payload) {
|
||||
throw new Error(payload?.error || response.statusText || 'Failed to load GitHub status');
|
||||
}
|
||||
return payload;
|
||||
};
|
||||
|
||||
export const useGitHubAuthStore = create<GitHubAuthStore>((set, get) => ({
|
||||
status: null,
|
||||
isLoading: false,
|
||||
hasChecked: false,
|
||||
setStatus: (status) => set({ status, hasChecked: true }),
|
||||
refreshStatus: async (runtimeGitHub, options) => {
|
||||
const { hasChecked, status } = get();
|
||||
if (hasChecked && !options?.force) {
|
||||
return status;
|
||||
}
|
||||
|
||||
set({ isLoading: true });
|
||||
try {
|
||||
const payload = await fetchStatus(runtimeGitHub);
|
||||
set({ status: payload, isLoading: false, hasChecked: true });
|
||||
return payload;
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
set({
|
||||
status: { connected: false, error: message },
|
||||
isLoading: false,
|
||||
hasChecked: true,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
},
|
||||
}));
|
||||
Reference in New Issue
Block a user