feat: add Electron Mini Chat windows (#1161)
Add dedicated Electron Mini Chat windows for focused chat sessions without the full desktop shell. Mini Chat can open existing sessions or draft sessions, supports pinning above other windows, transfers sessions or drafts back to the main window, and deduplicates existing-session windows. Expose Mini Chat entry points from the main header, session sidebar, command palette, and `mod+alt+n`. Add a dedicated Vite entry and React runtime so the compact surface can stay isolated from full-app chrome while still sharing chat, sync, theme, locale, model, agent, and worktree behavior. Keep Mini Chat behavior scoped to the compact surface: - limit assistant/user message actions to the appropriate Mini Chat set - hide workspace changed-files UI in Mini Chat - keep draft worktree selection and streaming directory state in sync - mark sessions viewed while they are open in Mini Chat - support Mini Chat-specific keyboard shortcuts for input focus, model selection, thinking variant cycling, favorite model cycling, and opening new Mini Chat drafts Harden Electron integration by gating Mini Chat controls on desktop IPC availability, restricting pin/unpin IPC to Mini Chat windows, and only closing Mini Chat after the main window handoff succeeds.
This commit is contained in:
committed by
GitHub
parent
8410c41b01
commit
e1ff21bc0a
@@ -213,6 +213,18 @@ async function materializeSessionFromServer(
|
||||
// Used to determine if user is currently viewing the session when a notification arrives.
|
||||
let _activeDirectory = ""
|
||||
let _activeSession = ""
|
||||
const externallyViewedSessions = new Map<string, number>()
|
||||
const EXTERNAL_VIEW_TTL_MS = 15_000
|
||||
|
||||
const viewedSessionKey = (directory: string, sessionId: string) => `${directory}\n${sessionId}`
|
||||
|
||||
function pruneExternallyViewedSessions(now = Date.now()) {
|
||||
for (const [key, expiresAt] of externallyViewedSessions.entries()) {
|
||||
if (expiresAt <= now) {
|
||||
externallyViewedSessions.delete(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
const pendingQuestionToastIds = new Set<string>()
|
||||
const pendingPermissionToastIds = new Set<string>()
|
||||
|
||||
@@ -239,10 +251,21 @@ export function setActiveSession(directory: string, sessionId: string) {
|
||||
_activeSession = sessionId
|
||||
}
|
||||
|
||||
export function setExternallyViewedSession(directory: string, sessionId: string, viewed: boolean) {
|
||||
if (!directory || !sessionId) return
|
||||
const key = viewedSessionKey(directory, sessionId)
|
||||
if (!viewed) {
|
||||
externallyViewedSessions.delete(key)
|
||||
return
|
||||
}
|
||||
externallyViewedSessions.set(key, Date.now() + EXTERNAL_VIEW_TTL_MS)
|
||||
}
|
||||
|
||||
function isViewedInCurrentSession(directory: string, sessionId?: string): boolean {
|
||||
if (!_activeDirectory || !_activeSession || !sessionId) return false
|
||||
if (directory !== _activeDirectory) return false
|
||||
return sessionId === _activeSession
|
||||
if (!sessionId) return false
|
||||
if (_activeDirectory && _activeSession && directory === _activeDirectory && sessionId === _activeSession) return true
|
||||
pruneExternallyViewedSessions()
|
||||
return externallyViewedSessions.has(viewedSessionKey(directory, sessionId))
|
||||
}
|
||||
|
||||
function isRecentBoot() {
|
||||
|
||||
Reference in New Issue
Block a user