Metadata-Version: 2.4
Name: jupyterlab_server_proxy_launcher_fix
Version: 1.0.3
Summary: Fix to the issue that when launchers configured in the jupyter config file with svg icons are in a different category than notebooks, icons are not displayed
Project-URL: Homepage, https://github.com/stellarshenson/jupyterlab_server_proxy_launcher_fix
Project-URL: Bug Tracker, https://github.com/stellarshenson/jupyterlab_server_proxy_launcher_fix/issues
Project-URL: Repository, https://github.com/stellarshenson/jupyterlab_server_proxy_launcher_fix.git
Author-email: Stellars Henson <konrad.jelen@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2026, Stellars Henson
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Keywords: jupyter,jupyterlab,jupyterlab-extension
Classifier: Framework :: Jupyter
Classifier: Framework :: Jupyter :: JupyterLab
Classifier: Framework :: Jupyter :: JupyterLab :: 4
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: jupyter-server-proxy>=4.0.0
Provides-Extra: dev
Requires-Dist: jupyterlab>=4; extra == 'dev'
Provides-Extra: test
Requires-Dist: coverage; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-asyncio; extra == 'test'
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: pytest-jupyter[server]>=0.6.0; extra == 'test'
Description-Content-Type: text/markdown

# jupyterlab_server_proxy_launcher_fix

[![GitHub Actions](https://github.com/stellarshenson/jupyterlab_server_proxy_launcher_fix/actions/workflows/build.yml/badge.svg)](https://github.com/stellarshenson/jupyterlab_server_proxy_launcher_fix/actions/workflows/build.yml)
[![npm version](https://img.shields.io/npm/v/jupyterlab_server_proxy_launcher_fix.svg)](https://www.npmjs.com/package/jupyterlab_server_proxy_launcher_fix)
[![PyPI version](https://img.shields.io/pypi/v/jupyterlab-server-proxy-launcher-fix.svg)](https://pypi.org/project/jupyterlab-server-proxy-launcher-fix/)
[![Total PyPI downloads](https://static.pepy.tech/badge/jupyterlab-server-proxy-launcher-fix)](https://pepy.tech/project/jupyterlab-server-proxy-launcher-fix)
[![JupyterLab 4](https://img.shields.io/badge/JupyterLab-4-orange.svg)](https://jupyterlab.readthedocs.io/en/stable/)
[![Brought To You By KOLOMOLO](https://img.shields.io/badge/Brought%20To%20You%20By-KOLOMOLO-00ffff?style=flat)](https://kolomolo.com)
[![Donate PayPal](https://img.shields.io/badge/Donate-PayPal-blue?style=flat)](https://www.paypal.com/donate/?hosted_button_id=B4KPBJDLLXTSA)

JupyterLab extension that fixes SVG icon display for [jupyter-server-proxy](https://github.com/jupyterhub/jupyter-server-proxy) launchers when placed in custom categories other than "Notebook" or "Console".

> [!WARNING]
> This extension is a temporary fix for [jupyterhub/jupyter-server-proxy](https://github.com/jupyterhub/jupyter-server-proxy). Once the upstream project implements proper icon support for custom launcher categories, this extension will be deprecated. We look forward to our own obsolescence.

## The Problem

When configuring jupyter-server-proxy launchers with custom categories (e.g., "Services", "Tools"), SVG icons fail to display. This happens because JupyterLab's launcher widget handles icons differently based on category:

- **Notebook/Console categories**: Uses `kernelIconUrl` property - works correctly
- **Other categories**: Calls `commands.icon(command, args)` to get the icon - server-proxy's `server-proxy:open` command doesn't define an `icon` property, so icons are missing

## The Fix

This extension wraps JupyterLab's `commands.icon()` method to intercept calls for the `server-proxy:open` command and return pre-cached LabIcon instances.

**How it works**:

- Fetches server-proxy configuration from `/server-proxy/servers-info` endpoint
- Pre-fetches SVG icons and creates LabIcon instances for non-kernel categories
- Wraps `app.commands.icon()` to return cached icons when command is `server-proxy:open`
- Matches icons by `args.title` (handles both plain titles and titles with ` [↗]` suffix for `new_browser_tab: true`)

**Implementation details**:

- **No command override**: Preserves server-proxy's original `execute` function completely
- **No timing issues**: Wrapper intercepts all calls regardless of extension load order
- **No private API access**: Uses public method wrapping instead of accessing internal `_commands` Map
- **Non-destructive**: Original behavior preserved for all other commands

## Fix Implementation Details

The extension consists of frontend TypeScript code that wraps the commands registry icon method.

**Frontend Implementation** (`src/index.ts`):

- **Icon Caching**: Fetches server info, creates LabIcon from `icon_url` for each non-kernel category launcher, caches by title
- **Title Matching**: Caches icons under both plain title and `${title} [↗]` suffix (server-proxy appends this when `new_browser_tab: true`)
- **Method Wrapping**: `const originalIcon = app.commands.icon.bind(app.commands)` preserves original, then `(app.commands as any).icon = ...` installs wrapper
- **Conditional Return**: If `id === 'server-proxy:open'` and `args.title` matches cache key, returns cached LabIcon; otherwise delegates to original

**Icon Utilities** (`src/iconUtils.ts`):

- **SVG Fetching**: `fetchSvgIcon(url, name)` fetches SVG content and creates LabIcon instance
- **Fallback Icons**: `createTextIcon(name, title)` generates simple SVG with first letter when icon_url unavailable

## Requirements

- JupyterLab >= 4.0.0
- [jupyter-server-proxy](https://github.com/jupyterhub/jupyter-server-proxy) installed and configured

## Install

To install the extension, execute:

```bash
pip install jupyterlab_server_proxy_launcher_fix
```

## Uninstall

To remove the extension, execute:

```bash
pip uninstall jupyterlab_server_proxy_launcher_fix
```
