mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 02:04:32 +00:00
Fix SessionListDialog behavior and document PersistentStorageDialog bug
- Fix SessionListDialog to not reload when user selects a session after deleting others - Track if dialog closed via selection vs other means - Only call delete callback if not closed via selection - Batch deletions to avoid reload on every delete - Comment out PersistentStorageDialog in both web-ui example and browser extension (TODO: fix) - Add Known Bugs section to both README.md files documenting PersistentStorageDialog issue - Clean up navigation tracking variable names in browser extension
This commit is contained in:
parent
2d68594711
commit
5f04960f6d
5 changed files with 94 additions and 25 deletions
|
|
@ -322,6 +322,10 @@ setAppStorage(storage);
|
|||
|
||||
See [src/index.ts](src/index.ts) for the full public API.
|
||||
|
||||
## Known Bugs
|
||||
|
||||
- **PersistentStorageDialog**: Currently broken and commented out in examples. The dialog for requesting persistent storage does not work correctly and needs to be fixed.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
type AppMessage,
|
||||
AppStorage,
|
||||
ChatPanel,
|
||||
PersistentStorageDialog,
|
||||
// PersistentStorageDialog, // TODO: Fix - currently broken
|
||||
ProviderTransport,
|
||||
ProxyTab,
|
||||
SessionIndexedDBBackend,
|
||||
|
|
@ -192,7 +192,7 @@ const renderApp = () => {
|
|||
await loadSession(sessionId);
|
||||
},
|
||||
(deletedSessionId) => {
|
||||
// If the deleted session is the current one, start a new session
|
||||
// Only reload if the current session was deleted
|
||||
if (deletedSessionId === currentSessionId) {
|
||||
newSession();
|
||||
}
|
||||
|
|
@ -311,10 +311,11 @@ async function initApp() {
|
|||
app,
|
||||
);
|
||||
|
||||
// TODO: Fix PersistentStorageDialog - currently broken
|
||||
// Request persistent storage
|
||||
if (storage.sessions) {
|
||||
await PersistentStorageDialog.request();
|
||||
}
|
||||
// if (storage.sessions) {
|
||||
// await PersistentStorageDialog.request();
|
||||
// }
|
||||
|
||||
// Create ChatPanel
|
||||
chatPanel = new ChatPanel();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ export class SessionListDialog extends DialogBase {
|
|||
|
||||
private onSelectCallback?: (sessionId: string) => void;
|
||||
private onDeleteCallback?: (sessionId: string) => void;
|
||||
private deletedSessions = new Set<string>();
|
||||
private closedViaSelection = false;
|
||||
|
||||
protected modalWidth = "min(600px, 90vw)";
|
||||
protected modalHeight = "min(700px, 90vh)";
|
||||
|
|
@ -57,16 +59,26 @@ export class SessionListDialog extends DialogBase {
|
|||
await storage.sessions.deleteSession(sessionId);
|
||||
await this.loadSessions();
|
||||
|
||||
// Notify callback that session was deleted
|
||||
if (this.onDeleteCallback) {
|
||||
this.onDeleteCallback(sessionId);
|
||||
}
|
||||
// Track deleted session
|
||||
this.deletedSessions.add(sessionId);
|
||||
} catch (err) {
|
||||
console.error("Failed to delete session:", err);
|
||||
}
|
||||
}
|
||||
|
||||
override close() {
|
||||
super.close();
|
||||
|
||||
// Only notify about deleted sessions if dialog wasn't closed via selection
|
||||
if (!this.closedViaSelection && this.onDeleteCallback && this.deletedSessions.size > 0) {
|
||||
for (const sessionId of this.deletedSessions) {
|
||||
this.onDeleteCallback(sessionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private handleSelect(sessionId: string) {
|
||||
this.closedViaSelection = true;
|
||||
if (this.onSelectCallback) {
|
||||
this.onSelectCallback(sessionId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue