From b1fb4242c0ab52767df1b8e155edcf2692f37873 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 18:00:35 -0300 Subject: scroll: a view's top is a line and a row within that line's own wrapped rows, and a scroll moves it by rows (P62, round 3, on the layer's new model where the `Changes` layer's lines are lines of the buffer): a wheel's notch, the glide, PageDown/PageUp, zj/zk, Ctrl-d/u, zt/zz/zb and the margin (`scroll_off` now ROWS) go a row at a time through a line wrapped over many rows and through a long description line of the layer, where the base jumped all of a wrapped line's rows at once (the user, 2026-11-23: "the scroll view jumps around near deleted lines on the diff view"; one-row deleted lines were cured by the layer's second step, a wrapped one was not): TESTS FIRST: core/jj.zig "a view scrolls by rows through a line wrapped over 12 rows and a change's description wrapped over several (a line of the layer): ..." (a notch is one row down the whole text and back, the notches the text's rows exactly; PageDown/PageUp a page of rows; zj/zk one; a held j and k keep the cursor's row `scroll_off` rows inside the body) failing on the base at notch 21 (line 20's 12 rows crossed at once), and "a client wheels its session's view a row a notch into a change's description wrapped over several rows ..., agreeing at every notch; a client joined over that view loads its row"; kept from round 1: core/replica.zig's join over a view scrolled into a wrapped line (with a rollback and a dump) and the explorer of a view's rows (30 seeds), dev/gui's glide a row a notch; THE CHANGE, taken from pardes-row-scroll (`xrxmqlnw`) and -2 (`xxzmwnvq`) without their ghost-row "blocks" (a block is now just a line's own rows): `File.State.scroll_row` and `views.PaneView.scroll_row` in the generic walk (digested, dumped, copied; a dump of 34 loads at its lines' first rows), the wire 35; core/File.zig `Top`, `rowIn`/`rowWalked` (a line's rows as fillBody wraps them, `guideOf` shared), `rowOf`, `lineRows`, `top`/`setTop`, `walkRows`/`walkKnown`, `rowsTo`, `rowsOf` (off the map where it holds the line), `mapFresh`, `scrollRows`, `shownRows` (the geometry laid out first), `show` (a cursor's or a result's row inside the band, the line's rows whole when they fit), `textRowLine`, fillBody's skip to the top's row walked once a geometry (`Pane.top_skip`, derived), the geometry's key with `scroll_row` and stored as what the map was made from; the one-row fact `State.widest` (`Widest`, an upper bound kept by the index's own vector passes `countLines`/`fillLines`) so a view whose lines are each one row walks nothing (`oneRow`: line arithmetic, checked against the walk in Debug); `fitEnd` a vector of printable ASCII at a time; the callers in rows: panes.zig `scrollBy(tab, delta)` and `ensureCursorVisible` (a file's through `File.show`), the wheel and the rail and the edge scroll (mouse.zig), Ctrl-d/u (normal.zig `halfPageMove`), zt/zz/zb, Ctrl-f/b and PgUp/PgDn (Text.zig `scrollViewMove`), Look's reveal and centring, Places' `goTo`/`restore`, Query's `showCurrent`/`caretTo`, the frames' `Region.row` and the glide (dev/glide.zig, the window's `topOf`); test/perf.zig's checks by (line, row) and its seek at a line's first row; Debug in the workspace: core-test 963/1129 (166 skipped), shell-test 1172/1175 (3 skipped) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/daemon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/daemon.py') diff --git a/test/daemon.py b/test/daemon.py index 90977ef4..cfdac2ec 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -328,7 +328,7 @@ class Replica: """A replica's connection (abi/wire.zig): length-prefixed messages, a tag byte and a little-endian u32 length. It is a near client: its first word after the hello says so.""" - WIRE = 34 + WIRE = 35 def __init__(self, path, timeout=10): self.path, self.timeout = path, timeout -- cgit v1.3 From 6fdf2bf2b1a90714ba998fa959db33089abb9f56 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 24 Nov 2026 14:09:41 -0300 Subject: test/daemon.py --client-idle (FAILING on nvuylkxw, the multi-client line's flood: "a PDF in a window's session floods every client"): a session showing a PDF, one terminal client attached, nobody typing for 5 s, takes no more steps than the same session showing the text alone, plus 40 for the PDF's opening (its page drawn, its views told), in boundaries and in the client's units: a window's session on the test surface, a window's loop offscreen with no test mode (asleep until an event or its deadline, as a real window's is: `loop`), and a terminal's with its own terminal; on the base (Debug, load 4): the test surface 388 boundaries and 389 units against the text alone's 206 and 207, the window's loop 4871 and 4872 against 5 and 6 (the session's CPU 1070 ms in the 5 s, the client's 360), the terminal's 7 and 8 against 5 and 6 (passes); the bound's terms: on the test surface the window's loop polls its feed every 16 ms, a step and a unit each, which the text alone's count is; a window's own loop and a terminal's session step for nothing; pdf.so beside both binaries (`zig build install addons` into their prefix): one missing fails the test, never skips it Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/daemon.py | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) (limited to 'test/daemon.py') diff --git a/test/daemon.py b/test/daemon.py index 5603131d..97d7a2bb 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -55,6 +55,11 @@ private HOME and runtime directory: a client window showing a PDF resized 30 times in a second by the real compositor (driftwm), the caller's display: no SDL assertion, the last size taken, an input a size at most + python3 -B test/daemon.py --client-idle + a window's session (the test surface, and offscreen with no test + mode) and a terminal's, each with a PDF and a terminal client, + nobody typing: no more steps than the text alone (pdf.so in both + prefixes) """ import fcntl import json @@ -2278,6 +2283,112 @@ def client_motion(binary, gui_binary): shutil.rmtree(root, ignore_errors=True) +def idle_session(binary, gui_binary, surface, pdf, secs): + """One session (`surface`: a window's on the test surface; a window's + offscreen with no test mode, `loop`: the loop a real window runs, asleep + until an event or its deadline; or a terminal's with its own terminal), + a text and, with `pdf`, a PDF, one terminal client attached, nobody + typing for `secs`: the session's boundaries and the units the client + took over its whole life, and the CPU each spent in the idle seconds + (ticks of 10 ms).""" + scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' + scratch.mkdir(parents=True, exist_ok=True) + root = Path(tempfile.mkdtemp(prefix='ci-', dir=os.environ.get('TMPDIR') or scratch)) + env = base_env() + env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), + TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') + (root / 'config' / 'pardes').mkdir(parents=True) + (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n') + notes = root / 'notes.txt' + notes.write_text(''.join(f'line {i} of the notes\n' for i in range(60))) + stats = root / 'session.stats' + started, terms, windows = [], [], [] + try: + if surface == 'window': + win = Window(root, 'win', [gui_binary, '--9p=idle', str(notes)], dict(env, PARDES_DAEMON='on', PARDES_REPLICA_STATS=str(stats))) + windows.append(win) + started.append(win.pid) + elif surface == 'loop': + started.append(subprocess.Popen([gui_binary, '--9p=idle', str(notes)], cwd=root, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, start_new_session=True, + env=dict(env, PARDES_DAEMON='on', PARDES_REPLICA_STATS=str(stats), SDL_VIDEO_DRIVER='offscreen')).pid) + else: + ts = Term(30, 100) + terms.append(ts) + started.append(ts.spawn([binary, '--tty', '--9p=idle', str(notes)], dict(env, PARDES_REPLICA_STATS=str(stats))).pid) + wait_for('the session\'s 9P socket', (root / 'pardes-9p-idle.sock').exists, timeout=30) + nine = Client(root / 'pardes-9p-idle.sock') + session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid']) + started.append(session) + sock = root / 'pardes-replica.sock' + wait_for('the replica socket', sock.exists, timeout=30) + pane = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text') + if pdf: + doc = root / 'design.pdf' + shutil.copy(Path(__file__).resolve().parent.parent / 'docs' / 'design.pdf', doc) + nine.write(f'/pane/{pane}/look', f'{doc}\n'.encode()) + wait_for('the PDF shown', lambda: any(row.split()[1] == b'pdf' for row in nine.read('/index').splitlines()), timeout=30) + tc = Term(24, 80) + terms.append(tc) + c = tc.spawn([binary, f'--attach={sock}:idle'], dict(env, PARDES_REPLICA_STATS=str(root / 'c.stats'))) + started.append(c.pid) + wait_for('the client\'s first frame', lambda: b'notes' in tc.text(), timeout=30) + # Its join and the frames after it over. + time.sleep(1.5) + cpu = (cpu_ticks(session), cpu_ticks(c.pid)) + time.sleep(secs) + cpu = (cpu_ticks(session) - cpu[0], cpu_ticks(c.pid) - cpu[1]) + c.send_signal(signal.SIGHUP) + c.wait(timeout=10) + line = checks(root / 'c.stats')[-1].split() + units = int(line[line.index('units') + 1]) + exit_session(nine, pane) + wait_for('the session ended', lambda: not alive(session), timeout=60) + nine.socket.close() + return int(session_stats(stats)[0]['boundaries']), units, cpu + finally: + for t in terms: + t.close() + for w in windows: + if w.p.poll() is None: + w.p.kill() + for pid in started + processes(root): + try: + os.kill(pid, signal.SIGKILL) + except OSError: + pass + shutil.rmtree(root, ignore_errors=True) + + +def client_idle(binary, gui_binary, secs=5): + """An idle session sends nothing (2026-11-24: a PDF in a window's session + with a client attached stepped the session ~700 times a second, nobody + typing, each step a unit every client replayed): a session showing a + text and a PDF, one terminal client, nobody typing for `secs`, takes at + most the steps the same session with the text alone takes, plus the + PDF's own opening (its page drawn, its views told: `opening`). On the + test surface the window's loop polls its feed every 16 ms, a step and a + unit each (the text alone's count is that rate); a window's own loop + (`loop`: offscreen, no test mode) and a terminal's session step for + nothing. The PDF's addon (`/lib/pardes/addons/pdf.so`, `zig + build addons`) beside each binary.""" + for b in (binary, gui_binary): + lib = Path(b).resolve().parent.parent / 'lib' / 'pardes' / 'addons' / 'pdf.so' + assert lib.exists(), f'no {lib}: the PDF is this test\'s subject (zig build install addons into that prefix)' + opening = 40 + flooded = [] + for surface in ('window', 'loop', 'tty'): + text = idle_session(binary, gui_binary, surface, False, secs) + shown = idle_session(binary, gui_binary, surface, True, secs) + print(f'daemon: a {surface}\'s session idle {secs} s, a terminal client attached: ' + f'text alone {text[0]} boundaries, the client {text[1]} units, CPU {text[2][0] * 10}/{text[2][1] * 10} ms; ' + f'with a PDF {shown[0]} boundaries, {shown[1]} units, CPU {shown[2][0] * 10}/{shown[2][1] * 10} ms (session/client)') + if shown[0] > text[0] + opening or shown[1] > text[1] + opening: + flooded.append(f'{surface}: {shown[0]} boundaries and {shown[1]} units against the text alone\'s {text[0]} and {text[1]}') + assert not flooded, (f'a session showing a PDF, a client attached, nobody typing for {secs} s, steps with nothing to do, ' + f'a unit every client replays: {"; ".join(flooded)}') + + def client_resize_real(binary, gui_binary): """A client window resized by a real compositor (driftwm's `msg resize`, the configures a drag sends: 30 sizes in a second) while it shows a PDF: @@ -4493,6 +4604,8 @@ if __name__ == '__main__': client_motion(sys.argv[2], sys.argv[3]) elif sys.argv[1:2] == ['--client-resize-real']: client_resize_real(sys.argv[2], sys.argv[3]) + elif sys.argv[1:2] == ['--client-idle']: + client_idle(sys.argv[2], sys.argv[3]) elif sys.argv[1:2] == ['--ping']: ping(sys.argv[2], sys.argv[3], sys.argv[4], int(sys.argv[5]) if len(sys.argv) > 5 else 50) elif sys.argv[1:2] == ['--pair-gui']: -- cgit v1.3