Compare commits
12 Commits
main
...
dpi-font-a
| Author | SHA1 | Date |
|---|---|---|
|
|
ce8ad59f7c | |
|
|
2e42d7e1c4 | |
|
|
17e7232d12 | |
|
|
88f66baeed | |
|
|
3f77180b63 | |
|
|
ccc5a745de | |
|
|
5b1c80a8a5 | |
|
|
e600d61eef | |
|
|
5c7f00a3b8 | |
|
|
3b0c27ec44 | |
|
|
574fb80d79 | |
|
|
cdb0e8411a |
|
|
@ -1,291 +0,0 @@
|
|||
# Test Harness Reference: piker
|
||||
|
||||
This repository-local file supplements the canonical `/run-tests` skill.
|
||||
Keep shared execution, worktree, failure-inspection, and cleanup policy in the
|
||||
canonical `SKILL.md`; keep Piker commands, paths, fixtures, and known outcomes
|
||||
here.
|
||||
|
||||
## Project And Environment
|
||||
|
||||
- Project/import: `piker`
|
||||
- Test root: `tests/`
|
||||
- Supported Python: `>=3.12,<3.14`
|
||||
- Preferred complete environment: worktree-local `py313` inside the current
|
||||
`nix develop` shell
|
||||
- The flake shell pins CPython 3.13 and sets
|
||||
`UV_PROJECT_ENVIRONMENT=py313`.
|
||||
- Verify the interpreter, package resolution, and dependency import before
|
||||
running tests. A bare `py313` may lack the Qt binding supplied by Nix.
|
||||
|
||||
Use an already-provisioned `py313` only when `import piker` succeeds:
|
||||
|
||||
```text
|
||||
py313/bin/python -m pytest -p no:xonsh
|
||||
```
|
||||
|
||||
If direct environment paths are unavailable, an existing uv environment can
|
||||
be used without changing it, subject to the same import check:
|
||||
|
||||
```text
|
||||
UV_PROJECT_ENVIRONMENT=py313 uv run --frozen --no-sync python -m pytest -p no:xonsh
|
||||
```
|
||||
|
||||
Ask before running provisioning commands such as:
|
||||
|
||||
```text
|
||||
UV_PROJECT_ENVIRONMENT=py313 uv sync --dev --all-extras --no-group lint
|
||||
nix develop
|
||||
nix-shell default.nix
|
||||
```
|
||||
|
||||
`nix develop` is the current Wayland/Qt 6 shell. `default.nix` is the current
|
||||
X11 shell. Do not use `develop.nix` for current testing; it retains the old
|
||||
Python 3.11, Poetry, and Qt 5 stack.
|
||||
|
||||
The current root-checkout `py313` resolves `piker` locally but fails
|
||||
`import piker` outside Nix because PyQtGraph cannot import PyQt or PySide. Do
|
||||
not treat that environment as test-ready and do not enter `nix develop`
|
||||
without approval: its shell hook may recreate and sync `py313`.
|
||||
|
||||
Plain `uv sync` does not include the testing group. The `dbs` dependency group
|
||||
is also absent from normal dev-shell provisioning.
|
||||
|
||||
## Commands
|
||||
|
||||
Base command in the preferred environment:
|
||||
|
||||
```text
|
||||
py313/bin/python -m pytest -p no:xonsh
|
||||
```
|
||||
|
||||
The explicit `-p no:xonsh` is required. The tracked comments-only
|
||||
`pytest.ini` takes precedence over `pyproject.toml`, so the intended
|
||||
`addopts = "-p no:xonsh"` and `testpaths = ["tests"]` are inactive.
|
||||
Always pass a test path or node ID explicitly.
|
||||
|
||||
Package-resolution check that does not import Piker's dependencies:
|
||||
|
||||
```text
|
||||
py313/bin/python -c 'import importlib.util, pathlib, sys; root = pathlib.Path.cwd().resolve(); spec = importlib.util.find_spec("piker"); mod = pathlib.Path(spec.origin).resolve(); print(sys.executable); print(mod); assert mod.is_relative_to(root)'
|
||||
```
|
||||
|
||||
Dependency import check, required before collection or execution:
|
||||
|
||||
```text
|
||||
py313/bin/python -c 'import pathlib, piker, sys; root = pathlib.Path.cwd().resolve(); mod = pathlib.Path(piker.__file__).resolve(); print(sys.executable); print(mod); assert mod.is_relative_to(root)'
|
||||
```
|
||||
|
||||
Safe core collection check:
|
||||
|
||||
```text
|
||||
py313/bin/python -m pytest -p no:xonsh -q --collect-only tests/test_watchlists.py tests/test_accounting.py tests/test_services.py tests/test_ems.py tests/test_feeds.py tests/test_cli.py
|
||||
```
|
||||
|
||||
Default first-pass flags are `-q -x --tb=short --no-header` unless the user
|
||||
requests otherwise. For actor-heavy tests, use one file or node per process
|
||||
with an outer timeout:
|
||||
|
||||
```text
|
||||
timeout -k 5 300 py313/bin/python -m pytest -p no:xonsh -q <one-file-or-node>
|
||||
```
|
||||
|
||||
If an actor-heavy command exits `124` or `143`, retry that exact command once
|
||||
and report both attempts. Never convert a retry pass into an unconditional
|
||||
pass, and do not retry assertion, import, collection, or configuration
|
||||
failures.
|
||||
|
||||
## Scope And Path Resolution
|
||||
|
||||
Resolve bare test filenames beneath `tests/`. Preserve complete node IDs and
|
||||
apply `-k` only within explicitly selected paths. There is no marker-based
|
||||
offline/full-suite split, so never use `pytest tests` as a deterministic
|
||||
default.
|
||||
|
||||
Deterministic or local first-pass targets:
|
||||
|
||||
- `tests/test_watchlists.py`
|
||||
- `tests/test_storage_audit.py`
|
||||
- `tests/test_store_cli.py`
|
||||
- `tests/test_backfill_audit_snippet.py`
|
||||
- `tests/test_ib_history.py`
|
||||
- `tests/test_ib_method_proxy.py`
|
||||
- `tests/test_history_backfill.py`
|
||||
- `tests/test_ldshm.py`
|
||||
- `tests/test_accounting.py::test_account_file_default_empty`
|
||||
- `tests/test_services.py::test_runtime_boot`
|
||||
- `tests/test_services.py::test_datad_spawn`
|
||||
- `tests/test_ems.py::test_ems_err_on_bad_broker`
|
||||
|
||||
Require explicit authorization before running:
|
||||
|
||||
- `tests/test_feeds.py` - live Binance/Kraken feeds;
|
||||
- `tests/test_services.py::test_ensure_datafeed_actors` - live Kraken feed;
|
||||
- `tests/test_services.py::test_ensure_ems_in_paper_actors` - paper EMS with
|
||||
live Kraken symbology/feed access;
|
||||
- `tests/test_ems.py::test_multi_fill_positions` - live backend setup and
|
||||
persisted state;
|
||||
- `tests/test_accounting.py::test_paper_ledger_position_calcs` - tracked
|
||||
fixtures plus possible live symcache generation;
|
||||
- `tests/test_accounting.py::test_ib_account_with_duplicated_mktids` - active
|
||||
broker/account configuration and state writes;
|
||||
- `tests/test_dpi_font.py` - Qt/UI import and user-config side effects;
|
||||
- `tests/test_docker_services.py` - optional dependencies and containers;
|
||||
- `tests/test_questrade.py` - obsolete credentialed imports.
|
||||
|
||||
`tests/test_cli.py` is currently hard-skipped. It is not an active CLI
|
||||
regression gate.
|
||||
|
||||
Never execute `piker store anal` or `piker store shm --write-parquet`
|
||||
as tests. They are mutating or interactive operational commands.
|
||||
|
||||
## Project-Specific Flags And Backend Matrix
|
||||
|
||||
| Flag | Purpose |
|
||||
|---|---|
|
||||
| `--ll LEVEL` | Piker log level |
|
||||
| `--confdir PATH` | Override `piker.config._config_dir` |
|
||||
| `--spawn-backend trio|mp_spawn|mp_forkserver` | Tractor process backend |
|
||||
| `--tpt-proto PROTO` | Tractor transport; one protocol per session |
|
||||
| `--tpdb` / `--debug-mode` | Tractor plugin debug mode |
|
||||
| `--pdb` | Standard pytest debugger |
|
||||
| `-s` | No capture; required with `--pdb` and `open_test_pikerd` |
|
||||
|
||||
Do not invent `network`, `offline`, `docker`, `gui`, or `broker` markers; none
|
||||
currently exists. `CI=1` is not an offline selector: feed tests still leave a
|
||||
live Kraken case enabled. Current Piker tests exercise TCP; do not assume the
|
||||
whole suite supports UDS merely because the Tractor plugin exposes it.
|
||||
|
||||
## Fixture Invariants
|
||||
|
||||
- The session `confdir` fixture does nothing unless `--confdir` is passed.
|
||||
Its claimed `tests/data` fallback is not implemented and that directory is
|
||||
absent.
|
||||
- Function-scoped `tmpconfdir` changes process-global config state and does
|
||||
not restore the previous path. Use separate pytest processes when
|
||||
diagnosing state leakage.
|
||||
- `open_test_pikerd` passes the temporary config path to child actors through
|
||||
`tractor_runtime_overrides`.
|
||||
- `tests/_inputs/trades_binance_paper.toml` and
|
||||
`tests/_inputs/account.binance.paper.toml` are used in place. Accounting
|
||||
contexts can write them on exit. Inspect `git diff -- tests/_inputs` after
|
||||
any selected accounting case.
|
||||
- Importing `tests/test_dpi_font.py` constructs module-global font objects
|
||||
before fixtures can isolate config. If explicitly requested, isolate
|
||||
`XDG_CONFIG_HOME` before Python starts and use the proper Qt/Nix shell.
|
||||
- Piker and the installed Tractor pytest plugin do not provide a
|
||||
repository-local process or socket reaper. Never apply historical broad
|
||||
`pkill -f tractor._child` guidance automatically.
|
||||
- The function-scoped autouse `shm_leak_tracker` fixture wraps Tractor's
|
||||
current-process `SharedMemory` factory. It tracks only successful
|
||||
`create=True` calls, restores the pre-test `_known_tokens` cache, and
|
||||
unlinks exact surviving names before failing the leaking test. It never
|
||||
scans `/dev/shm` or unlinks attachments created by another process.
|
||||
|
||||
## Test Layout
|
||||
|
||||
```text
|
||||
tests/
|
||||
conftest.py Piker options, config fixtures, Tractor plugin
|
||||
_inputs/ tracked ledger/account fixtures
|
||||
test_accounting.py config, ledgers, accounts, and position math
|
||||
test_cli.py legacy CLI suite; hard-skipped
|
||||
test_docker_services.py container integrations; optional deps, skipped
|
||||
test_dpi_font.py Qt DPI/font behavior
|
||||
test_ems.py actor, EMS, and paper-position behavior
|
||||
test_feeds.py live Binance/Kraken feeds and shared memory
|
||||
test_ib_history.py deterministic IB history request formatting
|
||||
test_ib_method_proxy.py deterministic IB asyncio proxy routing
|
||||
test_history_backfill.py deterministic history/SHM orchestration
|
||||
test_ldshm.py SHM unpublished-slot guard
|
||||
test_questrade.py obsolete credentialed tests; skipped
|
||||
test_services.py pikerd/datad/feed/EMS actor lifecycle
|
||||
test_store_cli.py storage command help and diagnostics UX
|
||||
test_storage_audit.py read-only NativeDB audit and JSON CLI
|
||||
test_backfill_audit_snippet.py
|
||||
disposable xonsh qualification helpers
|
||||
test_watchlists.py deterministic watchlist JSON operations
|
||||
```
|
||||
|
||||
## Change-To-Test Mapping
|
||||
|
||||
| Changed area | Run first | Caveat |
|
||||
|---|---|---|
|
||||
| `piker/watchlists/` | `tests/test_watchlists.py` | CLI suite is skipped |
|
||||
| `piker/storage/_audit.py`, `piker/storage/cli.py` | `tests/test_storage_audit.py` | direct Typer app, no actor |
|
||||
| `piker/storage/cli.py` command UX | `tests/test_store_cli.py` | fake SHM/runtime, no mutation |
|
||||
| `snippets/nativedb_backfill_audit.xsh` | `tests/test_backfill_audit_snippet.py` | disposable paths only |
|
||||
| `piker/brokers/ib/api.py`, `feed.py` history | `tests/test_ib_history.py` | fake client, no network |
|
||||
| `piker/brokers/ib/api.py` method proxy | `tests/test_ib_method_proxy.py` | fake channel, no network |
|
||||
| `piker/tsp/_history.py` | `tests/test_history_backfill.py` | fake provider/storage/SHM |
|
||||
| `piker/storage/cli.py` SHM null-slot guard | `tests/test_ldshm.py` | synthetic timestamps, no SHM mutation |
|
||||
| `piker/config.py` | `test_account_file_default_empty` | root-network test has a known mismatch |
|
||||
| `piker/accounting/` | targeted accounting node | some cases use live/configured state |
|
||||
| `piker/ui/_style.py`, `piker/ui/qt.py` | `tests/test_dpi_font.py` | GUI/config-isolated opt-in |
|
||||
| `piker/service/_actor_runtime.py`, `_registry.py`, `_mngr.py` | `test_runtime_boot` | then `test_datad_spawn` |
|
||||
| `piker/service/`, `piker/data/_daemon.py` | `test_datad_spawn` | feed lifecycle cases are live |
|
||||
| `piker/data/feed.py`, `flows.py`, `_sharedmem.py`, `_sampling.py` | collect first | feed execution needs live permission |
|
||||
| `piker/clearing/` | `test_ems_err_on_bad_broker` | multi-fill case is live/persisted |
|
||||
| `piker/brokers/binance/`, `kraken/` | selected feed/accounting node | live network |
|
||||
| `piker/brokers/ib/` | duplicated-market-ID node | controlled account config required |
|
||||
| Docker/service adapters | `tests/test_docker_services.py` | optional deps and containers |
|
||||
| project, lock, or Nix files | import check and safe collection | full collection is not safe by default |
|
||||
|
||||
Prefer deterministic filesystem/config tests, then local actor-runtime nodes,
|
||||
then explicitly approved live broker, GUI, or container coverage.
|
||||
|
||||
## Quick Checks
|
||||
|
||||
```text
|
||||
py313/bin/python -c 'import importlib.util, pathlib, sys; root = pathlib.Path.cwd().resolve(); spec = importlib.util.find_spec("piker"); mod = pathlib.Path(spec.origin).resolve(); print(sys.executable); print(mod); assert mod.is_relative_to(root)'
|
||||
py313/bin/python -c 'import pathlib, piker, sys; root = pathlib.Path.cwd().resolve(); mod = pathlib.Path(piker.__file__).resolve(); print(sys.executable); print(mod); assert mod.is_relative_to(root)'
|
||||
py313/bin/python -m pytest -p no:xonsh -q tests/test_watchlists.py
|
||||
py313/bin/python -m pytest -p no:xonsh -q tests/test_accounting.py::test_account_file_default_empty
|
||||
timeout -k 5 300 py313/bin/python -m pytest -p no:xonsh -q tests/test_services.py::test_runtime_boot
|
||||
timeout -k 5 300 py313/bin/python -m pytest -p no:xonsh -q tests/test_services.py::test_datad_spawn
|
||||
timeout -k 5 300 py313/bin/python -m pytest -p no:xonsh -q tests/test_ems.py::test_ems_err_on_bad_broker
|
||||
```
|
||||
|
||||
## Known Outcomes
|
||||
|
||||
- The current root-checkout `py313` fails `import piker` outside the Nix shell
|
||||
with `ImportError: PyQtGraph requires one of PyQt5, PyQt6, PySide2 or
|
||||
PySide6`. This is an incomplete environment, not an application regression.
|
||||
- `tests/test_accounting.py::test_root_conf_networking_section` currently
|
||||
expects `network.tsdb`, which is absent from the tracked config template.
|
||||
Match the current `KeyError: 'tsdb'` before classifying it as the known
|
||||
repository mismatch.
|
||||
- `tests/test_docker_services.py` is marked skipped but imports
|
||||
`elasticsearch` first. Without the `dbs` group it fails collection rather
|
||||
than skipping.
|
||||
- `tests/test_questrade.py` is marked skipped but imports undeclared `asks`
|
||||
through the legacy broker module before marks apply.
|
||||
- `test_open_orders_reloaded` and `test_dark_order_clearing` in
|
||||
`tests/test_ems.py` contain only ellipsis bodies. A pass does not verify the
|
||||
named behavior.
|
||||
- Treat `.pytest_cache` feed IDs using old FQME forms as stale historical
|
||||
cache, not current known failures.
|
||||
|
||||
Do not classify every `TooSlowError`, timeout, or child survivor as the known
|
||||
Tractor teardown wedge. Match the selected node and the documented
|
||||
second-runtime/lingering-child signature.
|
||||
|
||||
## Tractor Runtime Notes
|
||||
|
||||
The suite loads `tractor._testing.pytest`. Defaults are the `trio` spawn
|
||||
backend and TCP transport. Registry addresses are normally session-unique,
|
||||
except `tests/test_services.py::test_runtime_boot`, which binds
|
||||
`127.0.0.1:6666`. Check that fixed port only for that node; ordinary tests do
|
||||
not require Piker's production `127.0.0.1:6116` registry address.
|
||||
|
||||
Current repository concurrency notes document an intermittent second
|
||||
in-process `pikerd` boot wedge with a lingering broker child and unread parent
|
||||
IPC bytes. Use the outer timeout for actor-heavy nodes. Retry an exact command
|
||||
once only after status `124` or `143`, and report both attempts.
|
||||
|
||||
Ordinary actor tests support normal capture. Diagnose a capture-dependent hang
|
||||
by retrying only the exact node with `-s`. Standard `--pdb` with
|
||||
`open_test_pikerd` requires `-s`; Tractor's `--tpdb` is a separate option.
|
||||
|
||||
After abnormal exit, inspect only descendants, sockets, and shared-memory
|
||||
objects attributable to the exact pytest session. Ask before signaling or
|
||||
unlinking anything.
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"version": 1, "backend": "neutral"}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(chmod:*)",
|
||||
"Bash(/tmp/piker_commits.txt)",
|
||||
"Bash(python:*)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
---
|
||||
name: commit-msg
|
||||
description: >
|
||||
Generate piker-style git commit messages from
|
||||
staged changes or prompt input, following the
|
||||
style guide learned from 500 repo commits.
|
||||
argument-hint: "[optional-scope-or-description]"
|
||||
disable-model-invocation: true
|
||||
allowed-tools: Bash(git *), Read, Grep, Glob, Write
|
||||
---
|
||||
|
||||
## Current staged changes
|
||||
!`git diff --staged --stat`
|
||||
|
||||
## Recent commit style reference
|
||||
!`git log --oneline -10`
|
||||
|
||||
# Piker Git Commit Message Generator
|
||||
|
||||
Generate a commit message from the staged diff above
|
||||
following the piker project's conventions (learned from
|
||||
analyzing 500 repo commits).
|
||||
|
||||
If `$ARGUMENTS` is provided, use it as scope or
|
||||
description context for the commit message.
|
||||
|
||||
For the full style guide with verb frequencies,
|
||||
section markers, abbreviations, piker-specific terms,
|
||||
and examples, see
|
||||
[style-guide-reference.md](./style-guide-reference.md).
|
||||
|
||||
## Quick Reference
|
||||
|
||||
- **Subject**: ~50 chars, present tense verb, use
|
||||
backticks for code refs
|
||||
- **Body**: only for complex/multi-file changes,
|
||||
67 char line max
|
||||
- **Section markers**: Also, / Deats, / Other,
|
||||
- **Bullets**: use `-` style
|
||||
- **Tone**: technical but casual (piker style)
|
||||
|
||||
## Claude-code Footer
|
||||
|
||||
When the written **patch** was assisted by
|
||||
claude-code, include:
|
||||
|
||||
```
|
||||
(this patch was generated in some part by [`claude-code`][claude-code-gh])
|
||||
[claude-code-gh]: https://github.com/anthropics/claude-code
|
||||
```
|
||||
|
||||
When only the **commit msg** was written by
|
||||
claude-code (human wrote the patch), use:
|
||||
```
|
||||
(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
|
||||
[claude-code-gh]: https://github.com/anthropics/claude-code
|
||||
```
|
||||
|
||||
## Output Instructions
|
||||
|
||||
When generating a commit message:
|
||||
|
||||
1. Analyze the staged diff (injected above via
|
||||
dynamic context) to understand all changes.
|
||||
2. If `$ARGUMENTS` provides a scope (e.g.,
|
||||
`.ib.feed`) or description, incorporate it into
|
||||
the subject line.
|
||||
3. Write the subject line following verb + backtick
|
||||
conventions from the
|
||||
[style guide](./style-guide-reference.md).
|
||||
4. Add body only for multi-file or complex changes.
|
||||
5. Write the message to a file in the repo's
|
||||
`.claude/` subdir with filename format:
|
||||
`<timestamp>_<first-7-chars-of-last-commit-hash>_commit_msg.md`
|
||||
where `<timestamp>` is from `date --iso-8601=seconds`.
|
||||
Also write a copy to
|
||||
`.claude/git_commit_msg_LATEST.md`
|
||||
(overwrite if exists).
|
||||
|
||||
---
|
||||
|
||||
**Analysis date:** 2026-01-27
|
||||
**Commits analyzed:** 500 from piker repository
|
||||
**Maintained by:** Tyler Goodlet
|
||||
|
|
@ -150,18 +150,21 @@ Common in piker commits (33.0% use colons):
|
|||
- File:line references not used (0 occurrences)
|
||||
- No WIP commits in analyzed set
|
||||
|
||||
### Coding-harness Footer
|
||||
When a coding harness assisted with the written patch,
|
||||
identify the active harness, model, and provider:
|
||||
### Claude-code Footer
|
||||
When the written **patch** was assisted by claude-code,
|
||||
include:
|
||||
|
||||
```
|
||||
(this patch was generated in some part by `<harness>` using `<model>` (`<provider>`))
|
||||
(this patch was generated in some part by [`claude-code`][claude-code-gh])
|
||||
[claude-code-gh]: https://github.com/anthropics/claude-code
|
||||
```
|
||||
|
||||
When it generated only the commit message, use:
|
||||
When only the **commit msg** was written by claude-code
|
||||
(human wrote the patch), use:
|
||||
|
||||
```
|
||||
(this commit msg was generated in some part by `<harness>` using `<model>` (`<provider>`))
|
||||
(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
|
||||
[claude-code-gh]: https://github.com/anthropics/claude-code
|
||||
```
|
||||
|
||||
## Piker-Specific Terms
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../.agents/skills/piker-profiling
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../.agents/skills/piker-slang
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../.agents/skills/pyqtgraph-optimization
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../.agents/skills/timeseries-optimization
|
||||
|
|
@ -107,9 +107,6 @@ ENV/
|
|||
.git/
|
||||
|
||||
# any commit-msg gen tmp files
|
||||
.claude/skills/commit-msg/msgs/
|
||||
.claude/skills/commit-msg/conf.toml
|
||||
.claude/git_commit_msg_LATEST.md
|
||||
.claude/*_commit_*.md
|
||||
.claude/*_commit*.toml
|
||||
|
||||
|
|
@ -133,362 +130,3 @@ gitea/
|
|||
|
||||
# LLM conversations that should remain private
|
||||
docs/conversations/
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:gish
|
||||
/.claude/skills/gish
|
||||
# END ai.skillz: direct:symlink:claude:gish
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:gish
|
||||
/.opencode/skills/gish
|
||||
# END ai.skillz: direct:symlink:opencode:gish
|
||||
|
||||
# BEGIN ai.skillz: runtime:open-wkt
|
||||
/wkts/
|
||||
# END ai.skillz: runtime:open-wkt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:open-wkt
|
||||
/.claude/skills/open-wkt
|
||||
# END ai.skillz: direct:symlink:claude:open-wkt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:open-wkt
|
||||
/.opencode/skills/open-wkt
|
||||
# END ai.skillz: direct:symlink:opencode:open-wkt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:run-tests
|
||||
/.claude/skills/run-tests/SKILL.md
|
||||
# END ai.skillz: direct:symlink:claude:run-tests
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:run-tests
|
||||
/.opencode/skills/run-tests/SKILL.md
|
||||
# END ai.skillz: direct:symlink:opencode:run-tests
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:close-wkt
|
||||
/.claude/skills/close-wkt
|
||||
# END ai.skillz: direct:symlink:claude:close-wkt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:close-wkt
|
||||
/.opencode/skills/close-wkt
|
||||
# END ai.skillz: direct:symlink:opencode:close-wkt
|
||||
|
||||
# BEGIN ai.skillz: runtime:code-review
|
||||
.ai/code-review/reports/
|
||||
# END ai.skillz: runtime:code-review
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:code-review
|
||||
/.claude/skills/code-review
|
||||
# END ai.skillz: direct:symlink:claude:code-review
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:code-review
|
||||
/.opencode/skills/code-review
|
||||
# END ai.skillz: direct:symlink:opencode:code-review
|
||||
|
||||
# BEGIN ai.skillz: runtime:code-review-changes
|
||||
.ai/state/review/
|
||||
.claude/review_context.md
|
||||
.claude/review_regression.md
|
||||
.claude/review_replies/
|
||||
# END ai.skillz: runtime:code-review-changes
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:code-review-changes
|
||||
/.claude/skills/code-review-changes
|
||||
# END ai.skillz: direct:symlink:claude:code-review-changes
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:code-review-changes
|
||||
/.opencode/skills/code-review-changes
|
||||
# END ai.skillz: direct:symlink:opencode:code-review-changes
|
||||
|
||||
# BEGIN ai.skillz: runtime:commit-msg
|
||||
.ai/state/commit-msg/
|
||||
.ai/state/migrations/
|
||||
.ai/commit-msg/conf.toml
|
||||
.claude/skills/commit-msg/msgs/
|
||||
.claude/git_commit_msg_LATEST.md
|
||||
# END ai.skillz: runtime:commit-msg
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:commit-msg
|
||||
/.claude/skills/commit-msg/SKILL.md
|
||||
# END ai.skillz: direct:symlink:claude:commit-msg
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:commit-msg
|
||||
/.opencode/skills/commit-msg/SKILL.md
|
||||
# END ai.skillz: direct:symlink:opencode:commit-msg
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:commit-plan
|
||||
/.claude/skills/commit-plan
|
||||
# END ai.skillz: direct:symlink:claude:commit-plan
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:commit-plan
|
||||
/.opencode/skills/commit-plan
|
||||
# END ai.skillz: direct:symlink:opencode:commit-plan
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:dep-supersede-scan
|
||||
/.claude/skills/dep-supersede-scan
|
||||
# END ai.skillz: direct:symlink:claude:dep-supersede-scan
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:dep-supersede-scan
|
||||
/.opencode/skills/dep-supersede-scan
|
||||
# END ai.skillz: direct:symlink:opencode:dep-supersede-scan
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:resolve-conflicts
|
||||
/.claude/skills/resolve-conflicts
|
||||
# END ai.skillz: direct:symlink:claude:resolve-conflicts
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:resolve-conflicts
|
||||
/.opencode/skills/resolve-conflicts
|
||||
# END ai.skillz: direct:symlink:opencode:resolve-conflicts
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:git-mgmt
|
||||
/.claude/skills/git-mgmt
|
||||
# END ai.skillz: direct:symlink:claude:git-mgmt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:git-mgmt
|
||||
/.opencode/skills/git-mgmt
|
||||
# END ai.skillz: direct:symlink:opencode:git-mgmt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:harness-perf
|
||||
/.claude/skills/harness-perf
|
||||
# END ai.skillz: direct:symlink:claude:harness-perf
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:harness-perf
|
||||
/.opencode/skills/harness-perf
|
||||
# END ai.skillz: direct:symlink:opencode:harness-perf
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:inter-skill-review
|
||||
/.claude/skills/inter-skill-review
|
||||
# END ai.skillz: direct:symlink:claude:inter-skill-review
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:inter-skill-review
|
||||
/.opencode/skills/inter-skill-review
|
||||
# END ai.skillz: direct:symlink:opencode:inter-skill-review
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:opencode-cleaning
|
||||
/.claude/skills/opencode-cleaning
|
||||
# END ai.skillz: direct:symlink:claude:opencode-cleaning
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:opencode-cleaning
|
||||
/.opencode/skills/opencode-cleaning
|
||||
# END ai.skillz: direct:symlink:opencode:opencode-cleaning
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:plan-io
|
||||
/.claude/skills/plan-io
|
||||
# END ai.skillz: direct:symlink:claude:plan-io
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:plan-io
|
||||
/.opencode/skills/plan-io
|
||||
# END ai.skillz: direct:symlink:opencode:plan-io
|
||||
|
||||
# BEGIN ai.skillz: runtime:pr-msg
|
||||
.ai/state/pr-msg/
|
||||
.ai/pr-msg/conf.toml
|
||||
.claude/skills/pr-msg/msgs/
|
||||
.claude/skills/pr-msg/pr_msg_LATEST.md
|
||||
# END ai.skillz: runtime:pr-msg
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:pr-msg
|
||||
/.claude/skills/pr-msg/SKILL.md
|
||||
/.claude/skills/pr-msg/references
|
||||
/.claude/skills/pr-msg/scripts
|
||||
# END ai.skillz: direct:symlink:claude:pr-msg
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:pr-msg
|
||||
/.opencode/skills/pr-msg/SKILL.md
|
||||
/.opencode/skills/pr-msg/references
|
||||
/.opencode/skills/pr-msg/scripts
|
||||
# END ai.skillz: direct:symlink:opencode:pr-msg
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:prompt-io
|
||||
/.claude/skills/prompt-io
|
||||
# END ai.skillz: direct:symlink:claude:prompt-io
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:prompt-io
|
||||
/.opencode/skills/prompt-io
|
||||
# END ai.skillz: direct:symlink:opencode:prompt-io
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:py-codestyle
|
||||
/.claude/skills/py-codestyle
|
||||
# END ai.skillz: direct:symlink:claude:py-codestyle
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:py-codestyle
|
||||
/.opencode/skills/py-codestyle
|
||||
# END ai.skillz: direct:symlink:opencode:py-codestyle
|
||||
|
||||
# BEGIN ai.skillz: runtime:taken-export
|
||||
.ai/taken/exports/
|
||||
# END ai.skillz: runtime:taken-export
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:taken-export
|
||||
/.claude/skills/taken-export
|
||||
# END ai.skillz: direct:symlink:claude:taken-export
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:taken-export
|
||||
/.opencode/skills/taken-export
|
||||
# END ai.skillz: direct:symlink:opencode:taken-export
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:yt-url-lookup
|
||||
/.claude/skills/yt-url-lookup
|
||||
# END ai.skillz: direct:symlink:claude:yt-url-lookup
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:yt-url-lookup
|
||||
/.opencode/skills/yt-url-lookup
|
||||
# END ai.skillz: direct:symlink:opencode:yt-url-lookup
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:run-tests
|
||||
/.opencode/commands/run-tests.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:run-tests
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:code-review
|
||||
/.opencode/commands/code-review.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:code-review
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:code-review-changes
|
||||
/.opencode/commands/code-review-changes.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:code-review-changes
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:commit-msg
|
||||
/.opencode/commands/commit-msg.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:commit-msg
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:commit-plan
|
||||
/.opencode/commands/commit-plan.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:commit-plan
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:opencode-cleaning
|
||||
/.opencode/commands/opencode-cleaning.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:opencode-cleaning
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:pr-msg
|
||||
/.opencode/commands/pr-msg.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:pr-msg
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:taken-export
|
||||
/.opencode/commands/taken-export.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:taken-export
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:claude:code-nav-refs
|
||||
/.claude/skills/code-nav-refs
|
||||
# END ai.skillz: direct:symlink:claude:code-nav-refs
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:code-nav-refs
|
||||
/.opencode/skills/code-nav-refs
|
||||
# END ai.skillz: direct:symlink:opencode:code-nav-refs
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:gish
|
||||
/.opencode/commands/gish.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:gish
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:resolve-conflicts
|
||||
/.opencode/commands/resolve-conflicts.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:resolve-conflicts
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:git-mgmt
|
||||
/.opencode/commands/git-mgmt.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:git-mgmt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:open-wkt
|
||||
/.opencode/commands/open-wkt.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:open-wkt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:close-wkt
|
||||
/.opencode/commands/close-wkt.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:close-wkt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:dep-supersede-scan
|
||||
/.opencode/commands/dep-supersede-scan.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:dep-supersede-scan
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:harness-perf
|
||||
/.opencode/commands/harness-perf.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:harness-perf
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:opencode:command:yt-url-lookup
|
||||
/.opencode/commands/yt-url-lookup.md
|
||||
# END ai.skillz: direct:symlink:opencode:command:yt-url-lookup
|
||||
# BEGIN ai.skillz: direct:symlink:agents:gish
|
||||
/.agents/skills/gish
|
||||
# END ai.skillz: direct:symlink:agents:gish
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:resolve-conflicts
|
||||
/.agents/skills/resolve-conflicts
|
||||
# END ai.skillz: direct:symlink:agents:resolve-conflicts
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:git-mgmt
|
||||
/.agents/skills/git-mgmt
|
||||
# END ai.skillz: direct:symlink:agents:git-mgmt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:open-wkt
|
||||
/.agents/skills/open-wkt
|
||||
# END ai.skillz: direct:symlink:agents:open-wkt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:run-tests
|
||||
/.agents/skills/run-tests
|
||||
# END ai.skillz: direct:symlink:agents:run-tests
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:close-wkt
|
||||
/.agents/skills/close-wkt
|
||||
# END ai.skillz: direct:symlink:agents:close-wkt
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:code-review
|
||||
/.agents/skills/code-review
|
||||
# END ai.skillz: direct:symlink:agents:code-review
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:code-nav-refs
|
||||
/.agents/skills/code-nav-refs
|
||||
# END ai.skillz: direct:symlink:agents:code-nav-refs
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:code-review-changes
|
||||
/.agents/skills/code-review-changes
|
||||
# END ai.skillz: direct:symlink:agents:code-review-changes
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:commit-msg
|
||||
/.agents/skills/commit-msg
|
||||
# END ai.skillz: direct:symlink:agents:commit-msg
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:commit-plan
|
||||
/.agents/skills/commit-plan
|
||||
# END ai.skillz: direct:symlink:agents:commit-plan
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:dep-supersede-scan
|
||||
/.agents/skills/dep-supersede-scan
|
||||
# END ai.skillz: direct:symlink:agents:dep-supersede-scan
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:harness-perf
|
||||
/.agents/skills/harness-perf
|
||||
# END ai.skillz: direct:symlink:agents:harness-perf
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:inter-skill-review
|
||||
/.agents/skills/inter-skill-review
|
||||
# END ai.skillz: direct:symlink:agents:inter-skill-review
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:opencode-cleaning
|
||||
/.agents/skills/opencode-cleaning
|
||||
# END ai.skillz: direct:symlink:agents:opencode-cleaning
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:plan-io
|
||||
/.agents/skills/plan-io
|
||||
# END ai.skillz: direct:symlink:agents:plan-io
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:pr-msg
|
||||
/.agents/skills/pr-msg
|
||||
# END ai.skillz: direct:symlink:agents:pr-msg
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:prompt-io
|
||||
/.agents/skills/prompt-io
|
||||
# END ai.skillz: direct:symlink:agents:prompt-io
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:py-codestyle
|
||||
/.agents/skills/py-codestyle
|
||||
# END ai.skillz: direct:symlink:agents:py-codestyle
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:taken-export
|
||||
/.agents/skills/taken-export
|
||||
# END ai.skillz: direct:symlink:agents:taken-export
|
||||
|
||||
# BEGIN ai.skillz: direct:symlink:agents:yt-url-lookup
|
||||
/.agents/skills/yt-url-lookup
|
||||
# END ai.skillz: direct:symlink:agents:yt-url-lookup
|
||||
|
||||
# BEGIN ai.skillz: workflow-state
|
||||
/.ai/state/
|
||||
/.ai/commit-msg/conf.toml
|
||||
/.ai/pr-msg/conf.toml
|
||||
# END ai.skillz: workflow-state
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
---
|
||||
model: openai/gpt-5.6-sol
|
||||
service: opencode
|
||||
session: unavailable
|
||||
timestamp: 2026-09-07T21:40:00Z
|
||||
git_ref: 9115d24
|
||||
scope: config
|
||||
substantive: true
|
||||
raw_file: 20260907T214000Z_9115d24_prompt_io.raw.md
|
||||
---
|
||||
|
||||
## Prompt
|
||||
|
||||
Deploy the provider-neutral `.agents` skill tree for Codex first and
|
||||
then migrate Piker's workflow state without losing archived helpers.
|
||||
|
||||
## Response summary
|
||||
|
||||
Deployed 21 ignored `.agents/skills` links, copied 132 legacy runtime
|
||||
files into `.ai/state`, selected the neutral backend, and preserved the
|
||||
original archive and staged `ruff.toml` change.
|
||||
|
||||
## Files changed
|
||||
|
||||
- `.gitignore` - ignore shared links and generated neutral state.
|
||||
- `.ai/workflow-state.json` - select the neutral backend.
|
||||
- `.ai/commit-msg/style-guide-reference.md` - port commit guidance.
|
||||
- `.ai/run-tests/test-harness-reference.md` - port test guidance.
|
||||
|
||||
## Human edits
|
||||
|
||||
The human prioritized immediate Codex deployment and directed helper
|
||||
archives to migrate as opaque runtime data instead of blocking the
|
||||
operation. No direct source-line edits were made by the human.
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
model: openai/gpt-5.6-sol
|
||||
service: opencode
|
||||
timestamp: 2026-09-07T21:40:00Z
|
||||
git_ref: 9115d24
|
||||
diff_cmd: git diff HEAD~1..HEAD
|
||||
---
|
||||
|
||||
Deploy all shared `ai.skillz` skills through `.agents/skills` for
|
||||
Codex, then migrate Piker's generated workflow state from the legacy
|
||||
Claude layout to provider-neutral `.ai/state` storage.
|
||||
|
||||
Preserve every legacy source and the existing staged `ruff.toml`
|
||||
change. Commit only the neutral backend selection, repository guidance,
|
||||
ignore rules, and this provenance record.
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
---
|
||||
model: openai/gpt-5.6-sol
|
||||
service: opencode
|
||||
session: unavailable
|
||||
timestamp: 2026-09-08T04:31:34Z
|
||||
git_ref: f148fbcc
|
||||
scope: config
|
||||
substantive: true
|
||||
raw_file: 20260908T043134Z_f148fbcc_prompt_io.raw.md
|
||||
---
|
||||
|
||||
## Prompt
|
||||
|
||||
Audit tracked legacy skill files under `.claude/`, then migrate Piker's
|
||||
repository-specific skills into the provider-neutral discovery tree.
|
||||
Keep Claude compatibility and remove stale Claude-local configuration.
|
||||
|
||||
## Response summary
|
||||
|
||||
Moves four Piker-specific skill packages to `.agents/skills/`, retains
|
||||
Claude discovery through relative adapter links, and drops two stale
|
||||
tracked Claude-local files.
|
||||
|
||||
## Files changed
|
||||
|
||||
- `.agents/skills/piker-*/` - provider-neutral Piker skill sources.
|
||||
- `.claude/skills/piker-*` - relative Claude compatibility links.
|
||||
- `.claude/settings.local.json` - remove tracked local permissions.
|
||||
- `.claude/skills/commit-msg/style-guide-reference.md` - remove the
|
||||
superseded legacy copy now represented under `.ai/commit-msg/`.
|
||||
|
||||
## Human edits
|
||||
|
||||
The human identified that repository-specific skills were not migrated
|
||||
by the shared `ai.skillz` deployment, selected `.agents/skills/` as the
|
||||
neutral source, and requested that the migration land in PR 93 before
|
||||
following up on the generic migration tooling.
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
---
|
||||
model: openai/gpt-5.6-sol
|
||||
service: opencode
|
||||
timestamp: 2026-09-08T04:31:34Z
|
||||
git_ref: f148fbcc
|
||||
diff_cmd: git diff --cached
|
||||
---
|
||||
|
||||
## Prompt
|
||||
|
||||
Audit tracked legacy skill files under `.claude/`, then migrate Piker's
|
||||
repository-specific skills into the provider-neutral discovery tree.
|
||||
Keep Claude compatibility and remove stale Claude-local configuration.
|
||||
|
||||
## Generated changes
|
||||
|
||||
> `git diff --cached -- .agents/skills/`
|
||||
|
||||
Moves the four Piker-owned skill packages into the neutral
|
||||
`.agents/skills/` source tree without changing their contents.
|
||||
|
||||
> `git diff --cached -- .claude/skills/ .claude/settings.local.json`
|
||||
|
||||
Adds relative Claude adapter links to the neutral skill sources and
|
||||
removes the tracked local settings file and superseded commit-message
|
||||
style guide.
|
||||
|
||||
## Validation
|
||||
|
||||
- All four Claude adapter links resolve to a `SKILL.md`.
|
||||
- `git diff --cached --check` passes.
|
||||
- No tracked files match the repository's ignore rules.
|
||||
- Shared deployment validation retains one unrelated stale local
|
||||
`commit-plan` hybrid-link error for an `ai.skillz` follow-up.
|
||||
|
|
@ -75,6 +75,9 @@ class Axis(pg.AxisItem):
|
|||
self.pi = plotitem
|
||||
self._dpi_font = _font
|
||||
|
||||
# store for later recalculation on zoom
|
||||
self._typical_max_str = typical_max_str
|
||||
|
||||
self.setTickFont(_font.font)
|
||||
font_size = self._dpi_font.font.pixelSize()
|
||||
|
||||
|
|
@ -156,6 +159,41 @@ class Axis(pg.AxisItem):
|
|||
def size_to_values(self) -> None:
|
||||
pass
|
||||
|
||||
def update_fonts(self, font: DpiAwareFont) -> None:
|
||||
'''Update font and recalculate axis sizing after zoom change.'''
|
||||
# IMPORTANT: tell Qt we're about to change geometry
|
||||
self.prepareGeometryChange()
|
||||
|
||||
self._dpi_font = font
|
||||
self.setTickFont(font.font)
|
||||
font_size = font.font.pixelSize()
|
||||
|
||||
# recalculate text offset based on new font size
|
||||
text_offset = None
|
||||
if self.orientation in ('bottom',):
|
||||
text_offset = floor(0.25 * font_size)
|
||||
elif self.orientation in ('left', 'right'):
|
||||
text_offset = floor(font_size / 2)
|
||||
|
||||
if text_offset:
|
||||
self.setStyle(tickTextOffset=text_offset)
|
||||
|
||||
# recalculate bounding rect with new font
|
||||
# Note: typical_max_str should be stored from init
|
||||
if not hasattr(self, '_typical_max_str'):
|
||||
self._typical_max_str = '100 000.000 ' # fallback default
|
||||
self.typical_br = font._qfm.boundingRect(self._typical_max_str)
|
||||
|
||||
# Update PyQtGraph's internal text size tracking
|
||||
# This is critical - PyQtGraph uses these internally for auto-expand
|
||||
if self.orientation in ['left', 'right']:
|
||||
self.textWidth = self.typical_br.width()
|
||||
else:
|
||||
self.textHeight = self.typical_br.height()
|
||||
|
||||
# resize axis to fit new font - this triggers PyQtGraph's auto-expand
|
||||
self.size_to_values()
|
||||
|
||||
def txt_offsets(self) -> tuple[int, int]:
|
||||
return tuple(self.style['tickTextOffset'])
|
||||
|
||||
|
|
@ -256,7 +294,14 @@ class PriceAxis(Axis):
|
|||
self._min_tick = size
|
||||
|
||||
def size_to_values(self) -> None:
|
||||
self.setWidth(self.typical_br.width())
|
||||
# Call PyQtGraph's internal width update mechanism
|
||||
# This respects autoExpandTextSpace and updates min/max constraints
|
||||
self._updateWidth()
|
||||
# tell Qt our preferred size changed so layout recalculates
|
||||
self.updateGeometry()
|
||||
# force parent plot item to recalculate its layout
|
||||
if self.pi and hasattr(self.pi, 'updateGeometry'):
|
||||
self.pi.updateGeometry()
|
||||
|
||||
# XXX: drop for now since it just eats up h space
|
||||
|
||||
|
|
@ -300,7 +345,14 @@ class DynamicDateAxis(Axis):
|
|||
}
|
||||
|
||||
def size_to_values(self) -> None:
|
||||
self.setHeight(self.typical_br.height() + 1)
|
||||
# Call PyQtGraph's internal height update mechanism
|
||||
# This respects autoExpandTextSpace and updates min/max constraints
|
||||
self._updateHeight()
|
||||
# tell Qt our preferred size changed so layout recalculates
|
||||
self.updateGeometry()
|
||||
# force parent plot item to recalculate its layout
|
||||
if self.pi and hasattr(self.pi, 'updateGeometry'):
|
||||
self.pi.updateGeometry()
|
||||
|
||||
def _indexes_to_timestrs(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -203,6 +203,9 @@ def run_qtractor(
|
|||
if is_windows:
|
||||
window.configure_to_desktop()
|
||||
|
||||
# install global keyboard shortcuts for UI zoom
|
||||
window.install_global_zoom_filter()
|
||||
|
||||
# actually render to screen
|
||||
window.show()
|
||||
app.exec_()
|
||||
|
|
|
|||
|
|
@ -124,6 +124,13 @@ class Edit(QLineEdit):
|
|||
self.sizeHint()
|
||||
self.update()
|
||||
|
||||
def update_fonts(self, font: DpiAwareFont) -> None:
|
||||
'''Update font and recalculate widget size.'''
|
||||
self.dpi_font = font
|
||||
self.setFont(font.font)
|
||||
# tell Qt our size hint changed so it recalculates layout
|
||||
self.updateGeometry()
|
||||
|
||||
def focus(self) -> None:
|
||||
self.selectAll()
|
||||
self.show()
|
||||
|
|
@ -241,6 +248,14 @@ class Selection(QComboBox):
|
|||
icon_size = round(h * 0.75)
|
||||
self.setIconSize(QSize(icon_size, icon_size))
|
||||
|
||||
def update_fonts(self, font: DpiAwareFont) -> None:
|
||||
'''Update font and recalculate widget size.'''
|
||||
self.setFont(font.font)
|
||||
# recalculate heights with new font
|
||||
self.resize()
|
||||
# tell Qt our size hint changed so it recalculates layout
|
||||
self.updateGeometry()
|
||||
|
||||
def set_items(
|
||||
self,
|
||||
keys: list[str],
|
||||
|
|
@ -431,6 +446,39 @@ class FieldsForm(QWidget):
|
|||
self.fields[key] = select
|
||||
return select
|
||||
|
||||
def update_fonts(self) -> None:
|
||||
'''Update font sizes after zoom change.'''
|
||||
from ._style import _font, _font_small
|
||||
|
||||
# update stored font size
|
||||
self._font_size = _font_small.px_size - 2
|
||||
|
||||
# update all labels
|
||||
for name, label in self.labels.items():
|
||||
if hasattr(label, 'update_font'):
|
||||
label.update_font(_font.font, self._font_size - 1)
|
||||
|
||||
# update all fields (edits, selects)
|
||||
for key, field in self.fields.items():
|
||||
# first check for our custom update_fonts method (Edit, Selection)
|
||||
if hasattr(field, 'update_fonts'):
|
||||
field.update_fonts(_font)
|
||||
# then handle stylesheet updates for those without custom methods
|
||||
elif hasattr(field, 'setStyleSheet'):
|
||||
# regenerate stylesheet with new font size
|
||||
field.setStyleSheet(
|
||||
f"""QLineEdit {{
|
||||
color : {hcolor('gunmetal')};
|
||||
font-size : {self._font_size}px;
|
||||
}}
|
||||
"""
|
||||
)
|
||||
field.setFont(_font.font)
|
||||
|
||||
# for Selection widgets that need style updates
|
||||
if hasattr(field, 'set_style'):
|
||||
field.set_style(color='gunmetal', font_size=self._font_size)
|
||||
|
||||
|
||||
async def handle_field_input(
|
||||
|
||||
|
|
@ -633,6 +681,37 @@ class FillStatusBar(QProgressBar):
|
|||
self.setRange(0, int(slots))
|
||||
self.setValue(value)
|
||||
|
||||
def update_fonts(self, font_size: int) -> None:
|
||||
'''Update font size after zoom change.'''
|
||||
from ._style import _font_small
|
||||
|
||||
self.font_size = font_size
|
||||
# regenerate stylesheet with new font size
|
||||
self.setStyleSheet(
|
||||
f"""
|
||||
QProgressBar {{
|
||||
|
||||
text-align: center;
|
||||
|
||||
font-size : {self.font_size - 2}px;
|
||||
|
||||
background-color: {hcolor('papas_special')};
|
||||
color : {hcolor('papas_special')};
|
||||
|
||||
border: {self.border_px}px solid {hcolor('default_light')};
|
||||
border-radius: 2px;
|
||||
}}
|
||||
QProgressBar::chunk {{
|
||||
|
||||
background-color: {hcolor('default_spotlight')};
|
||||
color: {hcolor('bracket')};
|
||||
|
||||
border-radius: 2px;
|
||||
}}
|
||||
"""
|
||||
)
|
||||
self.setFont(_font_small.font)
|
||||
|
||||
|
||||
def mk_fill_status_bar(
|
||||
|
||||
|
|
|
|||
|
|
@ -334,3 +334,19 @@ class FormatLabel(QLabel):
|
|||
out = self.fmt_str.format(**fields)
|
||||
self.setText(out)
|
||||
return out
|
||||
|
||||
def update_font(
|
||||
self,
|
||||
font: QtGui.QFont,
|
||||
font_size: int,
|
||||
font_color: str = 'default_lightest',
|
||||
) -> None:
|
||||
'''Update font after zoom change.'''
|
||||
self.setStyleSheet(
|
||||
f"""QLabel {{
|
||||
color : {hcolor(font_color)};
|
||||
font-size : {font_size}px;
|
||||
}}
|
||||
"""
|
||||
)
|
||||
self.setFont(font)
|
||||
|
|
|
|||
|
|
@ -178,6 +178,26 @@ class SettingsPane:
|
|||
# encompasing high level namespace
|
||||
order_mode: OrderMode | None = None # typing: ignore # noqa
|
||||
|
||||
def update_fonts(self) -> None:
|
||||
'''Update font sizes after zoom change.'''
|
||||
from ._style import _font_small
|
||||
|
||||
# update form fields
|
||||
if self.form and hasattr(self.form, 'update_fonts'):
|
||||
self.form.update_fonts()
|
||||
|
||||
# update fill status bar
|
||||
if self.fill_bar and hasattr(self.fill_bar, 'update_fonts'):
|
||||
self.fill_bar.update_fonts(_font_small.px_size)
|
||||
|
||||
# update labels with new fonts
|
||||
if self.step_label:
|
||||
self.step_label.setFont(_font_small.font)
|
||||
if self.pnl_label:
|
||||
self.pnl_label.setFont(_font_small.font)
|
||||
if self.limit_label:
|
||||
self.limit_label.setFont(_font_small.font)
|
||||
|
||||
def set_accounts(
|
||||
self,
|
||||
names: list[str],
|
||||
|
|
|
|||
|
|
@ -174,6 +174,13 @@ class CompleterView(QTreeView):
|
|||
|
||||
self.setStyleSheet(f"font: {size}px")
|
||||
|
||||
def update_fonts(self) -> None:
|
||||
'''Update font sizes after zoom change.'''
|
||||
self.set_font_size(_font.px_size)
|
||||
self.setIndentation(_font.px_size)
|
||||
self.setFont(_font.font)
|
||||
self.updateGeometry()
|
||||
|
||||
def resize_to_results(
|
||||
self,
|
||||
w: float | None = 0,
|
||||
|
|
@ -630,6 +637,29 @@ class SearchWidget(QtWidgets.QWidget):
|
|||
| align_flag.AlignLeft,
|
||||
)
|
||||
|
||||
def update_fonts(self) -> None:
|
||||
'''Update font sizes after zoom change.'''
|
||||
# regenerate label stylesheet with new font size
|
||||
self.label.setStyleSheet(
|
||||
f"""QLabel {{
|
||||
color : {hcolor('default_lightest')};
|
||||
font-size : {_font.px_size - 2}px;
|
||||
}}
|
||||
"""
|
||||
)
|
||||
self.label.setFont(_font.font)
|
||||
|
||||
# update search bar and view fonts
|
||||
if hasattr(self.bar, 'update_fonts'):
|
||||
self.bar.update_fonts(_font)
|
||||
elif hasattr(self.bar, 'setFont'):
|
||||
self.bar.setFont(_font.font)
|
||||
|
||||
if hasattr(self.view, 'update_fonts'):
|
||||
self.view.update_fonts()
|
||||
|
||||
self.updateGeometry()
|
||||
|
||||
def focus(self) -> None:
|
||||
self.show()
|
||||
self.bar.focus()
|
||||
|
|
|
|||
|
|
@ -79,9 +79,13 @@ class DpiAwareFont:
|
|||
self._font_inches: float = None
|
||||
self._screen = None
|
||||
|
||||
def _set_qfont_px_size(self, px_size: int) -> None:
|
||||
self._qfont.setPixelSize(px_size)
|
||||
def _set_qfont_px_size(
|
||||
self,
|
||||
px_size: int,
|
||||
) -> int:
|
||||
self._qfont.setPixelSize(int(px_size))
|
||||
self._qfm = QtGui.QFontMetrics(self._qfont)
|
||||
return self.px_size
|
||||
|
||||
@property
|
||||
def screen(self) -> QtGui.QScreen:
|
||||
|
|
@ -124,17 +128,22 @@ class DpiAwareFont:
|
|||
|
||||
return size
|
||||
|
||||
def configure_to_dpi(self, screen: QtGui.QScreen | None = None):
|
||||
def configure_to_dpi(
|
||||
self,
|
||||
screen: QtGui.QScreen | None = None,
|
||||
zoom_level: float = 1.0,
|
||||
) -> int:
|
||||
'''
|
||||
Set an appropriately sized font size depending on the screen DPI.
|
||||
Set an appropriately sized font size depending on the screen DPI
|
||||
or scale the size according to `zoom_level`.
|
||||
|
||||
If we end up needing to generalize this more here there are resources
|
||||
listed in the script in ``snippets/qt_screen_info.py``.
|
||||
If we end up needing to generalize this more here there are
|
||||
resources listed in the script in
|
||||
``snippets/qt_screen_info.py``.
|
||||
|
||||
'''
|
||||
if self._font_size is not None:
|
||||
self._set_qfont_px_size(self._font_size)
|
||||
return
|
||||
return self._set_qfont_px_size(self._font_size * zoom_level)
|
||||
|
||||
# NOTE: if no font size set either in the [ui] section of the
|
||||
# config or not yet computed from our magic scaling calcs,
|
||||
|
|
@ -153,7 +162,7 @@ class DpiAwareFont:
|
|||
ldpi = pdpi
|
||||
|
||||
mx_dpi = max(pdpi, ldpi)
|
||||
mn_dpi = min(pdpi, ldpi)
|
||||
# mn_dpi = min(pdpi, ldpi)
|
||||
scale = round(ldpi/pdpi, ndigits=2)
|
||||
|
||||
if mx_dpi <= 97: # for low dpi use larger font sizes
|
||||
|
|
@ -162,7 +171,7 @@ class DpiAwareFont:
|
|||
else: # hidpi use smaller font sizes
|
||||
inches = _font_sizes['hi'][self._font_size_calc_key]
|
||||
|
||||
dpi = mn_dpi
|
||||
# dpi = mn_dpi
|
||||
|
||||
mult = 1.0
|
||||
|
||||
|
|
@ -197,24 +206,25 @@ class DpiAwareFont:
|
|||
# always going to hit that error in range mapping from inches:
|
||||
# float to px size: int.
|
||||
self._font_inches = inches
|
||||
font_size = math.floor(inches * dpi)
|
||||
font_size = math.floor(inches * pdpi)
|
||||
|
||||
# apply zoom level multiplier
|
||||
font_size = int(font_size * zoom_level)
|
||||
|
||||
log.debug(
|
||||
f"screen:{screen.name()}\n"
|
||||
f"pDPI: {pdpi}, lDPI: {ldpi}, scale: {scale}\n"
|
||||
f"zoom_level: {zoom_level}\n"
|
||||
f"\nOur best guess font size is {font_size}\n"
|
||||
)
|
||||
# apply the size
|
||||
self._set_qfont_px_size(font_size)
|
||||
return self._set_qfont_px_size(font_size)
|
||||
|
||||
def boundingRect(self, value: str) -> QtCore.QRectF:
|
||||
|
||||
screen = self.screen
|
||||
if screen is None:
|
||||
if self.screen is None:
|
||||
raise RuntimeError("You must call .configure_to_dpi() first!")
|
||||
|
||||
unscaled_br = self._qfm.boundingRect(value)
|
||||
|
||||
unscaled_br: QtCore.QRectF = self._qfm.boundingRect(value)
|
||||
return QtCore.QRectF(
|
||||
0,
|
||||
0,
|
||||
|
|
@ -228,12 +238,22 @@ _font = DpiAwareFont()
|
|||
_font_small = DpiAwareFont(_font_size_key='small')
|
||||
|
||||
|
||||
def _config_fonts_to_screen() -> None:
|
||||
'configure global DPI aware font sizes'
|
||||
def _config_fonts_to_screen(
|
||||
zoom_level: float = 1.0
|
||||
) -> int:
|
||||
'''
|
||||
Configure global DPI aware font size(s).
|
||||
|
||||
If `zoom_level` is provided we apply it to auto-calculated
|
||||
DPI-aware font.
|
||||
|
||||
Return the new `DpiAwareFont.px_size`.
|
||||
|
||||
'''
|
||||
global _font, _font_small
|
||||
_font.configure_to_dpi()
|
||||
_font_small.configure_to_dpi()
|
||||
_font.configure_to_dpi(zoom_level=zoom_level)
|
||||
_font_small.configure_to_dpi(zoom_level=zoom_level)
|
||||
return _font.px_size
|
||||
|
||||
|
||||
def get_fonts() -> tuple[
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
Qt main window singletons and stuff.
|
||||
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import os
|
||||
import signal
|
||||
import time
|
||||
|
|
@ -38,15 +39,107 @@ from piker.ui.qt import (
|
|||
QScreen,
|
||||
QCloseEvent,
|
||||
QSettings,
|
||||
QEvent,
|
||||
QObject,
|
||||
)
|
||||
from ..log import get_logger
|
||||
from ._style import _font_small, hcolor
|
||||
from . import _style
|
||||
from ._style import (
|
||||
_font_small,
|
||||
hcolor,
|
||||
)
|
||||
from ._widget import GodWidget
|
||||
|
||||
|
||||
log = get_logger(__name__)
|
||||
|
||||
|
||||
class GlobalZoomEventFilter(QObject):
|
||||
'''
|
||||
Application-level event filter for global UI zoom shortcuts.
|
||||
|
||||
This filter intercepts keyboard events BEFORE they reach widgets,
|
||||
allowing us to implement global UI zoom shortcuts that take precedence
|
||||
over widget-specific shortcuts.
|
||||
|
||||
Shortcuts:
|
||||
- Ctrl+Shift+Plus/Equal: Zoom in
|
||||
- Ctrl+Shift+Minus: Zoom out
|
||||
- Ctrl+Shift+0: Reset zoom
|
||||
|
||||
'''
|
||||
def __init__(self, main_window: MainWindow):
|
||||
super().__init__()
|
||||
self.main_window = main_window
|
||||
|
||||
def eventFilter(self, obj: QObject, event: QEvent) -> bool:
|
||||
'''
|
||||
Filter keyboard events for global zoom shortcuts.
|
||||
|
||||
Returns True to filter out (consume) the event, False to pass through.
|
||||
|
||||
'''
|
||||
if event.type() == QEvent.Type.KeyPress:
|
||||
key = event.key()
|
||||
mods = event.modifiers()
|
||||
|
||||
# Mask out the KeypadModifier which Qt sometimes adds
|
||||
mods = mods & ~Qt.KeyboardModifier.KeypadModifier
|
||||
|
||||
# Check if we have Ctrl+Shift (both required)
|
||||
has_ctrl = bool(
|
||||
mods
|
||||
&
|
||||
Qt.KeyboardModifier.ControlModifier
|
||||
)
|
||||
_has_shift = bool(
|
||||
mods
|
||||
&
|
||||
Qt.KeyboardModifier.ShiftModifier
|
||||
)
|
||||
|
||||
# Only handle UI zoom if BOTH Ctrl and Shift are pressed
|
||||
# For Plus key: user presses Cmd+Shift+Equal (which makes Plus)
|
||||
# For Minus key: user presses Cmd+Shift+Minus
|
||||
if (
|
||||
has_ctrl
|
||||
# and
|
||||
# has_shift
|
||||
):
|
||||
# Zoom in: Ctrl+Shift+Plus
|
||||
# Note: Plus key usually comes as Key_Equal with Shift modifier
|
||||
if key in (
|
||||
Qt.Key.Key_Plus,
|
||||
Qt.Key.Key_Equal,
|
||||
):
|
||||
self.main_window.zoom_in()
|
||||
return True # consume event
|
||||
|
||||
# Zoom out: Ctrl+Shift+Minus
|
||||
# Note: On some keyboards Shift+Minus produces '_' (Underscore)
|
||||
elif key in (
|
||||
Qt.Key.Key_Minus,
|
||||
Qt.Key.Key_Underscore,
|
||||
):
|
||||
self.main_window.zoom_out()
|
||||
return True # consume event
|
||||
|
||||
# Reset zoom: Ctrl+Shift+0
|
||||
# Note: On some keyboards Shift+0 produces ')' (ParenRight)
|
||||
elif key in (
|
||||
Qt.Key.Key_0,
|
||||
Qt.Key.Key_ParenRight,
|
||||
):
|
||||
self.main_window.reset_zoom()
|
||||
return True # consume event
|
||||
|
||||
# Pass through if only Ctrl (no Shift) - this goes to chart zoom
|
||||
# Pass through all other events too
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class MultiStatus:
|
||||
|
||||
bar: QStatusBar
|
||||
|
|
@ -189,6 +282,24 @@ class MainWindow(QMainWindow):
|
|||
self.restoreGeometry(geometry)
|
||||
log.debug('Restored window geometry from previous session')
|
||||
|
||||
# zoom level for UI scaling (1.0 = 100%, 1.5 = 150%, etc)
|
||||
# Change this value to set the default startup zoom level
|
||||
self._zoom_level: float = 1.0 # Start at 100% (normal)
|
||||
self._min_zoom: float = 0.5
|
||||
self._max_zoom: float = 3.0 # Reduced from 10.0 to prevent extreme cropping
|
||||
self._zoom_step: float = 0.2 # 20% per keypress
|
||||
|
||||
# event filter for global zoom shortcuts
|
||||
self._zoom_filter: GlobalZoomEventFilter | None = None
|
||||
|
||||
def install_global_zoom_filter(self) -> None:
|
||||
'''Install application-level event filter for global UI zoom shortcuts.'''
|
||||
if self._zoom_filter is None:
|
||||
self._zoom_filter = GlobalZoomEventFilter(self)
|
||||
app = QApplication.instance()
|
||||
app.installEventFilter(self._zoom_filter)
|
||||
log.info('Installed global zoom shortcuts: Ctrl+Shift+Plus/Minus/0')
|
||||
|
||||
@property
|
||||
def mode_label(self) -> QLabel:
|
||||
|
||||
|
|
@ -357,6 +468,201 @@ class MainWindow(QMainWindow):
|
|||
self.godwidget.on_win_resize(event)
|
||||
event.accept()
|
||||
|
||||
def zoom_in(self) -> None:
|
||||
'''
|
||||
Increase overall UI-widgets zoom level by scaling it the
|
||||
global font sizes.
|
||||
|
||||
'''
|
||||
new_zoom: float = min(
|
||||
self._zoom_level + self._zoom_step,
|
||||
self._max_zoom,
|
||||
)
|
||||
if new_zoom != self._zoom_level:
|
||||
self._zoom_level = new_zoom
|
||||
font_size: int = self._apply_zoom()
|
||||
log.info(
|
||||
f'Zoomed in UI\n'
|
||||
f'zoom_step: {self._zoom_step!r}\n'
|
||||
f'zoom_level(%): {self._zoom_level:.1%}\n'
|
||||
f'font_size: {font_size!r}'
|
||||
)
|
||||
|
||||
def zoom_out(self) -> float:
|
||||
'''
|
||||
Decrease UI zoom level.
|
||||
|
||||
'''
|
||||
new_zoom: float = max(self._zoom_level - self._zoom_step, self._min_zoom)
|
||||
if new_zoom != self._zoom_level:
|
||||
self._zoom_level = new_zoom
|
||||
font_size: int = self._apply_zoom()
|
||||
log.info(
|
||||
f'Zoomed out UI\n'
|
||||
f'zoom_step: {self._zoom_step!r}\n'
|
||||
f'zoom_level(%): {self._zoom_level:.1%}\n'
|
||||
f'font_size: {font_size!r}'
|
||||
)
|
||||
|
||||
return new_zoom
|
||||
|
||||
def reset_zoom(self) -> None:
|
||||
'''
|
||||
Reset UI zoom to 100%.
|
||||
|
||||
'''
|
||||
if self._zoom_level != 1.0:
|
||||
self._zoom_level = 1.0
|
||||
font_size: int = self._apply_zoom()
|
||||
log.info(
|
||||
f'Reset zoom level\n'
|
||||
f'zoom_step: {self._zoom_step!r}\n'
|
||||
f'zoom_level(%): {self._zoom_level:.1%}\n'
|
||||
f'font_size: {font_size!r}'
|
||||
)
|
||||
|
||||
return self._zoom_level
|
||||
|
||||
def _apply_zoom(self) -> int:
|
||||
'''
|
||||
Apply current zoom level to all UI elements.
|
||||
|
||||
'''
|
||||
# reconfigure fonts with zoom multiplier
|
||||
font_size: int = _style._config_fonts_to_screen(
|
||||
zoom_level=self._zoom_level
|
||||
)
|
||||
|
||||
# update status bar styling with new font size
|
||||
if self._status_bar:
|
||||
sb = self.statusBar()
|
||||
sb.setStyleSheet((
|
||||
f"color : {hcolor('gunmetal')};"
|
||||
f"background : {hcolor('default_dark')};"
|
||||
f"font-size : {_style._font_small.px_size}px;"
|
||||
"padding : 0px;"
|
||||
))
|
||||
|
||||
# force update of mode label if it exists
|
||||
if self._status_label:
|
||||
self._status_label.setFont(_style._font_small.font)
|
||||
|
||||
# update godwidget and its children
|
||||
if self.godwidget:
|
||||
# update search widget if it exists
|
||||
if hasattr(self.godwidget, 'search') and self.godwidget.search:
|
||||
self.godwidget.search.update_fonts()
|
||||
|
||||
# update order mode panes in all chart views
|
||||
self._update_chart_order_panes()
|
||||
|
||||
# recursively update all other widgets with stylesheets
|
||||
self._refresh_widget_fonts(self.godwidget)
|
||||
self.godwidget.update()
|
||||
|
||||
return font_size
|
||||
|
||||
def _update_chart_order_panes(self) -> None:
|
||||
'''
|
||||
Update order entry panels in all charts.
|
||||
|
||||
'''
|
||||
if not self.godwidget:
|
||||
return
|
||||
|
||||
# iterate through all linked splits (hist and rt)
|
||||
for splits_name in ['hist_linked', 'rt_linked']:
|
||||
splits = getattr(self.godwidget, splits_name, None)
|
||||
if not splits:
|
||||
continue
|
||||
|
||||
# get main chart
|
||||
chart = getattr(splits, 'chart', None)
|
||||
if chart:
|
||||
# update axes
|
||||
self._update_chart_axes(chart)
|
||||
|
||||
# update order pane
|
||||
if hasattr(chart, 'view'):
|
||||
view = chart.view
|
||||
if hasattr(view, 'order_mode') and view.order_mode:
|
||||
order_mode = view.order_mode
|
||||
if hasattr(order_mode, 'pane') and order_mode.pane:
|
||||
order_mode.pane.update_fonts()
|
||||
|
||||
# also check subplots
|
||||
subplots = getattr(splits, 'subplots', {})
|
||||
for name, subplot_chart in subplots.items():
|
||||
# update subplot axes
|
||||
self._update_chart_axes(subplot_chart)
|
||||
|
||||
# update subplot order pane
|
||||
if hasattr(subplot_chart, 'view'):
|
||||
subplot_view = subplot_chart.view
|
||||
if hasattr(subplot_view, 'order_mode') and subplot_view.order_mode:
|
||||
subplot_order_mode = subplot_view.order_mode
|
||||
if hasattr(subplot_order_mode, 'pane') and subplot_order_mode.pane:
|
||||
subplot_order_mode.pane.update_fonts()
|
||||
|
||||
# resize all sidepanes to match main chart's sidepane width
|
||||
# this ensures volume/subplot sidepanes match the main chart
|
||||
if splits and hasattr(splits, 'resize_sidepanes'):
|
||||
splits.resize_sidepanes()
|
||||
|
||||
def _update_chart_axes(self, chart) -> None:
|
||||
'''Update axis fonts and sizing for a chart.'''
|
||||
from . import _style
|
||||
|
||||
# update price axis (right side)
|
||||
if hasattr(chart, 'pi') and chart.pi:
|
||||
plot_item = chart.pi
|
||||
# get all axes from plot item
|
||||
for axis_name in ['left', 'right', 'bottom', 'top']:
|
||||
axis = plot_item.getAxis(axis_name)
|
||||
if axis and hasattr(axis, 'update_fonts'):
|
||||
axis.update_fonts(_style._font)
|
||||
|
||||
# force plot item to recalculate its entire layout
|
||||
plot_item.updateGeometry()
|
||||
|
||||
# force chart widget to update
|
||||
if hasattr(chart, 'updateGeometry'):
|
||||
chart.updateGeometry()
|
||||
|
||||
# trigger a full scene update
|
||||
if hasattr(chart, 'update'):
|
||||
chart.update()
|
||||
|
||||
def _refresh_widget_fonts(self, widget: QWidget) -> None:
|
||||
'''
|
||||
Recursively update font sizes in all child widgets.
|
||||
|
||||
This handles widgets that have font-size hardcoded in their stylesheets.
|
||||
'''
|
||||
from . import _style
|
||||
|
||||
# recursively process all children
|
||||
for child in widget.findChildren(QWidget):
|
||||
# skip widgets that have their own update_fonts method (handled separately)
|
||||
if hasattr(child, 'update_fonts'):
|
||||
continue
|
||||
|
||||
# update child's stylesheet if it has font-size
|
||||
child_stylesheet = child.styleSheet()
|
||||
if child_stylesheet and 'font-size' in child_stylesheet:
|
||||
# for labels and simple widgets, regenerate stylesheet
|
||||
# this is a heuristic - may need refinement
|
||||
try:
|
||||
child.setFont(_style._font.font)
|
||||
except (AttributeError, RuntimeError):
|
||||
pass
|
||||
|
||||
# update child's font
|
||||
try:
|
||||
child.setFont(_style._font.font)
|
||||
except (AttributeError, RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
# singleton app per actor
|
||||
_qt_win: QMainWindow = None
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ from PyQt6.QtCore import (
|
|||
QSize,
|
||||
QModelIndex,
|
||||
QItemSelectionModel,
|
||||
QObject,
|
||||
pyqtBoundSignal,
|
||||
pyqtRemoveInputHook,
|
||||
QSettings,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
#!env xonsh
|
||||
'''
|
||||
Compute the pxs-per-inch (PPI) naively for the local DE.
|
||||
|
||||
NOTE, currently this only supports the `sway`-TWM on wayland.
|
||||
|
||||
!TODO!
|
||||
- [ ] support Xorg (and possibly other OSs as well?
|
||||
- [ ] conver this to pure py code, dropping the `.xsh` specifics
|
||||
instead for `subprocess` API calls?
|
||||
- [ ] possibly unify all this with `./qt_screen_info.py` as part of
|
||||
a "PPI config wizard" or something, but more then likely we'll
|
||||
have lib-ified version inside modden/piker by then?
|
||||
|
||||
'''
|
||||
|
||||
import math
|
||||
import json
|
||||
|
||||
# XXX, xonsh part using "subprocess mode"
|
||||
disp_infos: list[dict] = json.loads($(wlr-randr --json))
|
||||
lappy: dict = disp_infos[0]
|
||||
|
||||
dims: dict[str, int] = lappy['physical_size']
|
||||
w_cm: int = dims['width']
|
||||
h_cm: int = dims['height']
|
||||
|
||||
# cm per inch
|
||||
cpi: float = 25.4
|
||||
|
||||
# compute "diagonal" size (aka hypot)
|
||||
diag_inches: float = math.sqrt((h_cm/cpi)**2 + (w_cm/cpi)**2)
|
||||
|
||||
# compute reso-hypot / inches-hypot
|
||||
hi_res: dict[str, float|bool] = lappy['modes'][0]
|
||||
w_px: int = hi_res['width']
|
||||
h_px: int = hi_res['height']
|
||||
|
||||
diag_pxs: float = math.sqrt(h_px**2 + w_px**2)
|
||||
unscaled_ppi: float = diag_pxs/diag_inches
|
||||
|
||||
# retrieve TWM info on the display (including scaling info)
|
||||
sway_disp_info: dict = json.loads($(swaymsg -r -t get_outputs))[0]
|
||||
scale: float = sway_disp_info['scale']
|
||||
|
||||
print(
|
||||
f'output: {sway_disp_info["name"]!r}\n'
|
||||
f'--- DIMENSIONS ---\n'
|
||||
f'w_cm: {w_cm!r}\n'
|
||||
f'h_cm: {h_cm!r}\n'
|
||||
f'w_px: {w_px!r}\n'
|
||||
f'h_cm: {h_px!r}\n'
|
||||
f'\n'
|
||||
f'--- DIAGONALS ---\n'
|
||||
f'diag_inches: {diag_inches!r}\n'
|
||||
f'diag_pxs: {diag_pxs!r}\n'
|
||||
f'\n'
|
||||
f'--- PPI-related-info ---\n'
|
||||
f'(DE reported) scale: {scale!r}\n'
|
||||
f'unscaled PPI: {unscaled_ppi!r}\n'
|
||||
f'|_ =sqrt(h_px**2 + w_px**2) / sqrt(h_in**2 + w_in**2)\n'
|
||||
f'scaled PPI: {unscaled_ppi/scale!r}\n'
|
||||
f'|_ =unscaled_ppi/scale\n'
|
||||
)
|
||||
|
|
@ -31,8 +31,8 @@ Resource list for mucking with DPIs on multiple screens:
|
|||
- https://doc.qt.io/qt-5/qguiapplication.html#screenAt
|
||||
|
||||
'''
|
||||
import os
|
||||
|
||||
from pyqtgraph import QtGui
|
||||
from PyQt6 import (
|
||||
QtCore,
|
||||
QtWidgets,
|
||||
|
|
@ -43,6 +43,11 @@ from PyQt6.QtCore import (
|
|||
QSize,
|
||||
QRect,
|
||||
)
|
||||
from pyqtgraph import QtGui
|
||||
|
||||
|
||||
# https://doc.qt.io/qt-6/highdpi.html#environment-variable-reference
|
||||
os.environ['QT_USE_PHYSICAL_DPI'] = '1'
|
||||
|
||||
# Proper high DPI scaling is available in Qt >= 5.6.0. This attibute
|
||||
# must be set before creating the application
|
||||
|
|
@ -58,13 +63,22 @@ if hasattr(Qt, 'AA_UseHighDpiPixmaps'):
|
|||
True,
|
||||
)
|
||||
|
||||
# NOTE, inherits `QGuiApplication`
|
||||
# https://doc.qt.io/qt-6/qapplication.html
|
||||
# https://doc.qt.io/qt-6/qguiapplication.html
|
||||
app = QtWidgets.QApplication([])
|
||||
#
|
||||
# ^TODO? various global DPI settings?
|
||||
# [ ] DPI rounding policy,
|
||||
# - https://doc.qt.io/qt-6/qt.html#HighDpiScaleFactorRoundingPolicy-enum
|
||||
# - https://doc.qt.io/qt-6/qguiapplication.html#setHighDpiScaleFactorRoundingPolicy
|
||||
|
||||
window = QtWidgets.QMainWindow()
|
||||
main_widget = QtWidgets.QWidget()
|
||||
window.setCentralWidget(main_widget)
|
||||
window.show()
|
||||
|
||||
pxr: float = main_widget.devicePixelRatioF()
|
||||
_main_pxr: float = main_widget.devicePixelRatioF()
|
||||
|
||||
# explicitly get main widget and primary displays
|
||||
current_screen: QtGui.QScreen = app.screenAt(
|
||||
|
|
@ -77,7 +91,13 @@ for screen in app.screens():
|
|||
name: str = screen.name()
|
||||
model: str = screen.model().rstrip()
|
||||
size: QSize = screen.size()
|
||||
geo: QRect = screen.availableGeometry()
|
||||
geo: QRect = screen.geometry()
|
||||
|
||||
# device-pixel-ratio
|
||||
# https://doc.qt.io/qt-6/highdpi.html
|
||||
pxr: float = screen.devicePixelRatio()
|
||||
|
||||
unscaled_size: QSize = pxr * size
|
||||
phydpi: float = screen.physicalDotsPerInch()
|
||||
logdpi: float = screen.logicalDotsPerInch()
|
||||
is_primary: bool = screen is primary_screen
|
||||
|
|
@ -88,11 +108,12 @@ for screen in app.screens():
|
|||
f'|_primary: {is_primary}\n'
|
||||
f' _current: {is_current}\n'
|
||||
f' _model: {model}\n'
|
||||
f' _screen size: {size}\n'
|
||||
f' _screen geometry: {geo}\n'
|
||||
f' _devicePixelRationF(): {pxr}\n'
|
||||
f' _physical dpi: {phydpi}\n'
|
||||
f' _logical dpi: {logdpi}\n'
|
||||
f' _size: {size}\n'
|
||||
f' _geometry: {geo}\n'
|
||||
f' _devicePixelRatio(): {pxr}\n'
|
||||
f' _unscaled-size: {unscaled_size!r}\n'
|
||||
f' _physical-dpi: {phydpi}\n'
|
||||
f' _logical-dpi: {logdpi}\n'
|
||||
)
|
||||
|
||||
# app-wide font info
|
||||
|
|
@ -110,8 +131,8 @@ str_w: int = str_br.width()
|
|||
|
||||
print(
|
||||
f'------ global font settings ------\n'
|
||||
f'font dpi: {fontdpi}\n'
|
||||
f'font height: {font_h}\n'
|
||||
f'string bounding rect: {str_br}\n'
|
||||
f'string width : {str_w}\n'
|
||||
f'font dpi: {fontdpi!r}\n'
|
||||
f'font height: {font_h!r}\n'
|
||||
f'string bounding rect: {str_br!r}\n'
|
||||
f'string width : {str_w!r}\n'
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
import pytest
|
||||
from piker.ui._style import DpiAwareFont
|
||||
|
||||
|
||||
class MockScreen:
|
||||
def __init__(self, pdpi, ldpi, name="MockScreen"):
|
||||
self._pdpi = pdpi
|
||||
self._ldpi = ldpi
|
||||
self._name = name
|
||||
|
||||
def physicalDotsPerInch(self):
|
||||
return self._pdpi
|
||||
|
||||
def logicalDotsPerInch(self):
|
||||
return self._ldpi
|
||||
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pdpi, ldpi, expected_px",
|
||||
[
|
||||
(96, 96, 9), # normal DPI
|
||||
(169, 96, 15), # HiDPI
|
||||
(120, 96, 10), # mid-DPI
|
||||
]
|
||||
)
|
||||
def test_font_px_size(pdpi, ldpi, expected_px):
|
||||
font = DpiAwareFont()
|
||||
font.configure_to_dpi(screen=MockScreen(pdpi, ldpi))
|
||||
|
||||
px = font.px_size
|
||||
print(f"{pdpi}x{ldpi} DPI -> Computed pixel size: {px}")
|
||||
|
||||
assert px == expected_px
|
||||
Loading…
Reference in New Issue