Skip to main content

Tailscale preview command plugin for Takopi

Project description

takopi-preview

preview command plugin for takopi. exposes existing local ports via tailscale serve, and tracks preview sessions by project/worktree context.

published as the takopi-preview package. the command id is preview.

features

  • /preview commands to start, list, stop, and clean up previews
  • per-project overrides for ports
  • session registry with ttl expiration
  • allowlist support for sensitive commands (like killall)

requirements

  • python 3.14+
  • takopi >= 0.20
  • provider tooling:
    • tailscale installed and authenticated on the host (tailscale up)
  • the service you want to share binds to 127.0.0.1 (tunnels proxy locally)
  • security groups should not expose the local service port publicly

install

install into the same environment as takopi.

uv tool install -U takopi
uv tool install -U takopi --with takopi-transport-slack --with takopi-preview

or, with a virtualenv:

pip install takopi-transport-slack takopi-preview

setup

  1. install tailscale and authenticate (tailscale up).
  2. enable magicdns so DEVICE.TAILNET.ts.net resolves.
  3. run takopi with your transport (slack or telegram) as usual.

configuration

add to ~/.takopi/takopi.toml:

[plugins]
enabled = ["takopi-transport-slack", "takopi-preview"]

[plugins.preview]
provider = "tailscale"
default_port = 3000
ttl_minutes = 120
path_prefix = "/preview"
tailscale_https_port = 443
allowed_user_ids = [123456789]
local_host = "127.0.0.1"
tailscale_bin = "tailscale"

# per-project overrides (Takopi project tables are strict, so use plugins.preview.projects)
[plugins.preview.projects.myapp]
port = 5173

notes:

  • provider = "tailscale" uses tailnet-only urls from tailscale serve.
  • preview only configures tailscale serve; start your dev server separately.
  • ttl_minutes = 0 disables expiration.
  • empty allowed_user_ids means no allowlist enforcement.

commands

  • /preview start [port]: start a preview for the current context
  • /preview list: show active previews (url, port, uptime, context)
  • /preview stop [id|port]: stop a preview (defaults to current context)
  • /preview killall: stop all previews (restricted by allowlist)
  • /preview help: usage help

workflow

  1. choose a context: /myapp @feat/login or reply in an existing thread. previews only run in worktrees, so include a branch to create/use one.
  2. start your dev server in that worktree (ex: pnpm dev -- --port 5173).
  3. run /preview start (or /preview start 5173).
  4. open the returned url, for example:
https://DEVICE.TAILNET.ts.net/preview/5173
  1. stop when done: /preview stop or /preview stop 5173.

state and ttl

  • tailscale: sessions are derived from tailscale serve status; no preview state file is written.
  • tailscale: if the requested port is already served, takopi will attempt to disable the existing serve entry before starting a new preview.
  • tailscale: set path_prefix = "/" to serve from the tailnet root. This avoids subpath issues with apps that assume /, but only one preview can be served at a time unless you also set per-preview HTTPS ports.
  • tailscale: when path_prefix = "/", the default HTTPS port is the preview port (so 5173 maps to https://host.ts.net:5173). Set tailscale_https_port = 443 to force the default HTTPS port.

ttl_minutes controls automatic expiration for previews started by this takopi process; expired sessions are cleaned up on the next command invocation. worktrees that are pruned or deleted are also cleaned up on the next command. takopi shutdown stops all previews.

errors

  • missing tailscale: follow the install docs and run tailscale up.
  • serve disabled: enable serve for your tailnet (Tailscale admin UI) if you see the "Serve is not enabled" error.
  • preview already active: if a port is already served, takopi will stop the existing serve entry before re-enabling it.
  • service not reachable: ensure your dev server is running and bound to local_host (default 127.0.0.1).
  • not in a worktree: include a branch (ex: /myapp @feat/foo) to create/use a worktree.

spec alignment

this implementation follows the webapp preview workflow spec:

  • command surface: start/list/stop/killall/help
  • config in [plugins.preview] with per-project overrides
  • tailscale serve for tailnet-only preview urls
  • tailscale serve registry
  • ttl-based expiration (ttl_minutes)
  • allowlist enforcement via allowed_user_ids

license

mit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

takopi_preview-0.1.14.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

takopi_preview-0.1.14-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file takopi_preview-0.1.14.tar.gz.

File metadata

  • Download URL: takopi_preview-0.1.14.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for takopi_preview-0.1.14.tar.gz
Algorithm Hash digest
SHA256 5e778d716104e448696ead2bb11285618f2d7b566f4473da02ded6b9e2d5b487
MD5 f72d6ae3f39232f0622792fd91ba624f
BLAKE2b-256 6a518fcc7f2e2812a96e51f8496ecd50ed56a9d0817cc20f7ee99bbf55443cd3

See more details on using hashes here.

Provenance

The following attestation bundles were made for takopi_preview-0.1.14.tar.gz:

Publisher: workflow.yml on richardliang/takopi-preview

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file takopi_preview-0.1.14-py3-none-any.whl.

File metadata

File hashes

Hashes for takopi_preview-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 d978420d571871e21d50dd647f7f344f43622b6ddccef7b9253e4954e652cfd0
MD5 ccefbf7d431e5f412522f38eda78931a
BLAKE2b-256 aa0db487a0e24ed703ad71bda8a4dbb9cd374c38a89f7567a787ec1feacffd5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for takopi_preview-0.1.14-py3-none-any.whl:

Publisher: workflow.yml on richardliang/takopi-preview

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page