Show AI tools only in edit mode; open existing summary without regenerating

- Hide AI tools panel when entry is not in edit mode
- Clicking AI button when a summary already exists opens it directly
  instead of triggering a new API call; Re-run still available in modal

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-05-08 17:22:16 -04:00
parent bdba092de0
commit 66c0be65c4
2 changed files with 19 additions and 9 deletions

View File

@@ -157,9 +157,17 @@ function handle_save() {
<!-- Trigger Button -->
<button
type="button"
onclick={generate_ai_result}
onclick={() => {
if (summary) {
tmp_summary = summary;
active_tab = 'result';
show_modal = true;
} else {
generate_ai_result();
}
}}
class={buttonClass}
title="Generate AI summary/analysis">
title={summary ? 'View existing AI summary' : 'Generate AI summary/analysis'}>
{#await ae_promises}
<Loader class="mr-1 inline-block animate-spin" size="1.2em" />
<span class="text-sm">Processing...</span>

View File

@@ -487,13 +487,15 @@ let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
] == 'current'
? 'ring-primary-500/40 ring-2 ring-inset'
: ''}">
<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} />
{#if $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} />
{/if}
<AE_Comp_Journal_Entry_Editor
entry={$lq__journal_entry_obj}