saving status before scene frame fix after rust change

This commit is contained in:
2026-04-10 01:27:09 -03:00
parent 6f8f260b05
commit 6b6bc64ab8
6 changed files with 186 additions and 27 deletions

View File

@@ -46,6 +46,7 @@ class ChtWindow(Adw.ApplicationWindow):
self._pending_scrub_global = 0.0
self._scrub_pending = False # throttle flag for scrub updates
self._telemetry = None
self._threshold_timeout_id = None
# Core components
self._timeline = Timeline()
@@ -161,11 +162,23 @@ class ChtWindow(Adw.ApplicationWindow):
)
def _on_scene_threshold(self, val):
if self._lifecycle.stream_mgr and not self._lifecycle.stream_mgr.readonly:
old = self._lifecycle.stream_mgr.scene_threshold
self._lifecycle.stream_mgr.update_scene_threshold(val)
if self._telemetry:
self._telemetry.event("scene_threshold_changed", {"from": old, "to": val})
if not (self._lifecycle.stream_mgr and not self._lifecycle.stream_mgr.readonly):
return
if self._telemetry:
self._telemetry.event("scene_threshold_changed",
{"from": self._lifecycle.stream_mgr.scene_threshold, "to": val})
# Debounce: wait 500ms after user stops dragging, then restart in background.
if self._threshold_timeout_id:
GLib.source_remove(self._threshold_timeout_id)
self._threshold_timeout_id = GLib.timeout_add(500, self._apply_threshold, val)
def _apply_threshold(self, val):
self._threshold_timeout_id = None
mgr = self._lifecycle.stream_mgr
if mgr and not mgr.readonly:
Thread(target=mgr.update_scene_threshold, args=(val,),
daemon=True, name="threshold_update").start()
return False # don't repeat
def _on_min_chunk_changed(self, panel, val):
import cht.config
@@ -247,6 +260,9 @@ class ChtWindow(Adw.ApplicationWindow):
self._update_scrub_bar_manifest()
self._populate_model_dropdown()
# Show "Continue" since there's an active session to resume
self._connect_btn.set_label("Continue")
# Load persisted agent conversation
self._agent.load_from_session(mgr.session_dir)
if self._agent.thread.messages:
@@ -263,8 +279,11 @@ class ChtWindow(Adw.ApplicationWindow):
audio_dir = mgr.audio_dir
audio_dir.mkdir(parents=True, exist_ok=True)
full_wav = audio_dir / "full.wav"
# Rust transport writes audio to a separate file (fMP4 has no audio track).
aac_path = mgr.stream_dir / "audio.aac"
source = aac_path if aac_path.exists() else segments[0]
try:
ff.extract_audio_chunk(segments[0], full_wav)
ff.extract_audio_chunk(source, full_wav)
self._waveform_engine.compute_full(full_wav)
peaks = self._waveform_engine.peaks
bucket_dur = self._waveform_engine.bucket_duration
@@ -483,8 +502,18 @@ class ChtWindow(Adw.ApplicationWindow):
if self._proxy_mgr:
self._proxy_mgr.cancel()
self._proxy_mgr = None
self._manifest = []
self._connect_btn.set_label("Connect")
self._connect_btn.remove_css_class("destructive-action")
self._connect_btn.add_css_class("suggested-action")
if reload_session and last_session_id:
# Transition to review mode — _load_session handles UI setup
self._load_session(last_session_id)
return
# Full reset — only when not reloading
self._manifest = []
self._timeline.reset()
self._timeline_controls.scrub_bar.set_manifest([])
self._monitor.reset()
@@ -493,18 +522,10 @@ class ChtWindow(Adw.ApplicationWindow):
self._transcriber.reset()
self._agent.clear_history()
self._known_frames = set()
self._frames_panel.clear()
self._transcript_panel.clear()
self._connect_btn.set_label("Connect")
self._connect_btn.remove_css_class("destructive-action")
self._connect_btn.add_css_class("suggested-action")
self.set_title(APP_NAME)
if reload_session and last_session_id:
GLib.idle_add(self._load_session, last_session_id)
def _on_close(self, *args):
self.teardown()