Skip to content

Conversation

@ruotingx
Copy link
Contributor

Problem

In JupyterLab environments, when users start a new Q chat conversation and refresh their workspace, the active chat tab disappears and cannot be restored by clicking on it in the conversation history panel.

Solution

Allow multiple loadChats() calls in JupyterLab environment to enable conversation history access after refresh. In other IDEs, maintain existing behavior.

  • Add JUPYTER_LAB environment variable detection
  • Allow multiple loadChats() calls only in JupyterLab to restore open tabs
  • Add test for JupyterLab environment with multiple loadChats() calls

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Allow multiple loadChats() calls in JupyterLab environment.
@ruotingx ruotingx requested a review from a team as a code owner September 24, 2025 17:39
* Determines if the environment is JupyterLab.
*/
private isJupyterLabEnvironment(): boolean {
return process.env.JUPYTER_LAB === 'true'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we have a try catch block? does this env var exist by default for Jupyterlab?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This environment variable doesn't exist by default, we set it when starting the LSP server

def start_lsp_server(self, node_path, executable_path, auth_mode=None):
    env = os.environ.copy()
    env["JUPYTER_LAB"] = "true"  # We set this explicitly

Also tested this implementation on a SageMaker space where the JUPYTER_LAB environment variable is not
set, and the current functionalities still work, will not throw any errors.

Safe fallback behavior:

  • When the env variable is not set: process.env.JUPYTER_LAB is undefined → undefined === 'true' → false → maintains existing behavior for all other IDEs
  • When the env variable is set: process.env.JUPYTER_LAB is 'true' → 'true' === 'true' → true → enables JupyterLab-specific behavior

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer one so that all cases are covered and ls does not crash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer one so that all cases are covered and ls does not crash

Done

@ruotingx ruotingx force-pushed the jupyterlab-chat-reload branch from 6e043fa to 0c0779a Compare October 1, 2025 22:28
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 80.95238% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.90%. Comparing base (9f745a3) to head (ec124fe).

Files with missing lines Patch % Lines
...rc/language-server/agenticChat/tabBarController.ts 80.95% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2325   +/-   ##
=======================================
  Coverage   60.89%   60.90%           
=======================================
  Files         260      260           
  Lines       58313    58332   +19     
  Branches     3547     3550    +3     
=======================================
+ Hits        35512    35527   +15     
- Misses      22734    22738    +4     
  Partials       67       67           
Flag Coverage Δ
unittests 60.90% <80.95%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Will-ShaoHua Will-ShaoHua merged commit 0980351 into aws:main Oct 3, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants