Commit 5873182
feat: add conversation database (#1045)
* feat(convDatabase): add sqlalchemy and alembic
* feat(convDatabase): implement a first version of the conversation database
* chore: ignore claude code settings
* refactor(convDatabase): optimize subsequent save query
* feat(convDatabase): add settings and private mode
* refactor(convDatabase): manage database singleton inside wx app singleton
* refactor(convDatabase): optimize database manager code
* fix(convDatabase): code review comment
* fix(convDatabase): use correct method name
* fix(convDatabase): disable btn when no conversation history is selected
* fix(build_exe): add missing package for sqlalchemy and alembic
* feat: move alembic version in resource dir to simplify fhrozen version
* fix(frozenAPP): move alembic dir in resource
* style: fix docstring
* fix: address review findings across database, GUI, and test layers
- gitignore: remove personal .claude/settings.local.json entry (advise
contributors to add it to their global gitignore instead)
- models: use timezone-aware datetime.now(timezone.utc) for all
created_at/updated_at column defaults and onupdate callables
- models: add ondelete="SET NULL" to conversation_system_prompt_id FK
to avoid constraint violations during cascaded deletes
- conversation_model: add SystemMessage.__eq__ that compares only role
and content (mirrors __hash__), fixing lookup in OrderedSet when db_id
differs
- manager: add ConversationDatabase.from_engine() factory classmethod
for test-friendly initialisation without running Alembic migrations
- main_app: fix docstring typo ("started the background" →
"started in the background"); wrap init_conversation_db in try/except;
capitalise log messages in close_conversation_db
- main_frame: guard on_close against empty tabs_panels / invalid index
before calling current_tab
- conversation_tab: remove stale _conv_db class-level cache; always
return wx.GetApp().conv_db directly; add DRAFT_SAVE_DELAY_MS
constant; extract _pop_draft_if_present helper; fix set_private to
only clear db_conv_id on successful delete; make _build_draft_block
accept optional prompt_text/attachments args; pass pre-fetched values
from _save_draft_to_db to avoid double-read
- conversation_history_dialog: replace hardcoded limit=200 with
PAGE_SIZE=100 constant; add offset/reset pagination with Load More
button; add count_label showing "Showing N of M"; fix
_on_item_deselected to use wx.CallAfter(_update_buttons_state)
- preferences_dialog: disable auto_save_draft when auto_save_to_db is
unchecked; add on_auto_save_to_db_changed EVT_CHECKBOX handler
- pyproject.toml: sort alembic and sqlalchemy into correct alphabetical
position in dependencies
- tests/conftest: use ConversationDatabase.from_engine() instead of
__new__ + manual attribute injection
- tests/test_manager: fix flaky test_list_ordered_by_updated with
deterministic updated_at values via direct DB update
- tests/test_models: add db_session.rollback() after every
pytest.raises(IntegrityError) block
- tests/test_roundtrip: verify restored attachment content matches
original in test_attachment_dedup_roundtrip
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(database): add cleanup_orphan_attachments to reclaim orphaned blobs
DBAttachment uses content-hash deduplication and has no cascade delete
from DBMessageAttachment, so blob rows can accumulate as orphans when
conversations or draft blocks are deleted.
Add ConversationDatabase.cleanup_orphan_attachments() that identifies
unreferenced rows via a LEFT JOIN on DBMessageAttachment and removes them
in a single transaction. Wire it to:
- __init__ (once at startup, to sweep orphans from previous sessions)
- delete_conversation (after each cascade delete commits)
Add TestCleanupOrphanAttachments covering: no-orphan path, full cleanup
after a conversation delete, and shared-attachment survival when only one
of two referencing conversations is removed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(conversation): reduce setup duplication across database and conversation tests
- Add db_message_block fixture to database conftest; drop redundant
created_at/updated_at kwargs from all DBConversation/DBMessageBlock
constructions in test_models.py
- Replace _make_block, _make_message_and_attachment, _make_message class
helpers with the shared db_message_block fixture
- Lift local imports and add _count_attachments helper in test_manager.py
- Add tests/conversation/conftest.py with shared bskc_path and
storage_path fixtures; remove duplicate definitions from 3 test classes
- Replace 6 numbered fixtures with make_user_block/make_system factories
in TestConversationWithMultipleBlocks
- Move import io and from PIL import Image to module level in
test_migration.py
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: save draft prompt after model and account selection
* chore: remove claude file
* fix: flush the draft before closing tab
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 1406463 commit 5873182
File tree
26 files changed
+3596
-115
lines changed- basilisk
- config
- conversation
- database
- gui
- res/alembic
- versions
- tests
- conversation
- database
26 files changed
+3596
-115
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
120 | 134 | | |
121 | 135 | | |
122 | 136 | | |
| |||
131 | 145 | | |
132 | 146 | | |
133 | 147 | | |
| 148 | + | |
134 | 149 | | |
135 | 150 | | |
136 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments