ContextKeeper / ContextKeeper.VisualStudio

Session Manager for Visual Studio
17 stars 0 forks source link

Session Manager for Visual Studio

Your favorite files and contexts under your fingertips. Safely store and switch between documents sets in seconds using simple JSON files πŸ”₯ Save progress on tasks easily! ContextKeeper is a modern replacement for Save All Tabs extension.

πŸ’« Automatically switch contexts when changing Git branches and check article about it.

πŸ’‘ ContextKeeper is currently in the Open Beta, if you will find any issues please report them.

Are you use using Favorite Documents, Workspace Manager or Task Canvas? Check how much value ContextKeeper delivers when compared to them.

Looking for ARM-compatible build or VS 2019/2017/2015 support? Download from here.

The supported context is made by:

Join the revolution and install it today! Save at least 3300 minutes/year = 55 hours = 2.3 days (15 mins x 20 days x 11 months). You need about 15 minutes to fully switch between contexts at the best possible scenario.

In worst case scenarios switching to detailed context could take several hours, one of the real horror stories:

"Losing this functionality interrupts my workflow beyond imagination. The opened documents represent a "bookmark" for me and I'm barely able to pick up work again without them.

Every time this happens (...) I am willing to put hours into finding a solution, because the thought of losing my opened document state once more after a work session is terrifying. But this time around (...) nothing of the usual remedies helps (...) This has added another 20 Minutes and counting to my two hours put into solving this."

With ContextKeeper you could safely store and switch between different programming contexts in seconds πŸ”₯

All opened files, pinned tabs, documents positions and state (horizontal/vertical orientation, docked state and files order), breakpoints and bookmarks are preserved in a simple JSON file 😍 No more dealing with broken .suo file again.

After installing VSIX package you could access your latest Mental Snapshots by navigating to

View -> Other Windows -> Mental Snapshots

img

By default tool window will open next to Solution Explorer

img Tool

You could create a new snapshot using Create Snapshot button

img

and restore them quickly using few commands from right-click context menu

img

Automatic snapshot switching when changing branches

img

When switching to another git branch ContextKeeper will automatically remember current branch snapshot and save it to .contextkeeper/.git-branches folder. Also it will be added to the "Mental Snapshots" UI list at the very top with prefix:

img

This is the same process that you could do manually before switching branches but now fully automated for your convenience πŸ”₯. The current branch snapshot is always continuously auto-saved when you add, remove or change position of any document tab or window (with tabs).

Also a git branch could be changed from CLI, Visual Studio or other third-party client and ContextKeeper will detect it auto-magically πŸ§™β€β™‚οΈ and restore snapshot for currently selected branch.

Breakpoints and bookmarks

Generally, when a snapshot is created, breakpoints and bookmarks are saved only for the currently open files. This behavior differs from that of Visual Studio, which remembers all breakpoints and bookmarks across different sessions for all files. However, I believe that saving them only for open files is more practical. I remember countless examples of finding old breakpoints from days before that were no longer relevant because I was working on a different task.

The second important thing is that when they are restored for a file, all old breakpoints or/and bookmarks are removed if there were any, but only for that file and nothing else.

Breakpoints

Standard and conditional breakpoints are currently supported. When breakpoint is disabled it will be still saved to a snapshot with IsEnabled property set to false and restored in a disabled state later in the Visual Studio. A single conditional expression is supported with two modes Is true and When changed

img

Although the supported area is probably enough for about 90-95% of use cases, there are some limitations:

I will be looking for ways to support excluded areas, starting from β€œHit Count” and combined conditions (e. g. Conditional Expression with Hit Count). Unfortunately not every breakpoint’s detail is easily exposed via API but I will be extensively digging in Visual Studio’s internals to cover more use cases.

Bookmarks

Bookmarks are stored using line numbers in a similar way to breakpoints.

img

Visual Studio API for bookmarks is really limited; therefore, currently there is no support for:

I hope you will enjoy using new breakpoints & bookmarks support!

Relative paths

The feature was one of the missing puzzle pieces, that I always wanted to include. Adding support for relative path is essential part to allow sharing your context between different dev environments and also inside your team. It will unlock potential to e. g.:

Every time a new snapshot is created it will include RelativePath property for every entry in a *.ck file. When a snapshot is restored, relative paths will be used by default. There is still FilePath property used, as a fallback strategy, for global files. All different types of files are supported including:

RelativePath

Selected and active documents in tab groups

There can be multiple tab groups opened at once and single document selected in each:

img

The state of both selected documents is now preserved using IsSelected JSON property.

Additionally, support for the active tab was added. When a document has focus while generating the snapshot, it will be tagged internally using IsActive property.

img

Create stash snapshot and restore it later

There are two additional commands in the toolbar. Stash and unstash. The idea is from git workflow but here it's applied to a current context you're working on. You could quickly save it (stash) and switch to something else that needs an urgent attention. After stashing a snapshot all tabs will be closed automatically, similarly how stashing works in git - current context is cleared and ready for a new work.

A stash snapshot is always displayed as a first on the list. Currently only single stash is supported but multiple stashes will be supported in the future.

img

A stash has additional description, like " 2 hours ago", to get you additional awareness how long it's awaiting to be unstashed. It's really easy to lose track of time, during coding session, and it will act as an useful reminder how long your "main" task was put on hold. The stash timestamp description is live updated. If you decide that more meaningful name for stash snapshot is needed, you can simply rename it and it will become a regular snapshot.

Keyboard shortcuts

You could assign your favorites keyboard shortcut combination for stash and unstash commands from the toolbar. There aren't default shortcuts assigned but I found useful to use:

img

Full screen windows support

There is a support added to remember if windows is maximized during snapshot creation. No more problems with restoring maximized windows, especially during git branch switching 😍 Only maximized windows will have additional property serialized in a snapshot.

img

Where the snapshots are stored?

All snapshots are stored in the .contextkeeper folder which is created in the same folder where solution file (.sln) sits. A snapshot is saved using self explanatory JSON format. You could try changing different bits manually and later checking an impact it has during restoring process.

img

Git worktree support

The git worktree support, introduced in v1.3, allows even more streamlined context switching. If you sometimes clone entire repository when working on a feature I recommend checking git worktree. Long story short, working tree is like clean, cloned repository but better because:

How much value ContextKeeper delivers when compared to others

Below, you'll find a table comparing extensions that work with VS 2022. I've included free extensions, with the exception of Task Canvas, which is a paid one. I've invested several hours testing Favorite Documents, Workspace Manager, and Task Canvas to get a clearer picture of how they all stack up against ContextKeeper.

Features supported ContextKeeper Task Canvas Favorite Documents Workspace Manager
Automatic session switching when changing Git branches βœ… ❌ ❌ ❌
Restores full Visual Studio's original documents state βœ… ❌ ❌ ❌
Tabs order βœ… ❌ ❌ unreliable
Tab groups (including horizontal/vertical orientation) βœ… ❌ ❌ unreliable
Document windows positions & size (including floating windows) βœ… ❌ ❌ unreliable
Breakpoints βœ… ❌ ❌ ❌
Bookmarks βœ… ❌ ❌ ❌
Last selected tab for every window βœ… ❌ ❌ unreliable
Last active tab among all opened βœ… ❌ ❌ unreliable
Visual Studio independent restore engine βœ… partially ❌ ❌
Multiple document windows βœ… ❌ ❌ unreliable
Multiple monitors support βœ… ❌ ❌ unreliable
Relative path (portable sessions between environments) βœ… limited limited ❌
Maximized/Normal state for document windows βœ… ❌ ❌ ❌
Source control ready sessions files (diffable JSON format) βœ… ❌ ❌ ❌
Continuous session auto-save for branch snapshots βœ… ❌ ❌ ❌
One-click append files βœ… ❌ βœ… ❌
Pinned files βœ… ❌ βœ… unreliable
One-click session update βœ… βœ… ❌(only adding) unreliable
One-click restore βœ… βœ… ❌ ❌
Shareable session's file between teammates βœ… βœ… ❌(one file for all sessions) ❌
Last opened files βœ… βœ… βœ… unreliable
Line & column for every file βœ… βœ… βœ… unreliable
Non-solution (external) files βœ… βœ… βœ… ❌
Not based on the (broken) IVsUIShellDocumentWindowMgr βœ… βœ… βœ… ❌
Still in an active development (updates in 2023) βœ… ❌ βœ… ❌
Price Free during Beta $49 Free Free

Task Canvas

I must say, I'm a bit surprised by how Task Canvas, the only paid competitor, performed in the comparison. It was built with a different workflow in mind, which is why it lacks in certain areas. However, it's still quite powerful and presents an interesting concept with its independent task canvas (separate, physical tab). Kudos to Sergey for trying something different. I'll take a closer look to see if there are any elements from this concept that could add additional value to ContextKeeper. What are your thoughts on this?

Favorite Documents

It appears that the most popular extension is based on the simple VS API - VsShellUtilities.OpenDocument(). Unfortunately, it lacks more sophisticated use cases. Nonetheless, it's still better than relying solely on Visual Studio's default state engine and the inherently flawed .suo file.

Workspace Manager

The spiritual successor to the (broken) approach of Save All the Tabs, utilizing the IVsUIShellDocumentWindowMgr.ReopenDocumentWindows() API. Unfortunately it is nothing more than wrapper for the default Visual Studio state engine, which which has had persistent, unresolved issues for years. It's unreliable, sometimes functioning properly but often failing. My experience with it has been similar to Save All the Tabs, which I tried using with mixed success in the past.

The fail of the Save All the Tabs extension, to deliver a stable and reliable restore mechanism, really push me to work on the a truly independent session restore engine. I distinctly recall my thought process during that time -

If it doesn't work, I'll at least give it a shot and try to build it. There's nothing wrong with failing, but if I succeed, it will be a big deal one day! I will try to make it the state-of-the-art session manager that Visual Studio has never had but always deserved.

Later, the context engine has become the heart of ContextKeeper. It was entirely written from scratch, and it is fully independent from Visual Studio session restore API. It is rock solid, and works in VS 2022, including olders versions VS 2019/2017/2015. It has taken thousands of hours and years of work to bring it to a state where it is a true pleasure and an enjoyable experience to use, and to have the session manager that Visual Studio has always deserved. πŸš€ Cause there ain't room for more than one King πŸ‘‘ in this town.

Current limitations

The Roadmap includes among others: