From f2b02c455f2bcdfb905a015eefbb630a28b4b12e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 12 Nov 2026 10:56:42 -0300 Subject: addons: an addon can hand the frontend a GPU scene (ABI 3.1), and a snake drawn by shaders does; a commit's patch keeps its own +Diff pane; a real ZLS checked through the window build ABI 3.1 appends an optional `gpu` callback and its context to pa_paint: one self-contained sketchbook SGPU v1 scene for the pane, at most 4 MiB, copied during the call, the last successful call winning. The SDL frontend runs it on its own GPU through sketchbook's executor and composites its target texture into the pane; replicas carry the scene beside the authoritative pane frame; cells and rasters stay the fallback for terminals, older hosts and frontends without an executor. addons/snake_shader is such an addon (`zig build snake-shader`, the SnakeShader word: a board that follows its pane, buffered turns, a CRT look), with test/gpu_snake.py, test/gpu_snake_interaction.py and test/gpu_upgrade.py. Commit patches open as `+Diff-` and reuse only their own commit's pane, so another paged patch no longer replaces one already open. The language-server client looks in the standard per-user bin directory, which desktop launchers often leave out of PATH, and takes an empty answer that beats the startup progress notification onto the wire; test/real_zls.py checks imports, hover, references, rename previews, diagnostics and completion against a real ZLS from a private home. The dump's schema reader skips two fields older builds persisted, and a replica's shadow of a kind ticks when the authority's does. The reference, the guide, the building and setup notes and the changelog say so. The working copy as it stood on 2026-11-12; message written by Claude from the diff, at the author's request. --- test/real_zls.py | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 test/real_zls.py (limited to 'test/real_zls.py') diff --git a/test/real_zls.py b/test/real_zls.py new file mode 100644 index 00000000..74f7cd04 --- /dev/null +++ b/test/real_zls.py @@ -0,0 +1,168 @@ +#!/usr/bin/env python3 +"""Real ZLS through Pardes: desktop PATH, imports, hover, references and editing. + +python3 -B test/real_zls.py GUI_BINARY ZLS_BINARY OUTPUT_DIRECTORY +Uses a private HOME and a project with spaces in its path; needs Zig on PATH. +""" +import argparse +import json +import os +from pathlib import Path +import shutil +import struct +import subprocess +from ninep import Client +from gpu_snake import wait +from daemon import processes + +parser = argparse.ArgumentParser(description=__doc__) +for arg in ['binary', 'zls', 'output']: + parser.add_argument(arg, type=Path) +args = parser.parse_args() +root = args.output.resolve() +root.mkdir(parents=True, mode=0o700) +(root / '.local/bin').mkdir(parents=True) +(root / '.local/bin/zls').symlink_to(args.zls.resolve()) +(root / 'desktop-bin').mkdir() +zig = shutil.which('zig') +assert zig, 'Zig must be on PATH' +(root / 'desktop-bin/zig').symlink_to(Path(zig).resolve()) +(root / 'config/pardes').mkdir(parents=True) +(root / 'config/pardes/init').write_text('Shell /bin/bash\nMessageLinger 0\n') +project = root / 'project with spaces' +project.mkdir() +(project / 'build.zig').write_text('''const std = @import("std"); +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const helper = b.addModule("helper", .{ .root_source_file = b.path("helper.zig"), .target = target }); + const exe = b.addExecutable(.{ .name = "fixture", .root_module = b.createModule(.{ + .root_source_file = b.path("main.zig"), .target = target, + .imports = &.{.{ .name = "helper", .module = helper }}, + }) }); + b.installArtifact(exe); +} +''') +(project / 'helper.zig').write_text('''/// Double a number. +pub fn double(x: u32) u32 { return x * 2; } +pub fn triple(x: u32) u32 { return x * 3; } +''') +(project / 'local file.zig').write_text('pub const answer: u32 = 42;\n') +source = '''const std = @import("std"); +const local = @import("local file.zig"); +const helper = @import("helper"); +pub fn main() void { + _ = std.mem.len("hello"); + _ = local.answer; + _ = helper.double(21); +} +pub fn broken() void { const unused_local: u32 = 7; } +pub fn broken_too() void { const unused_other: u32 = 8; } +''' +(project / 'main.zig').write_text(source) +env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_')} +env.pop('XDG_DATA_HOME', None) +env.update(HOME=str(root), PATH=str(root / 'desktop-bin') + ':/usr/bin:/bin', XDG_RUNTIME_DIR=str(root), + XDG_CONFIG_HOME=str(root / 'config'), XDG_CACHE_HOME=str(root / 'cache'), + PARDES_TEST='1', PARDES_TEST_ROWS='60', PARDES_TEST_CAPTURE_DIR=str(root), SDL_VIDEO_DRIVER='offscreen', PARDES_DAEMON='on') +log = (root / 'stderr.log').open('w') +p = subprocess.Popen([str(args.binary.resolve()), '--9p=zls', str(project / 'main.zig')], + env=env, cwd=project, stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, + stderr=log, start_new_session=True) +c = None +passed = [] +try: + sock = root / '9p/pardes/zls' + wait(lambda: sock.exists() or p.poll() is not None) + assert p.poll() is None, (root / 'stderr.log').read_text() + c = Client(sock, timeout=40) + main = int(next(line.split()[0] for line in c.read('/index').splitlines() if b'/main.zig ' in line)) + + def execute(word): + fid = c.open(f'/pane/{main}/exec', 2) + try: + data = (word + '\n').encode() + c.rpc(118, struct.pack('