Skip to content

Conversation

@justise
Copy link
Contributor

@justise justise commented Nov 27, 2025

Types of changes

Changes visible to users:

  • New feature (prefix: feat - non-breaking change which adds functionality)
    • Issue/discussion:
    • WARNING: If the link is absent, the PR may be closed without review, due to the workload that such reviews usually require.
  • Breaking change (prefix: feat!! or fix!! - fix or feature that would cause existing functionality to not work as expected)
    • Issue/discussion:
  • Bug fix (prefix: fix - non-breaking change which fixes an issue)
  • Translation (prefix: i18n - additions or improvements to the translations - see Support a new language)
  • Documentation (prefix: docs - improvements to any documentation content for users)
  • Sample vault (prefix: vault - improvements to the Tasks-Demo sample vault)
  • Contributing Guidelines (prefix: contrib - any improvements to documentation content for contributors - see Contributing to Tasks)

Internal changes:

  • Refactor (prefix: refactor - non-breaking change which only improves the design or structure of existing code, and making no changes to its external behaviour)
  • Tests (prefix: test - additions and improvements to unit tests and the smoke tests)
  • Infrastructure (prefix: chore - examples include GitHub Actions, issue templates)

Description

An earlier PR introduced a change to the TaskModal which only submitted when there were any task updates.

This means that the API calls were not resolving when you cancel.

The solution is to add an onCancel callback so we can resolve the API functions even on cancel.

The change was simple enough I did not break it up into multiple changes (some AI support was leveraged as well).

Motivation and Context

Without this bug fix, usage of the tasks API functions will result in bugs as canceling will leave the program with unresolved promises.

Addresses Issue: #3656

How has this been tested?

Manual using the linked plugin
Updated Unit tests

Screenshots (if appropriate)

n/a

Checklist

Terms

@sonarqubecloud
Copy link

@claremacrae claremacrae added the scope: for plugin developers Tools for use by plugin developers, including the Tasks API label Nov 27, 2025
@claremacrae
Copy link
Collaborator

Thank you very much for this - I will test it soon...

Copy link
Collaborator

@claremacrae claremacrae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for looking at this.

My concern about this PR is the following test:

/**
* If the Modal is cancelled, the api function createTaskLineModal() should return an empty string
*/
it('should return an empty string if cancelled', async () => {
const taskLinePromise = createTaskLineModal(app, []);
const expected = '';
TaskModal.instance.cancel();
const result = await taskLinePromise;
expect(result).toEqual(expected);
});

See #3656 (comment).

Since that test didn't fail before the fix, and doesn't change in behaviour with this PR, it appears to not be a useful test - and therefore is not protecting us against future breakages of the Cancel feature, perhaps?

@justise
Copy link
Contributor Author

justise commented Dec 1, 2025

I was thinking about that too. The issue was the Mock just called onSubmit without checking the length of the return value. Let me verify that my new change fixes that and it would fail with the new mock code or add that check in so the mock is accurate.

Thx @claremacrae

@claremacrae
Copy link
Collaborator

Hi @justise, I'm going to be doing a release fairly soon, so if you had time to look at the test, it would really help.

If you can't, just let me know and I will merge anyway, as it's clearly an improvement.

@claremacrae claremacrae added the question Further information is requested label Jan 6, 2026
@claremacrae claremacrae changed the title Add an onCanceled callback to allow resolving edit and create APIs fix: Add an onCanceled callback to allow resolving edit and create APIs Jan 6, 2026
@justise
Copy link
Contributor Author

justise commented Jan 11, 2026

Sorry, I got distracted with some beginning of the year stuff and holiday break. Haven't had a chance to circle back on this yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested scope: for plugin developers Tools for use by plugin developers, including the Tasks API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants