sun rising on one half split with sun set over the sea

Building in Public: The ‘Back to It’ VS Code Extension – Part 1

As a developer, I’ve often found myself staring at my code, trying to remember where I left off after a lunch break, a weekend, or even just a quick chat with a colleague. This frustrating experience of context loss is not just annoying—it’s a significant drain on productivity. That’s why I decided to create “Back to It,” a VS Code extension designed to help developers quickly recover their mental context and get back into the flow of coding. In this post, I’ll share my journey of building this tool in public, discussing the problem, my approach, and some unique features I’m working on.

The Problem: The Hidden Cost of Context Switching

Context switching is a silent productivity killer in software development. Research paints a stark picture of its impact:

  • It takes an average of 23 minutes and 15 seconds to fully return to a task after an interruption (Gloria Mark et al.).
  • Developers can lose up to 30 minutes trying to resume an interrupted task (Parnin and Rugaber).
  • The average developer is interrupted or switches tasks every 3-10 minutes.
  • Context switching costs the global economy an estimated $450 billion annually (Atlassian).

These numbers highlight a significant problem: every time we’re pulled away from our code, we’re not just losing the time of the interruption, but also the time it takes to mentally “reboot” and get back into the flow.

The Solution: ‘Back to It’ VS Code Extension

The core idea behind ‘Back to It’ is to capture the developer’s coding context and provide an AI-powered summary to help quickly reactivate their mental state when returning to work. Here’s an overview of the key features I’m building:

  1. Activity Tracking: Automatically capturing coding activities, file changes, and time spent on different tasks.
  2. Diff Capturing: Regularly saving detailed diffs of code changes to understand the nature of the work being done.
  3. AI-Powered Summaries: Using GPT-4 to generate intelligent, context-aware summaries of recent coding activities.
  4. Personalized Suggestions: Offering actionable, AI-generated suggestions for next steps based on recent work.

The Development Process

Getting started with VS Code extension development was an interesting journey. Here are some of the steps I went through:

  1. Setting Up the Development Environment: I installed Node.js and the VS Code Extension Manager (vsce).
  2. Initializing the Project: Used the yo code generator to create the initial extension structure.
  3. Implementing Core Functionality: Started with basic activity tracking and file change monitoring.
  4. Integrating AI: Added GPT-4 integration for generating summaries and suggestions.
  5. Handling Security: Implemented secure storage for the OpenAI API key.

New Things For Me To Play With / Fun Creative Problems

As I’ve been developing ‘Back to It,’ I’ve come up with some unique approaches to solve the core issue:

  1. Sliding Window of Context: Instead of just tracking the last session, I’m implementing a “sliding window” of context that captures a more comprehensive view of recent work.
  2. Diff-Based Analysis: By capturing and analyzing code diffs over time, the extension can provide more nuanced insights into the nature of the work being done.
  3. AI-Powered Context Reconstruction: Using GPT-4 to not just summarize activities, but to actually reconstruct the likely mental context of the developer based on their recent code changes.
  4. Personalized Interaction: The AI-generated summaries speak directly to the developer, creating a more engaging and motivating experience.
  5. Minimal Intrusion: Designing the extension to gather information passively, ensuring it doesn’t interrupt the developer’s flow while still providing valuable insights.

Beyond the Basics: Tackling Complex Data Tracking

While the initial setup of a VS Code extension is fairly straightforward and well-documented in the official “Getting Started” guide, the real challenges emerge when designing and implementing the core functionality of ‘Back to It’. The complexity lies in determining what data to track and how to track it efficiently without reinventing existing tools or overly taxing system resources.

Tracking Time Spent on Each Tab

One of the key metrics I want to capture is the time spent on each file or tab. This seems simple on the surface, but it quickly becomes complex when you consider:

  • How do we handle rapid tab switching?
  • Should we count time when VS Code is in the background?
  • How do we account for idle time when the developer steps away?

I’m currently implementing a system that uses VS Code’s onDidChangeActiveTextEditor event in combination with a custom timer. The timer is reset when the tab changes or when significant idle time is detected. This approach gives us a more accurate representation of active coding time per file.

Capturing Code Changes Without Reinventing Git

Another crucial aspect is tracking code changes over time. While Git already does an excellent job of version control, our needs are slightly different. We want to capture more frequent, granular changes to provide detailed context, but we don’t want to create a full version control system.

