Skip to content

[Feat]: As a VS Code user, I want the extension's core operations in the Command Palette so that I can create and export diagrams without digging through menus #39

Description

@emaarco

Summary

As a VS Code user of the Team Topologies Modeler, I want the extension's core operations —
creating a diagram and exporting the current diagram — available as first-class Command
Palette commands under one shared "Team Topologies" category, so that I can reach them from
Cmd/Ctrl+Shift+P without knowing about the in-canvas menu.

Motivation

The Command Palette is the primary discovery surface in VS Code. Today only the create operations
are palette commands; the export operations live solely inside the webview's collapsed
(Excalidraw-style) menu
, so a new user who wants an SVG/PNG has no way to discover them from the
palette, and they can't be bound to a keyboard shortcut. Consolidating the core operations under the
existing Team Topologies category makes the extension self-describing and keyboard-friendly.

What exists today — declared in apps/vscode/package.jsoncontributes.commands, each with
category: "Team Topologies". There is no contributes.menus.commandPalette restriction, so all
three are already reachable from the palette:

Command id Title In palette? In file/newFile?
teamTopologies.newDiagram New Empty Diagram
teamTopologies.newFromExample New Diagram from Example
teamTopologies.newPngDiagram New Empty Diagram (embedded PNG)

What's missing — core operations that are NOT exposed as commands:

Operation Today Proposed command id
Export current diagram as SVG webview menu only teamTopologies.exportSvg
Export current diagram as PNG webview menu only teamTopologies.exportPng
(secondary) New Diagram from Example in File ▸ New File… palette only add to file/newFile menu

Proposed Solution

  1. Add two new commands under the shared Team Topologies category:

    • teamTopologies.exportSvg"Export as SVG"
    • teamTopologies.exportPng"Export as PNG"
  2. Reuse existing logic, don't duplicate. The write-to-disk half already exists in
    apps/vscode/src/exportImage.ts (exportImageToFile), and the webview already emits an export
    protocol message with the rendered data (apps/vscode/src/protocol.ts, handled in
    TtEditorProvider.ts:66 and TtPngEditorProvider.ts:160). The new commands should:

    • resolve the active Team Topologies editor,
    • send a new host → webview "request export" message so the webview produces the SVG text /
      base64 PNG (the same data it already produces for the in-canvas menu),
    • pipe that into the existing exportImageToFile().

    No new export/render code — just a command entry point into the path that already runs.

  3. Gate the export commands so they only appear when a diagram editor is focused, via
    contributes.menus.commandPalette with a when clause (e.g.
    activeCustomEditorId == 'teamTopologies.editor' || activeCustomEditorId == 'teamTopologies.pngEditor'),
    so the palette isn't cluttered when no diagram is open.

  4. (Secondary) Add teamTopologies.newFromExample to the file/newFile menu for parity with the
    other two create commands.

  5. Keep category: "Team Topologies" on every command so they group together in the palette.

Acceptance Criteria

  • Team Topologies: Export as SVG and Team Topologies: Export as PNG appear in the Command
    Palette when a .tt / .ttm.json / *.tt.png editor is focused, and are hidden otherwise.
  • Running either command produces the same file (with the embedded scene) as the existing
    in-canvas export menu, via exportImageToFile — no duplicated export/render logic.
  • All create + export commands share the Team Topologies category in the palette.
  • New Diagram from Example is reachable from File ▸ New File… alongside the other create
    commands.
  • npm run lint, npm test, and npm run typecheck stay green.

Alternatives Considered

  • Leave export in the canvas menu only. Rejected: not discoverable from the palette and can't be
    keybound.
  • A single Export… command with a Quick Pick for SVG/PNG. Viable and arguably cleaner; noted as
    an option, but two explicit commands are more directly discoverable and individually keybindable.
  • Duplicate the export logic in a command handler. Rejected: violates reuse — exportImageToFile
    plus the existing export protocol message should stay the single source of truth.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions