@@ -467,11 +467,8 @@ pub async fn start_development_mode(
467467 settings : & Settings ,
468468 enable_mcp : bool ,
469469) -> anyhow:: Result < ( ) > {
470- // Set global flag so ensure_typescript_compiled knows to skip
471- // (tspc --watch handles compilation in dev mode)
472470 use crate :: utilities:: constants:: IS_DEV_MODE ;
473471 use std:: sync:: atomic:: Ordering ;
474- IS_DEV_MODE . store ( true , Ordering :: Relaxed ) ;
475472
476473 display:: show_message_wrapper (
477474 MessageType :: Info ,
@@ -515,8 +512,29 @@ pub async fn start_development_mode(
515512 // For TypeScript, initial compilation is required (no ts-node fallback). Fail fast if it fails.
516513 let ts_compile_handle = if project. language == SupportedLanguages :: Typescript {
517514 use crate :: cli:: ts_compilation_watcher:: spawn_and_await_initial_compile;
515+ use crate :: framework:: typescript:: parser:: ensure_typescript_compiled;
518516 match spawn_and_await_initial_compile ( & project) . await {
519- Ok ( handle) => Some ( handle) ,
517+ Ok ( Some ( handle) ) => {
518+ // tspc --watch is working; set IS_DEV_MODE so ensure_typescript_compiled
519+ // is a no-op (tspc --watch handles compilation going forward)
520+ IS_DEV_MODE . store ( true , Ordering :: Relaxed ) ;
521+ Some ( handle)
522+ }
523+ Ok ( None ) => {
524+ // Old moose-tspc without --watch support: run single compilation,
525+ // then use FileWatcher for watching changes
526+ warn ! ( "moose-tspc does not support --watch; using file watcher fallback" ) ;
527+ display:: show_message_wrapper (
528+ MessageType :: Highlight ,
529+ Message {
530+ action : "Fallback" . to_string ( ) ,
531+ details : "moose-tspc does not support --watch; using file watcher"
532+ . to_string ( ) ,
533+ } ,
534+ ) ;
535+ ensure_typescript_compiled ( & project) ?;
536+ None
537+ }
520538 Err ( e) => {
521539 error ! ( "Initial TypeScript compilation failed: {}" , e) ;
522540 display:: show_message_wrapper (
@@ -739,44 +757,38 @@ pub async fn start_development_mode(
739757 // Create shutdown channel for graceful watcher termination
740758 let ( watcher_shutdown_tx, watcher_shutdown_rx) = tokio:: sync:: watch:: channel ( false ) ;
741759
742- // Use TypeScript compilation watcher for TS projects (incremental compilation)
743- // Use file watcher for Python projects
760+ // Use TypeScript compilation watcher when tspc --watch is available (ts_compile_handle is Some),
761+ // otherwise use file watcher ( Python projects, or TypeScript with old moose-tspc)
744762 let state_storage = Arc :: new ( state_storage) ;
745- match project. language {
746- SupportedLanguages :: Typescript => {
747- // Pass the handle from spawn_and_await_initial_compile() if we have one.
748- // This continues watching the already-running tspc process instead of
749- // spawning a new one, and ensures we don't trigger duplicate plan_changes.
750- let ts_watcher = TsCompilationWatcher :: new ( ) ;
751- ts_watcher. start (
752- project. clone ( ) ,
753- route_update_channel,
754- webapp_update_channel,
755- infra_map,
756- process_registry. clone ( ) ,
757- metrics. clone ( ) ,
758- state_storage,
759- settings. clone ( ) ,
760- processing_coordinator. clone ( ) ,
761- watcher_shutdown_rx,
762- ts_compile_handle,
763- ) ?;
764- }
765- SupportedLanguages :: Python => {
766- let file_watcher = FileWatcher :: new ( ) ;
767- file_watcher. start (
768- project. clone ( ) ,
769- route_update_channel,
770- webapp_update_channel,
771- infra_map,
772- process_registry. clone ( ) ,
773- metrics. clone ( ) ,
774- state_storage,
775- settings. clone ( ) ,
776- processing_coordinator. clone ( ) ,
777- watcher_shutdown_rx,
778- ) ?;
779- }
763+ if let Some ( handle) = ts_compile_handle {
764+ let ts_watcher = TsCompilationWatcher :: new ( ) ;
765+ ts_watcher. start (
766+ project. clone ( ) ,
767+ route_update_channel,
768+ webapp_update_channel,
769+ infra_map,
770+ process_registry. clone ( ) ,
771+ metrics. clone ( ) ,
772+ state_storage,
773+ settings. clone ( ) ,
774+ processing_coordinator. clone ( ) ,
775+ watcher_shutdown_rx,
776+ Some ( handle) ,
777+ ) ?;
778+ } else {
779+ let file_watcher = FileWatcher :: new ( ) ;
780+ file_watcher. start (
781+ project. clone ( ) ,
782+ route_update_channel,
783+ webapp_update_channel,
784+ infra_map,
785+ process_registry. clone ( ) ,
786+ metrics. clone ( ) ,
787+ state_storage,
788+ settings. clone ( ) ,
789+ processing_coordinator. clone ( ) ,
790+ watcher_shutdown_rx,
791+ ) ?;
780792 }
781793
782794 // Log MCP server status
0 commit comments