chore(cleanup): add journal AI shortcut and align posts tmp_sort

This commit is contained in:
Scott Idem
2026-06-02 14:43:16 -04:00
parent 84a9d0fffc
commit 1de87b6c5f
6 changed files with 64 additions and 32 deletions

View File

@@ -70,7 +70,7 @@ Documented in `GUIDE__SvelteKit2_Svelte5_DexieJS.md` (IDB Sort section).
- [ ] `ae_events__event_session` — roll out when sort behavior is reviewed
- [ ] `ae_events__event_presenter` — roll out when sort behavior is reviewed
- [ ] `ae_events__event_location` — roll out when sort behavior is reviewed
- [ ] `ae_posts__post` + `ae_posts__post_comment`note: currently use 3-char padding; align to 8
- [x] `ae_posts__post` + `ae_posts__post_comment`migrated to `build_tmp_sort` with 8-char padding; BB comment list consumer updated for ASC tmp_sort ordering. (2026-06-02)
- [ ] `ae_core__person` + `ae_core__account` — roll out when sort behavior is reviewed
### [Stores] IDB Content Version System
@@ -85,9 +85,7 @@ Documented in `GUIDE__SvelteKit2_Svelte5_DexieJS.md` (IDB Sort section).
### [Journals] Journal Entry Config follow-ups
- [ ] **[Journals] Entry passcode secondary auth** — implement `passcode_hash` comparison.
- [ ] **[Journals] Summary AI shortcut** — add button to modal.
Note: AI tools are already available in entry edit view (`AE_Comp_Journal_Entry_AiTools`),
but no dedicated shortcut button exists yet inside `ae_comp__modal_journal_entry_config.svelte`.
- [x] **[Journals] Summary AI shortcut** — added Quick Actions button in entry config modal and wired it to close modal + scroll to AI tools panel in entry edit view. (2026-06-02)
### [Cleanup] Migrate remaining `lucide-svelte` imports to `@lucide/svelte`
- [x] **[Cleanup] Migrate remaining `lucide-svelte` imports to `@lucide/svelte`**

View File

@@ -1,5 +1,6 @@
import type { key_val } from '$lib/stores/ae_stores';
import { api } from '$lib/api/api';
import { build_tmp_sort } from '$lib/ae_core/core__idb_sort';
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
import { db_posts } from '$lib/ae_posts/db_posts';
@@ -570,15 +571,16 @@ export async function process_ae_obj__post_props({
if (!obj.account_id_random) obj.account_id_random = account_id;
}
obj.name = obj.title;
const sort_val = (obj.sort ?? 0).toString().padStart(3, '0');
const updated =
obj.updated_on ?? obj.created_on ?? new Date(0).toISOString();
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
sort_val
}_${updated}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
sort_val
}_${obj.updated_on ?? ''}_${obj.created_on ?? ''}`;
const { tmp_sort_1, tmp_sort_2 } = build_tmp_sort({
prefix: [obj.group ?? ''],
priority: obj.priority,
sort: obj.sort,
fields_1: [obj.updated_on ?? obj.created_on ?? ''],
fields_2: [obj.updated_on ?? '', obj.created_on ?? ''],
pad_width: 8
});
obj.tmp_sort_1 = tmp_sort_1;
obj.tmp_sort_2 = tmp_sort_2;
return obj;
}

View File

@@ -1,5 +1,6 @@
import type { key_val } from '$lib/stores/ae_stores';
import { api } from '$lib/api/api';
import { build_tmp_sort } from '$lib/ae_core/core__idb_sort';
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
import { db_posts } from '$lib/ae_posts/db_posts';
@@ -383,15 +384,16 @@ export async function process_ae_obj__post_comment_props({
obj_type: 'post_comment',
log_lvl,
specific_processor: (obj) => {
const sort_val = (obj.sort ?? 0).toString().padStart(3, '0');
const updated =
obj.updated_on ?? obj.created_on ?? new Date(0).toISOString();
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
sort_val
}_${updated}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
sort_val
}_${obj.updated_on ?? ''}_${obj.created_on ?? ''}`;
const { tmp_sort_1, tmp_sort_2 } = build_tmp_sort({
prefix: [obj.group ?? ''],
priority: obj.priority,
sort: obj.sort,
fields_1: [obj.updated_on ?? obj.created_on ?? ''],
fields_2: [obj.updated_on ?? '', obj.created_on ?? ''],
pad_width: 8
});
obj.tmp_sort_1 = tmp_sort_1;
obj.tmp_sort_2 = tmp_sort_2;
return obj;
}

