Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

Add psl-playground: browser PSL editor wired to the language server - #856

Merged
SevInf merged 7 commits into
mainfrom
lsp-playground
Jun 19, 2026
Merged

SevInf merged 7 commits into
mainfrom
lsp-playground

Conversation

@SevInf

@SevInf SevInf commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue

n/a — small, self-contained dev tool. Builds on the language server from #852 (prisma-next lsp).

Summary

A private apps/lsp-playground package providing the psl-playground binary: it opens a PSL file in a browser CodeMirror 6 editor wired to prisma-next lsp over a single-port WebSocket bridge, giving you live PSL parse diagnostics without setting up an editor extension.

At a glance

# Open a blank scratch schema (no file, no config needed):
psl-playground

# Or open an existing PSL file:
psl-playground path/to/schema.psl

Then open http://localhost:5273/ and edit; diagnostics from @prisma-next/psl-parser update live. With no project config, the playground assumes a default-postgres setup.

CodeMirror 6 --LSP/WebSocket--> shared http server (port 5273) --spawn+stdio--> prisma-next lsp --stdio
(codemirror-languageserver)     (Vite middleware + vscode-ws-jsonrpc)           (@prisma-next/language-server)

Decision

This ships one thing: a browser playground for the PSL language server, as a private apps/ package so it stays out of the framework build graph and lint:deps layering. Three design decisions shape it:

  1. CodeMirror 6 + codemirror-languageserver for the editor (lighter than Monaco; grows into hover/completion as the server gains them).
  2. One port for everything. Vite runs in middleware mode on a single http.Server; the LSP WebSocket bridge attaches an upgrade listener that only claims /psl, so the editor, Vite HMR, and the language server all share port 5273.
  3. PSL file optional; config optional. With no argument the playground stages a scratch schema and generates a default-postgres config; an existing file already inside a project opens in place under its own config.

How it fits together

  1. Resolve what to open. src/cli.ts resolves the schema and the config above it: an explicit --config + file opens in place; an existing file inside a project opens in place under its discovered config; otherwise (no file / missing path / file with no project config) the schema is staged into .playground/ and a default-postgres config is generated beside it.
  2. Stage for resolvability. Staging into .playground/ (src/default-config.ts, stageSchema in src/cli.ts) is required because the language server discovers a document's config by walking up from the document's own path, and the generated config's @prisma-next/* imports must resolve through the workspace node_modules.
  3. Bridge stdio over WebSocket. src/bridge.ts attaches to the shared server, and on each /psl connection spawns prisma-next lsp --stdio and forwards JSON-RPC via vscode-ws-jsonrpc (createServerProcess + forward).
  4. Serve the editor. Vite serves the page; a generated src/client/runtime.ts hands the client the document URI, root, schema text, and WS path; src/client/main.ts mounts CodeMirror with the languageServer extension pointed at the same origin.

Behavior changes & evidence

  • psl-playground with no argument opens a scratch schema under default-postgres and publishes live diagnostics — apps/lsp-playground/src/cli.ts, apps/lsp-playground/src/default-config.ts. Validated manually end-to-end (no-arg launch → PSL_UNTERMINATED_BLOCK).
  • psl-playground <file> opens an existing schema; if it has no project config it is staged as a sandbox copy under default-postgres, otherwise opened in place — apps/lsp-playground/src/cli.ts. Validated manually (staged-copy launch → diagnostics).
  • Editor and LSP share a single port via Vite middleware mode + an /psl-scoped upgrade handler — apps/lsp-playground/src/cli.ts, apps/lsp-playground/src/bridge.ts.