Here’s how I’m approaching this challenge:

  1. Frequent Diff Capturing: I’m using the diff library to create patches of changes at regular intervals (currently set to every hour) and when significant changes occur.
  2. Efficient Storage: Instead of storing full file contents, I’m only storing the diffs. This significantly reduces storage requirements while still providing detailed change information.
  3. Rolling Window: I’m implementing a rolling window approach, keeping only the last 24 hours of diffs. This provides recent context without accumulating excessive historical data.
  4. Balancing Frequency and Performance: Determining how often to capture diffs is a delicate balance. Too frequent, and we risk impacting performance. Too infrequent, and we might miss important context. I’m currently experimenting with different intervals and triggers to find the optimal balance.

Challenges and Considerations

As I delve deeper into these implementations, I’m grappling with several questions:

  1. Privacy and Security: How do we ensure that sensitive code snippets aren’t inadvertently stored or transmitted?
  2. Performance Impact: How can we minimize the extension’s impact on VS Code’s performance, especially for large projects?
  3. Data Analysis: Once we have all this data, what’s the most effective way to analyze it to provide meaningful insights?
  4. Integration with Existing Workflows: How can we ensure that ‘Back to It’ complements rather than conflicts with existing development tools and practices?

Next Steps

As I continue to build ‘Back to It,’ I’m focusing on refining the AI-generated summaries, improving the accuracy of context reconstruction, and designing a user interface that seamlessly integrates with the VS Code workflow.

In the next part of this series, I’ll dive deeper into the technical challenges of implementing diff capturing and how I’m using this data to provide more accurate context summaries.

Stay tuned for more updates as I continue to build in public. Your feedback and suggestions are always welcome as we work together to solve the challenge of context switching in software development!


Have you experienced significant productivity loss due to context switching? What strategies do you use to mitigate this? Share your thoughts and experiences in the comments below!

A Different Kind of Developer Newsletter

We don’t spam! That’s yuck.

  • Building in Public: The ‘Back to It’ VS Code Extension – Part 1

    As a developer, I’ve often found myself staring at my code, trying to remember where I left off after a lunch break, a weekend, or even just a quick chat with a colleague. This frustrating experience of context loss is not just annoying—it’s a significant drain on productivity. That’s why I decided to create “Back…

  • Time, the Silent Exploit: The Unseen Enemy in Every Codebase

    You’ve got a bunch of gold sitting around because it’s holding its value great against inflation or because you are a dragon or something. The first thing you will want to do is protect your valuable gold. The most obvious thing is to start off with a wall. You do your research and build a…

  • The Mindful Coder’s Workweek: 5 Themes to Enhance Your Craft and Satisfaction

    TL;DR TL;DR for the TL;DR crowd: Screenshot this chart, print it out, follow it. Congrats, you’ve unlocked the cheat code to mindful coding. Now shoo – go be brilliant – or any other words that make you feel good. Day Theme Light Version In-Depth Version Mindful Fact Minimalist Monday Refactor one function to be more…

  • From Dirty Dishes to Clean Code: How Household Chores Mirror Programming Team Dynamics

    Ever felt like you’re the only one pulling your weight in a coding project? You might be experiencing the same psychological phenomenon that happens with household chores. Let’s dive into this unexpected parallel and see what we can learn about team dynamics, whether you’re wielding a mop or a keyboard. The “I Do More” Illusion:…

  • You’re Closer Than You Think: The Only 6 DNS Concepts You Really Need

    Feeling like DNS is this big, scary monster you’ll never fully understand? Here’s some good news: you’re probably a lot closer to mastering it than you realize. In fact, there are really only six core concepts you need to have down pat. The rest? You can offload that from your mental RAM. Let’s walk through…

  • The Wasabi Method: Shocking Your Way Out of Anxiety Attacks

    Ever felt like your anxiety is a runaway train, and you’re desperately searching for the emergency brake? You’re not alone. As someone who’s battled crippling anxiety from my late teens through university, I’ve been there. But what if I told you that the key to derailing that anxiety express might be as simple as a…

Join 39 subscribers

Hi!

I’m Jonah and I have thoughts that I share – sometimes. Join my mailing list to hear about new posts when I get around to it.

yes, I update this number manually

Sign up to receive awesome content in your inbox, every week, month when I get around to it.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *