fix(projects): Drawer resettet App-Focus nicht mehr (leere Projekte-Ursache) + Zurueck-Button
Kernbug: ProjectsBrowser.load() pushte bei JEDEM Drawer-Oeffnen status.active
in den App-Focus. Im Multi-Threading hat das Brain keinen globalen
active_project-State mehr → status.active ist null → Focus wurde auf Hauptchat
zurueckgesetzt. Folge: nach jedem Drawer-Oeffnen landeten alle Nachrichten im
Hauptchat, Projekte blieben leer.
- ProjectsBrowser: neues Prop currentFocusId (App-Focus = Source-of-Truth).
load() uebernimmt nur noch die Projektliste, kein onActiveChanged(status.active)
mehr. Highlight (✓ FOCUS) folgt currentFocusId.
- ChatScreen: currentFocusId={focusedProjectId} durchgereicht.
- ChatScreen: direkter „← Hauptchat"-Button im Focus-Header (nur im Projekt
sichtbar) — ein Tap statt Drawer→Hauptchat.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,12 @@ interface Props {
|
||||
/** Wird gerufen wenn Stefan ein anderes Projekt fokussiert (App-lokale
|
||||
* UI-Entscheidung, wechselt den Chat-Focus). */
|
||||
onActiveChanged?: (project: Project | null) => void;
|
||||
/** Der aktuell in der App fokussierte Kontext (App-lokale Source-of-Truth).
|
||||
* Leer = Hauptchat. Steuert das ✓-FOCUS-Highlight. WICHTIG: der Drawer darf
|
||||
* den Focus NICHT aus dem Brain-Status ableiten — im Multi-Threading gibt es
|
||||
* kein globales active_project mehr (status.active ist null), das wuerde den
|
||||
* Focus bei jedem Drawer-Oeffnen auf Hauptchat zuruecksetzen. */
|
||||
currentFocusId?: string;
|
||||
/** Queue-Status pro Kontext (key "__main__" = Hauptchat, sonst project_id).
|
||||
* Wenn geliefert: Status-Dot pro Zeile gerendert. */
|
||||
queueStatus?: Record<string, { busy: boolean; queue_size: number }>;
|
||||
@@ -51,7 +57,7 @@ function _fmtRel(unixSec: number): string {
|
||||
return new Date(unixSec * 1000).toLocaleDateString('de-DE');
|
||||
}
|
||||
|
||||
export const ProjectsBrowser: React.FC<Props> = ({ visible = true, onClose, onActiveChanged, queueStatus }) => {
|
||||
export const ProjectsBrowser: React.FC<Props> = ({ visible = true, onClose, onActiveChanged, currentFocusId, queueStatus }) => {
|
||||
const _statusDot = (pid: string) => {
|
||||
const s = queueStatus?.[pid];
|
||||
if (!s) return { color: '#555570', label: '' };
|
||||
@@ -80,9 +86,11 @@ export const ProjectsBrowser: React.FC<Props> = ({ visible = true, onClose, onAc
|
||||
setLoading(true); setErr(null);
|
||||
brainApi.getProjectStatus()
|
||||
.then(status => {
|
||||
// NUR die Projektliste + Queue uebernehmen. NICHT status.active in den
|
||||
// App-Focus pushen — im Multi-Threading ist das Brain-active_project
|
||||
// bedeutungslos (null), das wuerde den Focus bei jedem Drawer-Oeffnen
|
||||
// auf Hauptchat zuruecksetzen und alle Nachrichten dort landen lassen.
|
||||
setProjects(status.projects || []);
|
||||
setActiveId(status.active_id || '');
|
||||
onActiveChangedRef.current?.(status.active);
|
||||
})
|
||||
.catch(e => setErr(String(e?.message || e)))
|
||||
.finally(() => setLoading(false));
|
||||
@@ -90,6 +98,10 @@ export const ProjectsBrowser: React.FC<Props> = ({ visible = true, onClose, onAc
|
||||
|
||||
useEffect(() => { if (visible) load(); }, [visible, load]);
|
||||
|
||||
// Highlight („✓ FOCUS") folgt dem App-Focus (Source-of-Truth), nicht dem
|
||||
// Brain. switchTo setzt activeId zusaetzlich sofort fuer Instant-Feedback.
|
||||
useEffect(() => { setActiveId(currentFocusId || ''); }, [currentFocusId]);
|
||||
|
||||
// Reload bei RVS-Reconnect — sonst zeigt die Liste den Fast-Fail ewig
|
||||
useEffect(() => {
|
||||
if (!visible) return;
|
||||
|
||||
Reference in New Issue
Block a user