View Shortcut tasks in IntelliJ
Recently, I started to play with tasks in IntelliJ (or PyCharm).
Essentially, they allow to create a context – essentially open tabs, but also
the current branch and list of changed files, plus things like bookmarks and
breakpoints.
This dramatically simplifies switching from a story to another (which in my
case, happens a bit too often), because it’s much easier to recall te point
where you left; as well, it’s easier to make sure that you don’t commit files on
the wrong branch.
That said, setting up a new context every time does not fit my process. I remember using some similar feature in Eclipse, and then giving up because it was just too much work for too little advantage.
However, here it’s possible to integrate with issue/task trackers, thus simplifying the entire workflow quite a lot (note: I am pretty sure the same is available in Eclipse too, but I am no longer using it, so I can’t tell).
There are plugins available already for a variety of trackers, like Jira,
Jetbrains’ YouTrack (obviously), Trello, or GitHub. However, the tracker I
am using currently, Shortcut, is not available.
Or better, there is a plugin “Shortcut tasks (former Clubhouse)", but I
could not make it work reliably. In particular, it was not fetching my
bugs, and it was not possible to set up a query, even if the plugin
documentation says otherwise.
This leaves us with the manual approach of configuring a generic task
server. Essentially, it boils down to a request for searching stories,
with some filters, and since shortcut has pretty nice and documented APIs,
that should be quite straightforward.
Search documentation says that we should issue a GET request, with the
parameters in the BODY part and the token as a header; both of which are not
supported by IntelliJ.
Fortunately, you can also pass them as a query parameter, so that’s not a
problem.
Sidebar: GET requests with payload are possible, but definitely quite weird: according HTTP specification, GET payload are possible but have no defined semantics; moreover, older versions of the specification were even stricter so that a GET request can have a body, but that body should not have any meaning and should be ignored.
Now, it’s time to put all together.
The first step is to check the query syntax, going to the advanced story
search.
Unfortunately, Shortcut does not allow filtering for active iterations,
eventually, the best query I could find was just a simple owner:rob !is:done
.
This translates to an API query like this:
https://api.app.shortcut.com/api/v3/search?token=***&query=owner:rob%20!is:done
which can be tested in any browser.
Next step is to find the mapping configuration for IntelliJ. This is JSON, and we need to pass the correct path for the interesting parts. I used JSON Query to do that work, as it was working quite fine, and eventually got this:
- tasks:
stories.data
- id:
id
- summary:
name
- description:
description
- issueUrl:
app_url
Here is the overall configuration:
- Query:
{serverUrl}/api/v3/search?token={shortcut_api_token}&page_size=25&query=owner%3A{owner}+and+%21is%3Adone+and+is%3Astory
And now, it works like a charm:
- When start work on a story, I chose “Open task”
- To quickly find the story from the list, I usually filter using its number
- Then I open, and usually use the defaults for the task and branch name
- And then I get a clean slate, and start working
If I need to switch from one task to another, I repeat the tasks above, and then switch back to the original task once done.
The only problem arise when completing a task: because I manually need to delete the task and the associated branch. Two clicks.
Finally, I know that it’s also possible to track time spent on every task, and then put in Jira/Shortcut/whatever you use; but this is not something I tried, so I can’t really tell how that works.
However, even without that,I think that using tasks and contexts in IntelliJ
is a very good tool to help maintaining focus when there is task switching.
Setting it up with Shortcut costed me a bit, but overall, it was worth it.