Skip to content

Commit 173ab1b

Browse files
abrichrclaude
andcommitted
fix(cli): update capture commands to use real openadapt-capture API
The capture start/list commands were using a fictional API (CaptureSession(name=...) and load_capture()) that doesn't exist in openadapt-capture. Updated to use the actual API: - capture start: Use Recorder context manager with proper params - capture list: Use Capture.load() to validate and display captures - Removed transcribe flag (not supported in current capture) - Added --video/--no-video flag Fixes: TypeError: CaptureSession.__init__() got an unexpected keyword argument 'name' Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 190361f commit 173ab1b

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

openadapt/cli.py

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -62,36 +62,38 @@ def capture():
6262

6363
@capture.command("start")
6464
@click.option("--name", "-n", required=True, help="Name for the capture session")
65-
@click.option("--audio/--no-audio", default=True, help="Record audio")
66-
@click.option("--transcribe/--no-transcribe", default=True, help="Transcribe audio")
67-
def capture_start(name: str, audio: bool, transcribe: bool):
65+
@click.option("--video/--no-video", default=True, help="Record video")
66+
@click.option("--audio/--no-audio", default=False, help="Record audio")
67+
def capture_start(name: str, video: bool, audio: bool):
6868
"""Start a new capture session."""
6969
try:
70-
from openadapt_capture import CaptureSession
70+
from openadapt_capture import Recorder
7171

7272
click.echo(f"Starting capture session: {name}")
73-
click.echo("Press Ctrl+C to stop recording...")
74-
75-
session = CaptureSession(
76-
name=name,
77-
record_audio=audio,
78-
transcribe=transcribe,
79-
)
80-
session.start()
81-
82-
# Wait for keyboard interrupt
83-
import signal
84-
85-
signal.pause()
73+
click.echo("Press Ctrl+C (or Ctrl x3) to stop recording...")
74+
75+
with Recorder(
76+
f"./{name}",
77+
task_description=name,
78+
capture_video=video,
79+
capture_audio=audio,
80+
) as recorder:
81+
recorder.wait_for_ready()
82+
click.echo("Recording...")
83+
try:
84+
while recorder.is_recording:
85+
import time
86+
87+
time.sleep(1)
88+
except KeyboardInterrupt:
89+
pass
90+
91+
click.echo(f"\nCapture saved: ./{name}/ ({recorder.event_count} events)")
8692

8793
except ImportError:
8894
click.echo("Error: openadapt-capture not installed.", err=True)
8995
click.echo("Install with: pip install openadapt-capture", err=True)
9096
sys.exit(1)
91-
except KeyboardInterrupt:
92-
click.echo("\nStopping capture...")
93-
session.stop()
94-
click.echo(f"Capture saved: {name}")
9597

9698

9799
@capture.command("stop")
@@ -109,14 +111,17 @@ def capture_list(path: str):
109111
try:
110112
from pathlib import Path
111113

112-
from openadapt_capture import load_capture
114+
from openadapt_capture import Capture
113115

114116
captures_found = 0
115-
for capture_dir in Path(path).iterdir():
116-
if capture_dir.is_dir():
117+
for capture_dir in sorted(Path(path).iterdir()):
118+
if capture_dir.is_dir() and (capture_dir / "recording.db").exists():
117119
try:
118-
load_capture(str(capture_dir)) # Validate it's a capture
119-
click.echo(f" {capture_dir.name}")
120+
cap = Capture.load(str(capture_dir))
121+
desc = cap.task_description or ""
122+
n_actions = sum(1 for _ in cap.actions())
123+
cap.close()
124+
click.echo(f" {capture_dir.name} ({n_actions} actions) {desc}")
120125
captures_found += 1
121126
except Exception:
122127
continue

0 commit comments

Comments
 (0)