aboutsummaryrefslogtreecommitdiffstats
path: root/src/composewindow.cpp
AgeCommit message (Collapse)AuthorFilesLines
24 hoursfix(drafts): index a saved draft so it appears without a syncDanilo M.1-0/+6
Autosave writes the draft to the Maildir drafts folder and stops, while the Drafts view is a notmuch path: query, so a freshly saved draft was invisible until notmuch new ran. saveDraftNow() now emits draftSaved, and MainWindow connects it to a new NotmuchWorker::indexDraftFile() that indexes the one file the way moveMessages() does, with the previous revision removed so a rewrite leaves no ghost. The send path unlinks a draft that was indexed while being composed, so draftRemoved -> removeIndexedFile() drops its entry too. Measured: notmuch_database_index_file assigns NO tags (unlike notmuch new, which adds draft inbox unread), so no tag-stripping is needed and the draft cannot leak into a tag:inbox view. Item 158.
25 hoursfix(compose): a resumed draft does not re-seed on a From: changeDanilo M.1-0/+5
A resumed draft kept m_signatureChosen false, so a From: change re-seeded the signature and rewrote what the user had saved, inserting the new account's where the saved block no longer matched a known file. The draft is the user's deliberate prior state and must not follow a From: change, so the draft branch marks it chosen.
25 hoursfeat(compose): the signature follows the account until it is chosenDanilo M.1-5/+22
A From: change re-seeds the signature from the newly selected account, and stops doing so the moment the user picks one from the switch. Re-seeding unconditionally is the one behaviour that can silently discard a deliberate choice made a moment earlier; this is the shape send_html already uses. seededSignatureName() reads the combo rather than the context, which records where the composer opened and does not follow a change to it. Part of item 152.
25 hoursfeat(compose): a signature switch on the editor barDanilo M.1-0/+136
A QToolButton with a checkable menu at the right end of the editor bar, where item 142 put the controls of the editor. Not registered in KeyMap: parented to the composer like the formatting actions, so its scope is this window. The signature is applied through a QTextCursor rather than setPlainText(), which destroys the undo stack, and the seeded one is cleared from that stack for the reason the seeded quote already is: one Ctrl+Z must not wipe content the user never typed. A resumed draft seeds nothing. Its body already carries the signature it was written with, and seeding again would put a second one on a message written once. Part of item 152.
33 hoursfeat(compose): open a draft to finish itDanilo M.1-4/+25
Item 153. DraftStore had a write() and no reader, and nothing opened a composer from an existing message, so a draft rendered like ordinary mail and could never be finished or sent. ComposeContextBuilder::forDraft() reads one back. A new Kind::Draft seeds every field verbatim: the subject takes no Re:/Fwd: prefix, and the body goes in exactly as it was left, with none of seedBody()'s quote framing. It is reachable by double-click and by an edit_draft action in the Message menu. Three things the shape of this depends on. A resumed draft must OWN its file. Maildir has no in-place edit, so an autosave writes a new file and unlinks the old one; a composer that did not know its own path would leave the original behind and one message would become two. ComposeContext::draftPath carries it into m_draftPath, which the autosave already knew how to replace. MimeParser had no bcc, and nothing had ever needed one. MessageBuilder writes Bcc into the draft file deliberately and explains why, so a resumed draft that ignored it would drop every blind recipient from the message the user then finishes and sends, reporting nothing. edit_draft is gated on the file being inside a configured drafts folder, matched on the PATH. A `draft` tag is not enough: notmuch surfaces the Maildir D flag as one, and a message flagged by another client sits in the inbox. Offered on ordinary mail, the composer would own a file it did not write and the first autosave would delete a received message. And a live defect found on the way, which is most of why this took as long as it did. updateComposeActions() ran only from onSelectionChanged. Both signals fire for an ordinary click, so nothing had noticed; but running a query and setting the current index emits currentRowChanged ALONE, so the enablement was computed against the previously selected row. Edit draft stayed disabled on a draft selected that way, and the reply family had the same blind spot with no test that could see it. Now connected to both. Reading currentRowChanged is safe here for the reason CLAUDE.md gives: it answers "which row is current", and no count is read. WorkerBackedWindow::AccountSpec gains a drafts field, which the two new tests need and which no fixture could express before.
34 hoursfeat: add a Drafts filter, and close the composer with Ctrl+WDanilo M.1-0/+14
Items 138 and 148. The query row carried Unread, Inbox, Important, Sent and Trash, and no Drafts, though the composer has been autosaving into each account's drafts folder since compose shipped. Reaching them meant typing a query by hand. Smaller than its size suggested: Account::draftsQuery() and Config::allDraftsQuery() already existed for the placeholder pane's drafts count, and builtinFilters() derives the row from kQueryGenerators, so the work was the generator entry, two resolvedQuery branches, a label and an icon. It follows TRASH rather than Sent. Folder-matched like both, because `draft` is a Maildir flag notmuch surfaces as a tag while the folder is what the user means and what the composer actually writes into. But NOT flat: Sent is flat so a thread cannot fold the user's own message back into the conversation it answers, and a draft reply belongs with its conversation for the same reason a trashed message does. An account with no drafts folder shows no button, per item 103's rule. The existing row test surfaced that by failing until its fixture configured one, which is the rule working rather than a defect. Ctrl+W closes the composer, which bound nothing at all: the only way out was the title bar. The action is parented to the composer, so it is a WindowShortcut dispatched to the active one only and the main window's namespace is untouched, exactly like the formatting shortcuts. It calls close() rather than doing anything of its own, since closeEvent() already decides whether the draft is saved and a second route out that skipped it would lose the message. The Italian gains "Bozze"; lrelease reports 478 finished, 0 unfinished.
34 hoursfix(compose): make the Send button a square that reads as one itemDanilo M.1-2/+16
An Expanding vertical size policy stretched the button to the full height of the header form beside it, while the icon and the label kept their natural sizes. The result was a tall rectangle with the icon anchored near the top, the label near the bottom, and a gap between them: two marks rather than one control. Fixed size, derived from the icon so the square still fits its contents if toolbar_icon_size changes, and aligned vertically centre against the headers so the whole button is centred rather than its contents. The icon grows to the configured size plus 8, since at this scale it is the button's subject and the word underneath is the caption. Nothing in the layout or the actions could see this, which is why the test now asserts the vertical policy and that width equals height. Both fail against the previous code.
34 hoursfeat(compose): lay the composer out by scopeDanilo M.1-23/+193
Items 142, 143, 144 and 145, to the layout the user described. The composer had one addToolBar carrying three scopes at once: text formatting, message composition, and the terminal action. It read as a menu bar that is not one. There is now no window toolbar at all. From: [.............] +--------+ To: [.........] [v Cc/Bcc] | Send | Subject: [...........................] + [B][I][</>][S][link]["] [Attach] [Send as HTML] +---------------------------------------------+ | message text | +---------------------------------------------+ [Remove] * report.pdf <- only when attached Send is a large icon-above-text button beside the headers: it is the terminal action and carries the weight to match. Formatting is a toolbar widget in the central column directly above the text it formats, icon-only with the words kept as tooltips, which is where a tooltip stops being decoration. Attach and the HTML toggle ride the right end of that bar, past a stretch, because neither formats text. Remove attachment sits with the list it acts on and appears only once something is attached. "Also send a formatted copy" becomes "Send as HTML": the old label described a mechanism without naming it, leaving the reader to infer that "formatted" meant HTML and that "copy" meant a MIME part rather than a second message. Cc and Bcc hide behind a disclosure beside To:. revealCcBccIfUsed() only ever shows, never hides, so nothing but the user's own click can make a field holding an address invisible: a hidden recipient is a message going somewhere the sender cannot see, which is worse than the clutter this removes. The label is hidden with each field, since a QFormLayout holds the two as separate items and hiding the line edit alone strands a "Cc:" over empty space. Two send-lock faults, one predicted and one not. The backlog warned that setInputsEnabled() disabled the single toolbar wholesale, so the send-path test was strengthened to name every control BEFORE the split; it then caught Attach live during a countdown, where a file appended after MessageBuilder has run is either dropped or added to bytes already sent, silently either way. With every control named it failed again on format_bold: disabling a QToolBar greys its buttons but leaves each QAction enabled, so Ctrl+B during a send would have edited a message already being built, through a button that looked unavailable. setInputsEnabled() now walks the bar's actions too. The Italian translation is refreshed; lrelease reports 477 finished, 0 unfinished.
35 hoursfix(compose): default to quoting below, and focus the body on a replyDanilo M.1-0/+8
The previous commit fixed the cursor within each quote_position branch and the user still saw the old layout, because the branches were already right: what was wrong was the DEFAULT. quote_position shipped as `above`, and the layout asked for is exactly what `below` already produced, a blank line at the top with the quote underneath. So the default flips, along with the fallback for a malformed value and the warning naming it. Nothing needs an Upgrading note: compose has not been released, so no config in the wild sets this. Focus goes to the body whenever To: is already filled, which a Reply and a Forward always are. The form's first widget took it otherwise, so the user had to click into the editor before typing. A New message keeps the default, since an empty To: is genuinely the first thing to fill in. The focus test asserts on the window's focusWidget() rather than on QWidget::hasFocus(): an unshown window is never active, so hasFocus() reads false whatever the code does and would fail against a correct fix. Both directions are mutation-checked, since focusing unconditionally passes the reply case while breaking the new-message one.
35 hoursfix(compose): put the reply cursor on blank space, not on the quoteDanilo M.1-6/+9
quote_position names where the QUOTE goes, so the reply belongs on the other side of it and the cursor has to follow the reply rather than the buffer. seedBody() moved the cursor to Start under both positions, which is correct only for Below: under Above, the shipped default, it landed on the "On ... wrote:" attribution line, so every reply had to have room made before it could be typed. End under Above, Start under Below. The existing theQuotePositionDecidesWhereTheQuoteLands passed throughout the defect and still does, because the quote was in the right place all along; only the cursor was not. The new test asserts the cursor's block is blank, and that typing lands on the correct side of the quote, so a fix that freed the cursor by inverting the position would not satisfy it. Also re-measures item 136 in the backlog, which is not the intermittent race it was filed as: undoMovesTheMessageBack fails 6 runs in 6 when named alone and passes in the full suite, on a clean tree, so it depends on the tests before it.
3 daysfeat(compose): wire the composer into the main window, item 123compose-and-sendDanilo M.1-0/+68
The reply family is disabled on mail that arrived at an account with no send_command, behind a ribbon in MessageView naming the account and the key to add. save_message is deliberately never disabled: it is the escape hatch for exactly that case. The ribbon is a WIDGET in the pane's layout, never markup inside the web view. Composing HTML from configuration into the one document that renders input from strangers is the wrong direction, and the header row is already a widget for the same reason. Compose itself is disabled only when NO account can send, and that state is not warned about at startup: an installation with no send_command anywhere is a valid read-only installation. Every reply resolves through messageScopeFor(), not threadFor(): a thread row means the one message its card shows. Replying to a thread is meaningless; a reply answers a message. The context is built from the DATABASE rather than the model, the rule Restore already follows, because a row whose state has not been re-queried carries stale values and a reply built from one would carry the wrong recipients. The mail root crosses from the worker as its own signal. There was no route for it at all: mailRootOf() is file-static in notmuchworker.cpp, and item 124 records that composing a destination from database.path writes into the Xapian tree under a split index. The test uses NotmuchFixture::splitIndex(), the only layout where the two accessors disagree. A thread row's path is RELATIVE to the mail root while a message row's is absolute, so the account lookup matched nothing and the reply family was dead on mail from an account that could send. Found by the positive guard test rather than the negative one, which passed throughout for the wrong reason. The quit path checks the failed-save case FIRST. In the ordinary case nothing is lost by saving; there, saving is what is already not working, so the dialog says plainly that quitting loses that text rather than offering a save that will fail again. Both dialogs name the composers, and the ordinary one asks once whatever the count, because three modals in a row is worse than a coarse answer. Its wording says drafts already saved stay in the folder, so Discard cannot read as 'delete my three messages'. The Save loop holds QPointers, not raw pointers. A deleteLater() posted while a nested exec() runs IS processed by that nested loop, measured in a standalone program: the guard nulls before the modal returns. Closing a composer while the quit dialog is up therefore freed a window the loop then called saveDraftNow() on, crashing at the exact moment the application promised to preserve that text. A compose request that matches nothing clears itself and says so. It was cleared only on a match, so a message deleted between selection and Reply left the request armed for the session: Reply did nothing, and the next ordinary click on that message opened a composer nobody asked for while the pane stayed blank. Forward carries the original's attachments, which the context has always had a field for and nothing ever filled, and seeds its HTML toggle from [compose] send_html. Only Reply seeds that from the original. save_message keeps its filename inside the chosen directory and no longer overwrites a file already there. The check was correct and untested: the test asserted through Attachment's helpers rather than through the function production calls, so deleting the containment check outright left it green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TvwDptMWxjqhbCmjxwcSZ2
3 daysfeat(compose): the composer window, item 123Danilo M.1-0/+851
A separate top-level QMainWindow, one per draft, several open at once. A modal dialog cannot consult another message while writing, which is most of what replying is, and taking over the message pane fights the pane that exists to show what is being replied to. No geometry save and no restore, deliberately. Under a tiling compositor saveGeometry stores normalGeometry while the compositor owns the tile, so the restore is correct and looks broken; a whole session went into that once. Autosave is a debounce AND a dirty check: an unchanged message writes no file and provokes no sync. The check is on a fingerprint of the OutgoingMessage, NOT on the built bytes as the plan drafted. GMime is given a fresh Date and Message-ID on every build, so two builds of an unchanged message never compare equal; a check on the bytes would have read as working while writing a file, and an mbsync upload, on every debounce. Checking before the build also skips the blocking build for the no-change case, which is the common one. closeEvent writes the draft when the buffer is dirty. Without it the debounce is a hole rather than a delay: typing a paragraph and pressing the window manager's X inside the interval loses it silently, since WA_DeleteOnClose destroys the window immediately afterwards. A failed save there does NOT refuse the close, because a window that will not close because it cannot save is worse than one that closes having raised the banner, which is what the quit path reads. One flag covers a send, countdown included. An earlier revision had two, and the narrower "committed and running" one reads as the honest thing to guard a live SMTP conversation with. It is not: a close during the countdown destroys the parented SendDialog, committed() never fires, and the user pressed Send, watched a countdown, and believes the mail went. The narrow flag was also written in three places and read in none. A failed draft write raises a persistent banner rather than a modal or a fading status line. A modal mid-sentence is hostile while the user is typing, but the warning must survive until it is dealt with, because the quit path escalates exactly this state to a dialog on the way out. An account with no drafts folder reports success rather than failure: nothing was written and nothing failed, and a false there would make the quit path offer a retry no retry can change. A failed send saves the draft before reporting. send() builds from the widgets without saving, so the revision on disk is whatever the last debounce wrote: edit, send, fail, close, and the user gets the older text back, having watched their correction be sent. A failed sent copy after a successful send is a modal, and never a send failure: the message went, and reporting otherwise makes someone send it twice. It is the one failure here that silently diverges what the recipient received from what the local archive shows, and nobody discovers a missing sent copy by noticing a line that appeared for a few seconds. The formatting toolbar applies its edits through a QTextCursor document replacement inside one edit block, NOT setPlainText as the plan drafted. Measured against a real widget: setPlainText destroys the document's undo stack and resets the cursor to 0, so every toolbar press would throw away everything the user could undo. The cursor route leaves undo available, collapses to a single undo step, and emits textChanged once. The seeded quote is cleared off the undo stack afterwards, since it is not an edit the user made and one Ctrl+Z on a fresh composer must not wipe it. The per-send connect carries Qt::SingleShotConnection. MessageSender is a long-lived member, so a bare connect accumulates a permanent receiver per send and the second result runs both lambdas, the first still holding the first message's bytes: it files a sent copy of the wrong message and acts on a dialog it already destroyed. Covered by a test that sends, fails, corrects and sends again; without the flag it segfaults in QLabel::setText on the destroyed dialog. Its companion disconnect takes the specific connection handle rather than every finished receiver on this object, so a later observer cannot be killed silently. The attachment warning states sizes with a decimal and a stepped unit. Integer MB division read as "'x' is 0 MB. Many mail servers refuse messages above about 0 MB." for any attachment_warn_bytes below a megabyte, in both halves of one sentence. The autosave timer is created before buildUi(), which is load-bearing: buildUi connects every field to markDirty and seeding then fills those fields, so markDirty runs during construction. Created afterwards it is a null dereference on the first seeded field, which is every composer. Twenty-six cases in test_mainwindow, each mutation-checked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>