Move history to sidebar, simplify task assist, add content deduplication
- VersionHistorySection.vue: new sidebar component — collapsible timestamp list, click any snapshot to see inline diff + Restore/Back; replaces the modal - NoteEditorView: remove History toolbar button + HistoryPanel modal, add VersionHistorySection at bottom of sidebar - TaskEditorView: remove floating overlay assist panel + toggle button; add Writing Assistant section in sidebar matching note editor (scope selector, instruction textarea, generate/proofread/accept/reject); main area now shows streaming preview and DiffView like note editor; add VersionHistorySection - note_versions.py: add content deduplication before time-gap check — identical body + title + tags skips snapshot regardless of interval (git semantics) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,16 +18,24 @@ async def create_version(
|
||||
user_id: int, note_id: int, body: str, title: str, tags: list[str] | None = None
|
||||
) -> NoteVersion | None:
|
||||
async with async_session() as session:
|
||||
# Skip if a recent snapshot already exists within the minimum interval.
|
||||
# Fetch the most recent snapshot once for both checks.
|
||||
recent = await session.execute(
|
||||
select(NoteVersion.created_at)
|
||||
select(NoteVersion)
|
||||
.where(NoteVersion.note_id == note_id, NoteVersion.user_id == user_id)
|
||||
.order_by(NoteVersion.created_at.desc())
|
||||
.limit(1)
|
||||
)
|
||||
last_at = recent.scalar_one_or_none()
|
||||
if last_at is not None:
|
||||
# created_at is stored with timezone; ensure comparison is tz-aware
|
||||
last = recent.scalars().first()
|
||||
if last is not None:
|
||||
# Skip if content is identical — no change, no snapshot (git semantics).
|
||||
if (
|
||||
last.body == body
|
||||
and last.title == title
|
||||
and sorted(last.tags or []) == sorted(tags or [])
|
||||
):
|
||||
return None
|
||||
# Skip if within the minimum interval to prevent rapid-fire autosave snapshots.
|
||||
last_at = last.created_at
|
||||
if last_at.tzinfo is None:
|
||||
last_at = last_at.replace(tzinfo=timezone.utc)
|
||||
age = (datetime.now(timezone.utc) - last_at).total_seconds()
|
||||
|
||||
Reference in New Issue
Block a user