Commit c310f05
feat: add /codex:attach command for live log streaming
Adds a new `attach` subcommand to codex-companion.mjs and a matching
`/codex:attach` command definition.
**Problem:** Background Codex jobs (`/codex:rescue --background`) produce
no live output. The only way to observe progress is to poll `/codex:status`
or wait for `/codex:result` after completion — a blind black-box experience.
**Solution:** `/codex:attach [job-id]` tails the job's on-disk log file in
real time and exits cleanly when the job reaches a terminal status
(completed, failed, cancelled). If no job ID is given, it automatically
attaches to the most recent active job.
Implementation details:
- New `handleAttach()` async function in codex-companion.mjs
- Reads the job log file path from `job.logFile` (falls back to
`resolveJobLogFile` if missing)
- Polls for new log content every 500ms (configurable via
`--poll-interval-ms`)
- Simultaneously polls job state via `listJobs()` for terminal status
- Final log flush + closing line on exit
- No new dependencies; uses existing state/job-control infrastructure
- Does not modify any existing commands or behaviour
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 807e03a commit c310f05
2 files changed
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
837 | 838 | | |
838 | 839 | | |
839 | 840 | | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
840 | 897 | | |
841 | 898 | | |
842 | 899 | | |
| |||
1015 | 1072 | | |
1016 | 1073 | | |
1017 | 1074 | | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
1018 | 1078 | | |
1019 | 1079 | | |
1020 | 1080 | | |
| |||
0 commit comments