View File

@@ -73,14 +73,14 @@ let lq__post_comment_obj_li = $derived.by(() => {
return liveQuery(async () => {
if (!post_id) return [];
// .reverse() before .sortBy() is a Dexie no-op — reverse the array after instead.
// tmp_sort_1 here uses legacy encoding (priority=true→'1') designed for DESC order.
// tmp_sort_1 is built with build_tmp_sort() and is designed for ASC sort:
// priority=true -> '0', so priority records naturally sort first.
const comments = await db_posts.comment
.where('post_id')
.equals(post_id)
.limit(limit)
.sortBy('tmp_sort_1');
return comments.reverse();
return comments;
});
});

View File

@@ -432,6 +432,20 @@ async function handle_force_reset() {
let show_append_modal = $state(false);
let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
function handle_show_ai_tools() {
show_config_modal = false;
if (typeof window === 'undefined') return;
const entry_id = $lq__journal_entry_obj?.journal_entry_id ?? 'default';
const ai_tools_anchor_id = `journal_entry_ai_tools_${entry_id}`;
queueMicrotask(() => {
const ai_tools_el = document.getElementById(ai_tools_anchor_id);
ai_tools_el?.scrollIntoView({ behavior: 'smooth', block: 'center' });
});
}
</script>
<div class="group/entry-view relative w-full min-w-0">
@@ -488,13 +502,16 @@ let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
? 'ring-primary-500/40 ring-2 ring-inset'
: ''}">
{#if $ae_loc.edit_mode && $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] === 'current'}
<AE_Comp_Journal_Entry_AiTools
content={typeof tmp_entry_obj.content === 'string'
? tmp_entry_obj.content
: ''}
bind:summary={tmp_entry_obj.summary}
on_save={() => update_journal_entry()}
{log_lvl} />
<div
id={`journal_entry_ai_tools_${$lq__journal_entry_obj?.journal_entry_id ?? 'default'}`}>
<AE_Comp_Journal_Entry_AiTools
content={typeof tmp_entry_obj.content === 'string'
? tmp_entry_obj.content
: ''}
bind:summary={tmp_entry_obj.summary}
on_save={() => update_journal_entry()}
{log_lvl} />
</div>
{/if}
<AE_Comp_Journal_Entry_Editor
@@ -539,6 +556,7 @@ let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
on_save={() => update_journal_entry()}
on_force_reset={handle_force_reset}
{on_show_export}
on_show_ai={handle_show_ai_tools}
on_append={() => {
modal_mode = 'append';
show_append_modal = true;

View File

@@ -37,6 +37,7 @@ interface Props {
on_save: () => void;
on_force_reset?: () => void;
on_show_export?: () => void;
on_show_ai?: () => void;
on_append?: () => void;
on_prepend?: () => void;
}
@@ -49,6 +50,7 @@ let {
on_save,
on_force_reset,
on_show_export,
on_show_ai,
on_append,
on_prepend
}: Props = $props();
@@ -254,6 +256,16 @@ async function handle_admin_delete_action() {
<FileDown size="1.2em" />
Export Entry
</button>
<button
type="button"
class="btn preset-tonal-primary w-full justify-start gap-2"
onclick={() => {
show = false;
on_show_ai?.();
}}>
<Zap size="1.2em" />
Summary AI
</button>
<button
type="button"
class="btn preset-tonal-surface w-full justify-start gap-2"