Reviewer notes

  • Largest file is src/cli.ts — the arg parsing + schema/config resolution + single-port wiring live there. The branching in schema/config resolution is the part to spot-check.
  • Staging edits a copy, not your file. For files outside a project, the playground deliberately opens a copy under .playground/ rather than your original — both because the server needs the config's @prisma-next/* imports to resolve and because walk-up config discovery requires the schema to sit beside the generated config. This is intentional sandbox behaviour.
  • Generated artefacts are gitignored. .playground/ and src/client/runtime.ts are written at launch and excluded from git; only sources are tracked.
  • Build prerequisite. The bridge spawns the built CLI (@prisma-next/cli's dist/cli.js) and the generated config loads built postgres-stack packages, so a fresh checkout needs pnpm install + a build of those packages before first run. Noted in the README.
  • No automated tests. This is a dev tool validated by manual end-to-end runs (documented in Verification); it ships no unit tests.

Compatibility / migration / risk

No framework surface changes. apps/ is exempt from lint:deps; the package is private and unpublished. Zero risk to shipped code.

Testing performed

  • pnpm --filter @prisma-next/lsp-playground typecheck — clean
  • pnpm --filter @prisma-next/lsp-playground lint — clean (exit 0)
  • Manual end-to-end against rebased origin/main: no-arg launch and existing-file launch both serve the editor on port 5273 and publish PSL_UNTERMINATED_BLOCK for a broken schema over the shared-port WebSocket bridge.

Skill update

n/a — internal dev tool; no user-facing CLI/API/config surface of the framework changes (the psl-playground binary lives only in this private package).

Alternatives considered

  • Monaco + monaco-languageclient — heavier (pulls the vscode-api shims); CodeMirror 6 is lighter and sufficient for diagnostics, and grows into later language features.
  • Two ports (separate Vite + bridge servers) — the original shape; collapsed to one shared http.Server to avoid hogging two ports.
  • A Zed/VS Code dev extension — more setup and editor-specific; a browser playground is editor-agnostic and instantly shareable.
  • lsp-ws-proxy (Rust) or the 8-year-old jsonrpc-ws-proxy — vscode-ws-jsonrpc is maintained, all-JS, and pnpm-installable.

Checklist

  • All commits are signed off (git commit -s) per the DCO.
  • I read CONTRIBUTING.md and the change is scoped to one logical concern.
  • Tests are updated (n/a — dev tool validated by manual end-to-end runs; no behavioural delta to framework code).
  • The PR title is in TML-NNNN: <sentence-case title> form (n/a — no Linear ticket; self-contained dev tool).
  • The Skill update section above is filled in.

Summary by CodeRabbit

Release Notes

New Features

  • Added an LSP playground web application for live PSL schema editing and diagnostics.
  • Supports opening an existing schema or using a scratch schema.
  • Provides real-time LSP updates in the browser via a WebSocket-to-LSP bridge.
  • Automatically locates the nearest project configuration or generates a default PostgreSQL configuration when needed.

Documentation

  • Updated the playground README with local usage and workflow details.

Chores

  • Updated ignore rules to exclude generated/staged playground output.

Tests

  • Added a sample “broken” PSL fixture for validation scenarios.

SevInf added 3 commits June 19, 2026 13:45
…rver

Add a private apps/lsp-playground package providing the `psl-playground`
binary. It opens a .psl file in a browser CodeMirror 6 editor wired to
`prisma-next lsp --stdio` over a WebSocket bridge (vscode-ws-jsonrpc),
publishing live PSL parse diagnostics.

Config resolution: --config, else the nearest prisma-next.config.ts walking
up from the schema, else a generated default-postgres config pointing
prismaContract at the schema. Without any config, a default Postgres setup
is assumed.

Lives under apps/ (exempt from lint:deps layering); runs via tsx, no build
step. Validated end-to-end: a broken schema yields PSL_UNTERMINATED_BLOCK
through the full WS -> bridge -> stdio server -> publishDiagnostics chain.

Signed-off-by: Serhii Tatarintsev <[email protected]>
Replace the separate Vite (5273) and bridge (30100) HTTP servers with one
shared http.Server: Vite runs in middleware mode with its HMR socket bound to
that server, and the bridge attaches an upgrade listener that only claims the
/psl path. The client derives its WebSocket URL from window.location, so the
editor and the language server share one origin/port (5273).

attachBridge now takes an existing server instead of owning a port; the
generated client runtime exports wsPath instead of a hard-coded wsUrl.

Validated end-to-end on the single port: GET / -> 200 and
ws://localhost:5273/psl yields PSL_UNTERMINATED_BLOCK for a broken schema.

Signed-off-by: Serhii Tatarintsev <[email protected]>
…server

The binary now runs with no schema argument: it stages a writable scratch
schema under .playground/ and assumes a generated default-postgres config,
matching the intended "without the config, assume default postgres" behaviour.
A non-existent path is treated the same way; an existing file with no project
config is staged as a sandbox copy under default-postgres.

Adapt to the merged prisma-next lsp (PR #852), which dropped --config and now
discovers each document config by walking up from the document path. The bridge
no longer passes --config; instead the schema is staged into .playground/
beside its generated config so the walk-up finds it and the config @prisma-next
imports resolve. An existing file already inside a project opens in place under
its own discovered config.

Validated against rebased origin/main: no-arg and existing-file launches both
serve the editor on port 5273 and publish PSL_UNTERMINATED_BLOCK live.

Signed-off-by: Serhii Tatarintsev <[email protected]>
@SevInf
SevInf requested a review from a team as a code owner June 19, 2026 13:56
@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: dbe487e8-9d20-4b0c-ba11-d0045a99c229

📥 Commits

Reviewing files that changed from the base of the PR and between c71e883 and 1638313.

📒 Files selected for processing (1)
  • apps/lsp-playground/src/cli.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/lsp-playground/src/cli.ts

📝 Walkthrough

Walkthrough

Adds a new apps/lsp-playground package from scratch. It provides a dev-only PSL schema editor backed by CodeMirror 6 with live LSP diagnostics. A single Node HTTP server co-hosts a Vite dev server (browser client) and a WebSocket-to-JSON-RPC bridge that spawns the prisma-next CLI language server via stdio.

Changes

LSP Playground App

Layer / File(s) Summary
Project scaffold and static assets
apps/lsp-playground/package.json, apps/lsp-playground/tsconfig.json, apps/lsp-playground/.gitignore, apps/lsp-playground/bin/psl-playground.mjs, apps/lsp-playground/index.html, apps/lsp-playground/fixtures/broken.psl, apps/lsp-playground/README.md
Defines package metadata, TypeScript config, binary launcher, HTML shell, a fixture schema, gitignore patterns (.playground/, dist/), and the README covering usage, config-resolution rules, and architecture.
Config resolution utilities
apps/lsp-playground/src/find-config.ts, apps/lsp-playground/src/default-config.ts
findNearestConfig walks parent directories from a schema path looking for prisma-next.config.ts; generateDefaultPostgresConfig creates a default Postgres config in .playground/ when none is found. Both are consumed by the CLI.
WebSocket-to-LSP JSON-RPC bridge
apps/lsp-playground/src/bridge.ts
attachBridge registers an HTTP upgrade handler, wraps accepted WebSocket connections into VS Code JSON-RPC reader/writer streams, spawns node <cliEntry> lsp --stdio, and forwards messages bidirectionally. Returns a disposer that removes the upgrade listener and closes the WS server.
CLI server orchestration
apps/lsp-playground/src/cli.ts, apps/lsp-playground/src/client/runtime.ts
Parses arguments, resolves or stages the schema and config (using findNearestConfig / generateDefaultPostgresConfig), validates the built CLI entry, writes src/client/runtime.ts with embedded URIs and schema text, then starts a single HTTP server hosting both Vite middleware and the LSP bridge at /psl with SIGINT/SIGTERM shutdown.
Browser CodeMirror + LSP client
apps/lsp-playground/src/client/main.ts
Populates the #schema-path element, derives a WebSocket URL from page protocol, instantiates the languageServer extension with rootUri/documentUri/'prisma' languageId, and mounts a CodeMirror EditorView with line numbers, active-line highlighting, lint gutter, history, keymaps, and the LSP extension.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as psl-playground (cli.ts)
    participant Config as Config Resolvers
    participant HTTP as HTTP Server
    participant Vite as Vite Dev Server
    participant Browser
    participant Bridge as WS-LSP Bridge
    participant LSP as prisma-next lsp --stdio

    User->>CLI: psl-playground [schema.psl]
    CLI->>Config: findNearestConfig(schemaPath)
    alt no config found
        Config->>Config: generateDefaultPostgresConfig → .playground/
    end
    CLI->>CLI: write src/client/runtime.ts (URIs + schema text)
    CLI->>Vite: createServer (middleware mode, bound to HTTP)
    CLI->>Bridge: attachBridge(HTTP, { path: "/psl" })
    CLI->>HTTP: listen :5273

    Browser->>HTTP: GET /
    HTTP->>Vite: middleware handles request
    Vite-->>Browser: index.html + client/main.ts bundle

    Browser->>Bridge: WebSocket upgrade /psl
    Bridge->>LSP: spawn node cli.js lsp --stdio
    Browser->>Bridge: LSP initialize (JSON-RPC over WS)
    Bridge->>LSP: forward via stdin
    LSP-->>Bridge: LSP response via stdout
    Bridge-->>Browser: forward JSON-RPC response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • prisma/prisma-next#852: The main PR's apps/lsp-playground bridge/CLI spawns and wires the prisma-next lsp --stdio language-server subcommand (and expects its config-driven PSL diagnostics), which directly matches the retrieved PR that adds the prisma-next lsp subcommand and its @prisma-next/language-server implementation.

Suggested reviewers

  • wmadden

Poem

🐇 A playground appears, fresh out of the warren,
Where schemas get linted and errors stop boring!
CodeMirror listens, WebSocket relays,
The LSP whispers diagnostics always.
With a hop and a click, the editor gleams —
Live PSL feedback: fancier than it seems! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely captures the main addition: a browser-based PSL editor (psl-playground) integrated with the language server via WebSocket bridge.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lsp-playground

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 154.55 KB (0%)
postgres / emit 142.13 KB (0%)
mongo / no-emit 78 KB (0%)
mongo / emit 72.09 KB (0%)
cf-worker / no-emit 181.82 KB (0%)
cf-worker / emit 167.78 KB (0%)

@pkg-pr-new

pkg-pr-new Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-author-tools@856

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-runtime@856

@prisma-next/family-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/family-mongo@856

@prisma-next/sql-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-runtime@856

@prisma-next/family-sql

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/family-sql@856

@prisma-next/extension-arktype-json

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-arktype-json@856

@prisma-next/middleware-cache

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/middleware-cache@856

@prisma-next/mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo@856

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-paradedb@856

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-pgvector@856

@prisma-next/extension-postgis

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-postgis@856

@prisma-next/postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/postgres@856

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-orm-client@856

@prisma-next/sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sqlite@856

@prisma-next/extension-supabase

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-supabase@856

@prisma-next/target-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-mongo@856

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-mongo@856

@prisma-next/driver-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-mongo@856

@prisma-next/contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract@856

@prisma-next/utils

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/utils@856

@prisma-next/config

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/config@856

@prisma-next/errors

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/errors@856

@prisma-next/framework-components

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/framework-components@856

@prisma-next/operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/operations@856

@prisma-next/ts-render

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/ts-render@856

@prisma-next/contract-authoring

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract-authoring@856

@prisma-next/ids

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/ids@856

@prisma-next/psl-parser

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-parser@856

@prisma-next/psl-printer

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-printer@856

@prisma-next/cli

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/cli@856

@prisma-next/cli-telemetry

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/cli-telemetry@856

@prisma-next/config-loader

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/config-loader@856

@prisma-next/emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/emitter@856

@prisma-next/language-server

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/language-server@856

@prisma-next/migration-tools

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/migration-tools@856

prisma-next

npm i https://pkg.pr.new/prisma/prisma-next@856

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/vite-plugin-contract-emit@856

@prisma-next/mongo-codec

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-codec@856

@prisma-next/mongo-contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract@856

@prisma-next/mongo-value

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-value@856

@prisma-next/mongo-contract-psl

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract-psl@856

@prisma-next/mongo-contract-ts

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract-ts@856

@prisma-next/mongo-emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-emitter@856

@prisma-next/mongo-schema-ir

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-schema-ir@856

@prisma-next/mongo-query-ast

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-query-ast@856

@prisma-next/mongo-orm

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-orm@856

@prisma-next/mongo-query-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-query-builder@856

@prisma-next/mongo-lowering

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-lowering@856

@prisma-next/mongo-wire

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-wire@856

@prisma-next/sql-contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract@856

@prisma-next/sql-errors

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-errors@856

@prisma-next/sql-operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-operations@856

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-schema-ir@856

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-psl@856

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-ts@856

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-emitter@856

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-lane-query-builder@856

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-relational-core@856

@prisma-next/sql-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-builder@856

@prisma-next/target-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-postgres@856

@prisma-next/target-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-sqlite@856

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-postgres@856

@prisma-next/adapter-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-sqlite@856

@prisma-next/driver-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-postgres@856

@prisma-next/driver-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-sqlite@856

commit: 1638313

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (3)
apps/lsp-playground/src/cli.ts (1)

3-3: ⚡ Quick win

Use pathe instead of node:path for repo consistency.

This file currently imports path helpers from node:path; repo convention in TS tooling files prefers pathe.

Small consistency refactor
-import { basename, dirname, isAbsolute, resolve } from 'node:path';
+import { basename, dirname, isAbsolute, resolve } from 'pathe';

Based on learnings: in this repo, TypeScript files should prefer pathe over Node’s built-in node:path for path operations.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/lsp-playground/src/cli.ts` at line 3, Replace the import statement that
imports basename, dirname, isAbsolute, and resolve from node:path with an
equivalent import from the pathe package instead. Update the import line at the
top of cli.ts to maintain the same destructured exports but source them from
pathe rather than node:path, ensuring consistency with the repository's
TypeScript tooling conventions.

Source: Learnings

apps/lsp-playground/src/default-config.ts (1)

2-2: ⚡ Quick win

Use pathe here as well for path operations.

Line 2 should align with the repo convention and import from pathe instead of node:path.

Based on learnings: “In the Prisma-next repository, prefer importing and using pathe over the built-in node:path module for path operations across the codebase.”

Suggested fix
-import { dirname, join } from 'node:path';
+import { dirname, join } from 'pathe';
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/lsp-playground/src/default-config.ts` at line 2, The import statement on
line 2 is using the built-in node:path module instead of following the
repository convention. Replace the import source from 'node:path' to 'pathe'
while keeping the imported functions (dirname and join) the same. This aligns
with the established pattern of using pathe for path operations throughout the
codebase.

Source: Learnings

apps/lsp-playground/src/find-config.ts (1)

2-2: ⚡ Quick win

Use pathe instead of node:path for repo consistency.

Please switch the Line 2 import to pathe to match the repository’s TS path-handling convention.

Based on learnings: “In the Prisma-next repository, prefer importing and using pathe over the built-in node:path module for path operations across the codebase.”

Suggested fix
-import { dirname, join, parse } from 'node:path';
+import { dirname, join, parse } from 'pathe';
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/lsp-playground/src/find-config.ts` at line 2, Replace the import source
in the find-config.ts file from 'node:path' to 'pathe' on the line that imports
dirname, join, and parse. This ensures consistency with the repository's
established convention of using the pathe module for path operations instead of
the built-in node:path module. Keep the same destructured imports (dirname,
join, parse) unchanged.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/lsp-playground/README.md`:
- Around line 50-53: The fenced code block containing the CodeMirror 6
architecture diagram is missing a language tag, which triggers the MD040 linting
rule. Add a language identifier to the opening fence of this code block by
changing the opening three backticks to include a language specifier (e.g.,
```text) instead of leaving it blank, to ensure the documentation passes lint
checks.

In `@apps/lsp-playground/src/bridge.ts`:
- Around line 46-50: The send method's webSocket.send callback throws errors
directly, which can cause uncaught exceptions and crash the process. Instead of
throwing the error in the callback when error is not null and not undefined,
handle it gracefully by closing or disposing of the WebSocket connection.
Replace the throw statement with appropriate error handling logic that
terminates the connection safely.
- Around line 77-79: When serverConnection is undefined (indicating
createServerProcess failed), the code currently returns silently, leaving the
WebSocket connection open with no backend and no feedback to the client. Instead
of the silent return, close the WebSocket connection (via the ws object) and log
a clear error message about the subprocess creation failure to provide explicit
feedback before returning. This prevents hanging clients and surfaces the actual
failure to aid debugging.

In `@apps/lsp-playground/src/cli.ts`:
- Around line 56-57: The `--config` argument parsing in the cli.ts file lacks
proper validation and enforcement. Add validation checks to ensure that when the
--config flag is present, it has an actual value provided after it (not
undefined or missing), and that the specified config path exists on the
filesystem. Additionally, ensure this explicit config is actually passed through
to the LSP process initialization instead of only affecting local configPath and
rootUri, or alternatively, add clear error handling that fails fast if the
config requirements cannot be met. Review the explicit config usage across all
referenced locations (lines around 87-98 and 167) to ensure consistency.

In `@apps/lsp-playground/src/client/main.ts`:
- Around line 14-16: The wsUrl variable assignment uses a bare `as` cast to
assert the type as the WebSocket URL union type (ws://${string} |
wss://${string}), which violates the production code typing guidelines. Replace
this bare `as` cast with the repo-approved cast helper function, either
`blindCast<T, "Reason">` or `castAs<T>`, ensuring you provide the appropriate
reason or context for the cast where required by the helper.

In `@apps/lsp-playground/tsconfig.json`:
- Around line 1-11: The outDir in the compilerOptions of tsconfig.json is set to
"dist" but should be changed to "dist-tsc" to align with the monorepo convention
established in the base tsconfig. Additionally, update the .gitignore file to
exclude "dist-tsc" instead of "dist", and update the clean script in
package.json to remove the "dist-tsc" directory instead of "dist" to maintain
consistency with the monorepo standard for output directories across all
packages.

---

Nitpick comments:
In `@apps/lsp-playground/src/cli.ts`:
- Line 3: Replace the import statement that imports basename, dirname,
isAbsolute, and resolve from node:path with an equivalent import from the pathe
package instead. Update the import line at the top of cli.ts to maintain the
same destructured exports but source them from pathe rather than node:path,
ensuring consistency with the repository's TypeScript tooling conventions.

In `@apps/lsp-playground/src/default-config.ts`:
- Line 2: The import statement on line 2 is using the built-in node:path module
instead of following the repository convention. Replace the import source from
'node:path' to 'pathe' while keeping the imported functions (dirname and join)
the same. This aligns with the established pattern of using pathe for path
operations throughout the codebase.

In `@apps/lsp-playground/src/find-config.ts`:
- Line 2: Replace the import source in the find-config.ts file from 'node:path'
to 'pathe' on the line that imports dirname, join, and parse. This ensures
consistency with the repository's established convention of using the pathe
module for path operations instead of the built-in node:path module. Keep the
same destructured imports (dirname, join, parse) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 590afa88-13d4-4712-ac94-58daf58b0b19

📥 Commits

Reviewing files that changed from the base of the PR and between a049b56 and 724f8b5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • apps/lsp-playground/.gitignore
  • apps/lsp-playground/README.md
  • apps/lsp-playground/bin/psl-playground.mjs
  • apps/lsp-playground/fixtures/broken.psl
  • apps/lsp-playground/index.html
  • apps/lsp-playground/package.json
  • apps/lsp-playground/src/bridge.ts
  • apps/lsp-playground/src/cli.ts
  • apps/lsp-playground/src/client/main.ts
  • apps/lsp-playground/src/default-config.ts
  • apps/lsp-playground/src/find-config.ts
  • apps/lsp-playground/tsconfig.json

Comment thread apps/lsp-playground/README.md Resolved
Comment thread apps/lsp-playground/src/bridge.ts Resolved
Comment thread apps/lsp-playground/src/bridge.ts Resolved
Comment thread apps/lsp-playground/src/cli.ts Resolved
Comment thread apps/lsp-playground/src/client/main.ts Resolved
Comment thread apps/lsp-playground/tsconfig.json Resolved
SevInf added 2 commits June 19, 2026 14:20
Three CI failures on the PR, fixed:

- Type Check: the generated client runtime module was gitignored, so a fresh
  checkout could not resolve `./runtime` and tsc failed. Commit a neutral
  placeholder runtime.ts (still overwritten at launch) and stop ignoring it.

- Lint cast ratchet: the no-bare-cast plugin flagged three sites. Two were
  false positives on `import { createServer as X }` aliases — rewritten as
  namespace imports (`import * as nodeHttp` / `import * as vite`). The third
  was a real `as` on the WebSocket URL; rebuilt so each protocol branch is
  already the correct template-literal type, eliminating the cast.

- Semgrep detect-insecure-websocket: false positive for a localhost-only dev
  playground served over http (wss/TLS is meaningless on loopback; we already
  upgrade to wss when served over https). Suppressed with a justified
  nosemgrep comment.

Re-validated end-to-end: launches, serves on port 5273, publishes
PSL_UNTERMINATED_BLOCK; typecheck clean, lint exit 0, cast ratchet delta=0.

Signed-off-by: Serhii Tatarintsev <[email protected]>
The detect-insecure-websocket rule fires on every `ws://` token, including
ones in comments and the type annotation, so the earlier single suppression
left three findings. Keep the suppression local instead of excluding the rule
repo-wide: remove `ws://` from comments and annotate the two real code lines
(the client serverUri and the CLI bridge-URL log) with `// nosemgrep`. The
scheme already mirrors the page origin (plain on http, secure on https); plain
ws on localhost loopback is the expected, safe behaviour for this dev tool.

typecheck clean, lint exit 0, cast ratchet delta=0, playground still serves.

Signed-off-by: Serhii Tatarintsev <[email protected]>
Comment thread apps/lsp-playground/src/client/main.ts Resolved
- bridge: don't throw from the WebSocket send callback (a transient send
  error could crash the playground process); close the socket instead.
- bridge: fail loud when the LSP subprocess can't be spawned — log a clear
  error and dispose the socket rather than leaving the client on a
  backend-less connection.
- cli: drop the `--config` flag. The language server discovers config by
  walking up from each document's path and cannot be pointed at an arbitrary
  config, so accepting `--config` was misleading and non-functional.
- tsconfig: stop overriding rootDir/outDir; inherit the base (dist-tsc).
- README: tag the architecture fence as `text` (MD040) and drop the removed
  `--config` from the config-resolution docs.

The stale CodeRabbit notes about the bare `as` cast and the unsuppressed
Semgrep finding were already resolved in earlier commits.

typecheck clean, lint exit 0, cast ratchet delta=0, playground still serves
and publishes diagnostics.

Signed-off-by: Serhii Tatarintsev <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/lsp-playground/src/cli.ts`:
- Around line 81-83: The condition at line 81 in the sourceFile validation only
checks if the path exists using fileExists() but does not verify that it is
actually a regular file and not a directory. This causes a crash later at line
114 when readFile() attempts to read a directory as a file. Enhance the
condition to also validate that sourceFile is a regular file (not just that it
exists) by adding an additional check before proceeding with
findNearestConfig(), ensuring the validation fails fast for directory paths.
- Line 56: The schemaArg assignment on line 56 silently ignores any unsupported
flags or extra positional arguments beyond the first non-flag token, which can
lead to unexpected behavior. After extracting schemaArg using the find method,
add explicit validation to check for unsupported flags (tokens starting with
`--` that are not recognized) and extra positional arguments (additional
non-flag tokens beyond the single schema argument). If any invalid flags or
extra positional arguments are detected, throw a usage error message that
clearly explains the valid command syntax instead of silently accepting the
malformed input.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: b2251150-04c4-4858-b8fc-5e8600b4fc4f

📥 Commits

Reviewing files that changed from the base of the PR and between 1b07c4e and c71e883.

📒 Files selected for processing (4)
  • apps/lsp-playground/README.md
  • apps/lsp-playground/src/bridge.ts
  • apps/lsp-playground/src/cli.ts
  • apps/lsp-playground/tsconfig.json
✅ Files skipped from review due to trivial changes (2)
  • apps/lsp-playground/tsconfig.json
  • apps/lsp-playground/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/lsp-playground/src/bridge.ts

Comment thread apps/lsp-playground/src/cli.ts Resolved
Comment thread apps/lsp-playground/src/cli.ts Resolved
Address the second round of review:

- Reject unknown flags and more than one positional argument with an explicit
  usage error, instead of silently picking the first non-flag token.
- Fail fast when the schema path exists but is not a regular file (e.g. a
  directory), rather than crashing later in readFile.

typecheck clean, lint exit 0, cast ratchet delta=0; edge cases (unknown flag,
extra positional, directory path) now exit 1 with clear messages, happy path
still serves.

Signed-off-by: Serhii Tatarintsev <[email protected]>
@SevInf
SevInf merged commit d76a792 into main Jun 19, 2026
20 checks passed
@SevInf
SevInf deleted the lsp-playground branch June 19, 2026 16:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant