Drafts Diagnostic Action26 Dec 2020
As a passionate user of the Drafts app by AgileTortoise, I usually spend at least some time each day on the Drafts forums catching up on the latest news and discussions, and helping other users with their queries where I can. Sometimes that help requires a few iterations of questions, tests and reviews. At times people can struggle as to what it is they are looking for. Recently I gave some consideration as to what I could do to speed up the process and help people provide pertinent information faster.
I decided to see what I could do to start developing some sort of diagnostic assistance tool for Drafts. Given that users of the app could be experiencing issues with their iPhone (and Apple Watch), iPad, and Mac, I was sure that whatever I created I’d want to run on any of the primary platforms. As a result, going with a Drafts action-based solution was the obvious approach, and would give me easy access to query many of Drafts’ settings.
The Initial Version
It consisted of a set of information gathering actions I figured would help in investigating this issue (specifically the file listing for the Previews directory), as well as some others that I quickly put together to allow me to put something out there that wasn’t just a one shot.
I also included a set of output options. By default, the action is set to preview the output in a prompt window. This provides the user with an initial view of what the output will be.
Below this, I included some options to allow the content to be placed on the clipboard in a range of formats based around Markdown (or more specifically MultiMarkdown), HTML, and rich text.
The hidden details section is one that I feel is particularly useful and was created with the Drafts forum in mind. The Discourse (not Discord) software that runs the forum allows content in Markdown format to be hidden in spoiler/summary sections. These sections have a disclosure triangle that allows you to expand them and reveal the content beneath. Given the potential length of some of the output from the action, I thought that automatically wrapping the output on the clipboard with the appropriate mark up was a good idea; particularly as many forum users do not know that the option even exists.
The action ultimately did help to identify an error in the user’s folder path.
A Few Iterations Later
That was almost three weeks ago, and since then I’ve been running through a few iterations making some additions and improvements to the action.
Here’s what has been added in each revision.
- Added several additional data gathering sections for app and action information.
After the initial release I had a quick run through of what else I thought might be useful, based on some of the more recent issues I had seen come up. As a result I added some more data gathering around actions, workspaces and the editor (object).
- Fixed an action name containing emoji display bug on macOS.
I prefix a number of my action group names with emoji characters and while the display of these in the preview was working fine on my iPhone and iPad, the same was not true on my Macbook Pro. Instead it was displaying odd looking accented characters - a sure sign of an encoding issue. I found it a little odd that it varied between devices, but after several attempts at amending the output encoding I found an option that worked and now my action group names show perfectly wherever the action is run.
- Added higher performance file/directory listings for macOS (only).
- Removed unnecessary element spacing in action group listing.
After contacting Greg, the Drafts developer, about performance when dealing with iCloud storage, I figured that while I couldn’t make much if any change to the performance of the File System queries on i*OS, the same was not true of macOS where I can run shell scripts. As a result I modified the action to take advantage of this option and use some shell scripting to return directory listings instead. This is several orders of magnitude faster, and I would certainly recommend that for complex file structures that this is run on the Mac.
For example, I have my entire TADpoLe library working files, including the documentation web site it generates all embedded and git version controlled within a sub-directory of my Drafts
Scripts folder. That is a lot of files and a complex directory structure. It is not suitable to scan on i*OS from Drafts.
- Added current draft information, including content dump and version information.
- De-Markdown action/separator and action group names so they are not interpreted on output.
- Added wrapping to code sections.
In this latest version I added some additional data capture based around the current draft. The main idea was to allow data about the draft, including its content, to be captured to include as an example of a draft where an issue may be occurring. Having these details for an example can make it much easier to reproduce an issue.
In addition I added some code to “de-Markdown” action, separator and action group names. If these names contained content that was valid Markdown, that would be interpreted and we don’t want that. We want to see the actual names even when rendered.
Along with this I amended the CSS used by the action to wrap the content in the pre-formatted/code sections. While this won’t wrap really long singular content (on purpose), it will make a nicer display in the preview for content that is long. For example a paragraph of text that is constructed on a single line will be soft-wrapped when tagged for pre-formatting.
The Current Action
As of today, the action can capture content in the following areas:
- Drafts Info
- Editor Info
- Workspace Info
- Current Workspace
- Device Info
- Directory Listing for Previews
- Directory Listing for Scripts
- Directory Listing for Templates
- Action Group Listing
- Action Listing
- Action Keyboard Shortcuts Listing
- Current Draft Info
- Current Draft’s Versions
- Current Draft Content
The action can also output to the following:
- Rendered Preview Window in Drafts
- Content to Clipboard
- As MultiMarkdown
- As MultiMarkdown in a Hidden Details Section
- As HTML
- As Rich Text
You can always download the latest version of the action from the Drafts Action Directory.
I’ll be endeavouring to update the action whenever I think of anything useful to add, and I’m certainly open to suggestions - just contact me on the Drafts forum or on Twitter if you have any suggestions. Otherwise, I hope you find this action useful and that it is useful to the wider Drafts community in troubleshooting issues in Drafts.