obsidian-tasks-group / obsidian-tasks

Task management for the Obsidian knowledge base.
https://publish.obsidian.md/tasks/
MIT License
2.27k stars 223 forks source link

Tasks 7.4.0 breaks Kanban plugin's use of Tasks Auto Suggest - giving 'Failed to save "file name" automatically...' #2896

Closed DudeThatsErin closed 1 month ago

DudeThatsErin commented 1 month ago

Please check that this issue hasn't been reported before.

Expected Behavior

No error should appear.

Current behaviour

I have Obsidian Tasks v7.4.0 and Kanban v2.0.51 and whenever I am creating a new card and the tasks pane pops up above the editor (I'll have another bug report on that one as it is always staying up) and I go to add anything like a due date or start date or whatever, it gives this error.

image image image

Debug Info:

SYSTEM INFO:
    Obsidian version: v1.6.3
    Installer version: v1.6.3
    Operating system: Windows 10 Home 10.0.22631
    Login status: logged in
    Catalyst license: supporter
    Insider build toggle: off
    Live preview: on
    Base theme: adapt to system
    Community theme: AnuPpuccin v1.5.0
    Snippets enabled: 4
    Restricted mode: off
    Plugins installed: 18
    Plugins enabled: 16
        1: BRAT v1.0.1
        2: Omnivore v1.10.3
        3: Settings Search v1.3.10
        4: Tasks v7.4.0
        5: Git v2.24.2
        6: Archiver v0.26.1
        7: Banners v2.0.5-beta
        8: Calendar v1.5.10
        9: Dataview v0.5.66
        10: Excalidraw v2.2.5
        11: Iconize v2.12.1
        12: Kanban v2.0.51
        13: Omnisearch v1.23.0
        14: Templater v2.3.3
        15: Style Settings v1.0.8
        16: Text Extractor v0.5.2

RECOMMENDATIONS:
    Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets.
    Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Steps to reproduce

  1. Install Tasks
  2. Restart Obsidian
  3. Install BRAT
  4. Set up Kanban in BRAT
  5. Restart Obsidian (for good measure)
  6. Create a Kanban Board
  7. Create a List
  8. Create a Card
  9. Add due date to said card Error should appear.

Note from maintainer: See https://github.com/obsidian-tasks-group/obsidian-tasks/issues/2896#issuecomment-2178988383 below for a reproduction without redundant steps, and that does not require knowledge of the Kanban plugin.

Which Operating Systems are you using?

Obsidian Version

1.6.3

Tasks Plugin Version

7.4.0

Checks

Possible solution

Copying over from Obsidian Kanban as you requested!

claremacrae commented 1 month ago

Thank you.

Can the steps to reproduce be shortened: why does BRAT need to be installed?

DudeThatsErin commented 1 month ago

When I originally opened this (I just copied and pasted everything to this report) Obsidian Kanban hadn't released full capability for Tasks in the official release.

I haven't had time recently to check to see if it is in the official release yet.

claremacrae commented 1 month ago

It is in the official release. I am working on a simpler and more precise reproduction - so there's no need to update...

claremacrae commented 1 month ago

Reproduction that doesn't require familiarity with the Kanban plugin

Here is a reproduction without redundant steps, and that does not require knowledge of the Kanban plugin:

  1. Install and enable Tasks
  2. Install and enable Kanban
  3. Create a Kanban board:
    1. Click the "Create new board" icon in the Ribbon
  4. Create a list:
    1. Type a name for the first column, e.g. "Stuff"
    2. Click "Add list"
    3. Click "Done"
  5. Create a card and attempt to give it a due date:
    1. Click "+Add a card"
    2. Type some text in the "Card title..." box, e.g. "Do something"
    3. Click on the "📅 due date" button in the Tasks context menu

Expected result: A due date emoji is added to the card

Actual result: The following error message is displayed:

image

claremacrae commented 1 month ago

I have Obsidian Tasks v7.4.0 and Kanban v2.0.51 and whenever I am creating a new card and the tasks pane pops up above the editor (I'll have another bug report on that one as it is always staying up)

I don't exactly understand, but to help inform where you would log that: whether or not the Tasks menu shows inside the Kanban UI is totally controlled by Kanban source code, not Tasks.

claremacrae commented 1 month ago

Workaround noted in https://github.com/mgmeyers/obsidian-kanban/issues/985:

claremacrae commented 1 month ago

@mgmeyers noted in https://github.com/mgmeyers/obsidian-kanban/issues/985#issuecomment-2161644701:

@claremacrae It seems the issue here comes from these lines:

https://github.com/obsidian-tasks-group/obsidian-tasks/blob/7ca5c1163ddaec4ea8c5bd9c22a18ef2f3273d33/src/Suggestor/EditorSuggestorPopup.ts#L175-L181

The assumption here is that markdownFileInfo is an instance of MarkdownView which is not the case when editing a Kanban card (which is a KanbanView).

claremacrae commented 1 month ago

@mgmeyers - there are two options here:

  1. The robust, long-term one: enable/require plugins that use the Tasks Auto Suggest interface to provide a mechanism that Tasks can call to save edits back to the file containing the task that is being edited
  2. If edits cannot be saved, then make Tasks not include id and depends on fields in the Auto Suggest menu.

1 is better for users, and is less complexity in the Tasks code.

Can you see a way of adding/enabling 1 to the mechanism you created in #2778 please?

claremacrae commented 1 month ago
  1. If edits cannot be saved, then make Tasks not include id and depends on fields in the Auto Suggest menu.

See the uses of globalThis.SHOW_DEPENDENCY_SUGGESTIONS for where to change...

claremacrae commented 1 month ago

My comment from https://github.com/mgmeyers/obsidian-kanban/issues/985#issuecomment-2161673813:

I can probably make it so that Tasks doesn’t offer Dependency suggestions if the edits cannot be saved. Which will remove the requirement to be able to save the file.

mgmeyers commented 1 month ago

Hi Clare. I took a look at what could be done on my end. Unfortunately things are a bit complicated. I can provide a save function with kanban's version of markdownFileInfo. The only issue is that edits to cards are temporary, i.e. they aren't saved to the view's state or the disk until the user commits them by pressing enter. This allows users to cancel edits.

How does the forced save support dependency suggestions? Maybe there's another approach I could take on my end to support this.

claremacrae commented 1 month ago

Hi Matthew. Thanks very much for looking in to this.

Background

I should give some more background info...

Prior to Tasks 7.4.0, Auto-Suggest only ever modified the line being edited, and nothing else in the vault.

However, 7.4.0 added this specific feature - copied from the docs:

image

It was really irritating for users to have to:

  1. First add an 🆔 id to a task
  2. Then add a ⛔ depends on id to the task that depended on the first task....

The above screenshotted facility allows this to be done in one step.

Getting it to work reliably required me to ensure that Tasks saved the new id value, and updated its cache of tasks, before trying to adding the depends on value. See https://github.com/obsidian-tasks-group/obsidian-tasks/pull/2876.

And the code for that is exactly the code that is causing the error message in Kanban now, as my saving assumed use of MarkdownView.

Conclusion

The only issue is that edits to cards are temporary, i.e. they aren't saved to the view's state or the disk until the user commits them by pressing enter. This allows users to cancel edits.

That is a really helpful thing to know.

In that case, I really think the best compromise for now is for me to make Tasks not offer Dependency suggestions if the editor is not a MarkdownView.

claremacrae commented 1 month ago

The fix for this is now released, in Tasks 7.5.0.