Commit fc96631
committed
fix: run work-metrics update on every transform pass
The initial work-metrics integration (commit fbfbc5a) gated the
computeOpenCodeWorkMetrics + setSessionWorkMetrics call on
workExecutedSuccessfully (OpenCode) and result.executedWorkThisPass (Pi).
That gate is overly conservative: the work-metrics update is a pure DB
read on the OpenCode message table plus a pure DB write to session_meta.
It does not mutate any tag state, does not rewrite message[0], and is
cache-stable.
Net effect of the bug: sessions sitting below the execute threshold
(default 65%) never see populated new_work_tokens / total_input_tokens
columns, so the TUI sidebar Stats section shows 0/0/0 for any session
that hasn't crossed threshold yet. For long-running but low-pressure
work this is essentially permanent.
Fix moves the work-metrics update out of the executedWorkSuccessfully
branch and runs it on every transform pass. Both OpenCode and Pi paths
updated symmetrically.
Verified:
- packages/plugin: typecheck clean, work-metrics.test.ts 6/6 pass
(including live AFT smoke target)
- packages/pi-plugin: typecheck clean, work-metrics-pi.test.ts 1/1 pass
- Both dist bundles rebuilt1 parent 3e4a147 commit fc96631
2 files changed
Lines changed: 40 additions & 29 deletions
File tree
- packages
- pi-plugin/src
- plugin/src/hooks/magic-context
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1827 | 1827 | | |
1828 | 1828 | | |
1829 | 1829 | | |
1830 | | - | |
1831 | | - | |
1832 | | - | |
1833 | | - | |
1834 | | - | |
1835 | | - | |
1836 | | - | |
1837 | | - | |
1838 | | - | |
1839 | | - | |
1840 | | - | |
1841 | | - | |
1842 | | - | |
1843 | | - | |
1844 | | - | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
1845 | 1850 | | |
1846 | 1851 | | |
1847 | 1852 | | |
| |||
Lines changed: 20 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
960 | 960 | | |
961 | 961 | | |
962 | 962 | | |
963 | | - | |
964 | | - | |
965 | | - | |
966 | | - | |
967 | | - | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | | - | |
976 | | - | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
977 | 982 | | |
| 983 | + | |
978 | 984 | | |
979 | 985 | | |
980 | 986 | | |
| |||
0 commit comments