Repository navigation
Protect unsaved voucher content from MCP draft replacement - #139
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MCP clients could silently discard a voucher the user was composing by staging the next proposal.
set_active_voucher_draftnow refuses to replace meaningful unsaved content unlessreplace_unsaved: trueis explicitly supplied. Refusals returnok: false,error_code: unsaved_changes, andhas_unsaved_changes: true.The check and replacement run together on Swing's event thread. Protection covers descriptions, incomplete lines, attachments, text in active cell editors, drafts retained while browsing saved vouchers, and deliberate date/series changes compared with the blank editor's initial values. That baseline is remembered with the draft and restored across browsing, including vouchers in other series. Empty active cell editors and unchanged defaults count as blank. Explicit replacement cancels any active cell edit.
get_active_voucher_draftleaves the editor untouched. Theeditingflag appears only at the top level. Whenediting: true, returned lines contain committed model values and exclude in-progress cell text.has_unsaved_changesis true/false when known and null when the editor or snapshot is unavailable. An empty editor returnserror_code: no_draft. Unexpected read failures are logged and return a neutral tool error directing the client to the application log; parameter errors on writes retain the existing JSON-RPC invalid-parameters behavior. Amount parsing has a friendly fallback instead of raw JDK messages. Tool and skill documentation describe these responses.SwingThreading.runOnEdtnow propagates all RuntimeExceptions from the EDT unchanged, where previously only IllegalArgumentException was unwrapped. This preserves the distinction between validation errors and state conflicts. The description label now references its input throughlabelFor, improving accessibility and allowing tests to locate the field semantically.Validation:
./gradlew spotlessApply,./gradlew codenarcMain codenarcTest, targeted voucher draft/MCP tests, and./gradlew buildpassed. Full suite: 837 tests, zero failures, 11 skipped. Regression coverage includes reading partially typed accounts/amounts without model events, empty active editors, deliberate date/series changes, structured refusal fields, unavailable/read-error paths, amount errors, EDT execution, attachments, and retained drafts. Cross-series Prev/Next tests verify both blank drafts and deliberate date/series choices, including repeated returns.No schema or migration changes; no visible UI layout changes.
Closes #126.