spec updated
This commit is contained in:
parent
83b8544404
commit
7bac86cc82
3 changed files with 73 additions and 1 deletions
|
|
@ -41,6 +41,30 @@ js/mzta-prompts.js (builds final prompt string)
|
|||
js/mzta-compose-script.js (inserts text into Thunderbird compose window)
|
||||
```
|
||||
|
||||
### Data Flow: Inline Summary on Message Display
|
||||
|
||||
```
|
||||
User opens/selects a message in Thunderbird
|
||||
↓
|
||||
mzta-compose-script.js (sends "initSummary" to background)
|
||||
↓
|
||||
mzta-background.js (checks summarize_auto pref)
|
||||
↓
|
||||
┌────────────────────────────────────────────────┐
|
||||
│ summarize_auto = 0 → do nothing │
|
||||
│ summarize_auto = 1 → show "click to generate" │
|
||||
│ summarize_auto = 2 → generate immediately │
|
||||
└────────────────────────────────────────────────┘
|
||||
↓ (if generating)
|
||||
taSummaryStore (check cache / set processing)
|
||||
↓ (cache miss)
|
||||
mzta-special-commands (via Web Worker, NOT chatgpt_web)
|
||||
↓
|
||||
taSummaryStore (save result via taStorage)
|
||||
↓
|
||||
mzta-compose-script.js (render summary banner in message body)
|
||||
```
|
||||
|
||||
## Key Modules
|
||||
|
||||
| File | Role |
|
||||
|
|
@ -51,13 +75,15 @@ js/mzta-compose-script.js (inserts text into Thunderbird compose window)
|
|||
| `js/mzta-placeholders.js` | Placeholder definitions and resolution logic |
|
||||
| `js/mzta-utils.js` | General utilities (email parsing, storage helpers, etc.) |
|
||||
| `js/mzta-utils-prompt.js` | Prompt-specific utilities (text truncation, lang injection) |
|
||||
| `js/mzta-compose-script.js` | Injects AI response into Thunderbird compose window |
|
||||
| `js/mzta-compose-script.js` | Content script for compose and message display: injects AI response into compose window, renders summary/spam banners in message display |
|
||||
| `js/mzta-chatgpt.js` | ChatGPT Web integration (opens browser window, reads DOM) |
|
||||
| `js/mzta-special-commands.js` | Handles special prompt actions (add_tags, calendar, task) |
|
||||
| `js/mzta-spamreport.js` | Spam filter logic |
|
||||
| `js/mzta-i18n.js` | i18n helper (wraps `browser.i18n.getMessage`) |
|
||||
| `js/mzta-logger.js` | Debug logging (gated by `do_debug` pref) |
|
||||
| `js/mzta-store.js` | Storage abstraction helpers |
|
||||
| `js/mzta-storage.js` | Unified per-message storage layer (`taStorage` class) for summary, spam, and translation data |
|
||||
| `js/mzta-summarystore.js` | Summary-specific storage wrapper (`taSummaryStore` class) with caching, truncation, and processing-state tracking |
|
||||
| `js/mzta-working-status.js` | Visual status indicator during AI processing |
|
||||
| `js/mzta-addatags-exclusion-list.js` | Tag exclusion list management |
|
||||
| `js/mzta-placeholders-autocomplete.js` | Autocomplete for placeholders in prompt editor |
|
||||
|
|
@ -106,3 +132,9 @@ Each subdirectory is a self-contained settings/UI page for a specific feature:
|
|||
## Storage
|
||||
|
||||
All preferences are stored via `browser.storage.local`. The keys and default values are defined in `options/mzta-options-default.js` (`prefs_default` export). Custom prompts and custom placeholders are stored separately in storage under their own keys.
|
||||
|
||||
### Per-Message Data Storage
|
||||
|
||||
Per-message data (summaries, spam reports, translations) is stored via `js/mzta-storage.js` (`taStorage` class). Each record is keyed by `msg:<headerMessageId>` in `messenger.storage.local` and follows schema version 1. Records contain optional fields: `summary`, `spam`, `translation`, plus metadata (`v`, `ts`). The `taStorage` class provides typed read/write/delete methods per field, automatic record cleanup when all fields are removed, and age-based cleanup.
|
||||
|
||||
`js/mzta-summarystore.js` (`taSummaryStore` class) wraps `taStorage` for summary-specific operations: load/save/remove summaries, track in-flight generation state via `browser.storage.session`, enforce a 100-entry cache limit with oldest-first truncation, and store error states.
|
||||
|
|
|
|||
|
|
@ -58,6 +58,29 @@ Some prompts trigger additional Thunderbird actions beyond just sending text to
|
|||
|
||||
These special prompts can have their own dedicated API integration settings (configured in the Options page). The list of these special prompts is in `options/mzta-options-default.js` as `special_prompts_with_integration`.
|
||||
|
||||
### Summarize: Dual-Mode Prompt System
|
||||
|
||||
The summarize feature uses two distinct prompt pathways:
|
||||
|
||||
**Context Menu Summarize** (right-click on messages in message list):
|
||||
- Activated via the `summarize` context menu item, controlled by the `summarize` feature flag
|
||||
- Uses 3 special prompts stored in `specialPrompts`:
|
||||
- `prompt_summarize` — the main instruction prompt for the LLM
|
||||
- `prompt_summarize_email_template` — template for formatting each email's content
|
||||
- `prompt_summarize_email_separator` — separator text between multiple emails
|
||||
- Supports multi-email summarization: each selected message is formatted with the email template, joined by the separator, then prepended with the instruction prompt
|
||||
- All 3 prompts support placeholder autocomplete (`{%placeholder%}` syntax)
|
||||
- Result is displayed via `openChatGPT()` in the standard chat output window (not inline)
|
||||
- Default prompt texts are stored as i18n keys: `prompt_summarize_full_text`, `prompt_summarize_email_template_full_text`, `prompt_summarize_email_separator_full_text`
|
||||
|
||||
**Inline Summary on Message Display** (automatic or manual per `summarize_auto` pref):
|
||||
- Uses a single i18n string `auto_summary_prompt` concatenated with the message body text
|
||||
- Does **not** use the 3 special prompts above
|
||||
- Does **not** support `chatgpt_web` connection type (shows error if configured)
|
||||
- Result is rendered as a styled banner at the top of the message body via `mzta-compose-script.js`
|
||||
- Banner includes a refresh button (↻) to regenerate the summary
|
||||
- Cached per-message via `taSummaryStore` / `taStorage` (max 100 entries)
|
||||
|
||||
## Prompt Types Reference
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -95,6 +95,23 @@ These are generated programmatically at the bottom of `mzta-options-default.js`
|
|||
| `spamfilter_enabled_accounts` | `[]` | Accounts where spam filter is active |
|
||||
| `spamfilter_show_msg_panel` | `true` | Show info panel on spam detection |
|
||||
| `summarize` | `false` | Enable email summarization |
|
||||
| `summarize_auto` | `0` | Auto-summarize mode: `0` = disabled, `1` = manual (show "click to generate" button), `2` = automatic (generate on message open) |
|
||||
|
||||
### Summarize Settings Page (`pages/summarize/`)
|
||||
|
||||
The summarize settings page provides:
|
||||
|
||||
1. **Specific integration checkbox** — enables per-feature API override (like other special prompts)
|
||||
2. **Auto-summarize dropdown** (`summarize_auto`) — three modes:
|
||||
- `0` (Disabled) — no inline summaries
|
||||
- `1` (Manual) — shows a "Click to generate summary" button in message display
|
||||
- `2` (Automatic) — generates summary immediately when message is opened
|
||||
3. **Three editable prompts** (used by context menu summarize, not inline):
|
||||
- Summarize instruction prompt (`prompt_summarize`)
|
||||
- Email template prompt (`prompt_summarize_email_template`)
|
||||
- Email separator prompt (`prompt_summarize_email_separator`)
|
||||
- Each has Save/Reset buttons and placeholder autocomplete
|
||||
- Default text comes from i18n strings (`prompt_summarize_full_text`, etc.)
|
||||
|
||||
## Adding a New Preference
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue