Skip to content

Commit ec8fa8c

Browse files
unhappychoiceclaude
andcommitted
refactor: update imports and references for TUI architecture
- Update all imports from presentation::game to presentation::tui - Update references to Screen, ScreenManager, and ScreenType - Update signal handler and main.rs for new TUI structure - Update game module to use tui module 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8062a54 commit ec8fa8c

File tree

18 files changed

+37
-31
lines changed

18 files changed

+37
-31
lines changed

benches/challenge_generator_bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use gittype::domain::models::{CodeChunk, ExtractionOptions, Languages};
33
use gittype::domain::services::challenge_generator::ChallengeGenerator;
44
use gittype::domain::services::source_code_parser::SourceCodeParser;
55
use gittype::presentation::game::models::StepType;
6-
use gittype::presentation::game::screens::loading_screen::ProgressReporter;
6+
use gittype::presentation::tui::screens::loading_screen::ProgressReporter;
77
use std::path::PathBuf;
88
use std::sync::{Arc, Mutex};
99

src/domain/repositories/challenge_repository.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::domain::models::{Challenge, DifficultyLevel, GitRepository};
22
use crate::infrastructure::storage::compressed_file_storage::CompressedFileStorage;
33
use crate::presentation::game::models::StepType;
4-
use crate::presentation::game::screens::loading_screen::ProgressReporter;
4+
use crate::presentation::tui::screens::loading_screen::ProgressReporter;
55
use rayon::prelude::*;
66
use std::fs;
77
use std::path::PathBuf;

src/domain/services/challenge_generator/challenge_generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::{
33
progress_tracker::ProgressTracker,
44
};
55
use crate::domain::models::{Challenge, CodeChunk, DifficultyLevel};
6-
use crate::presentation::game::screens::loading_screen::ProgressReporter;
6+
use crate::presentation::tui::screens::loading_screen::ProgressReporter;
77
use rayon::prelude::*;
88

99
/// Main orchestrator for converting CodeChunks into Challenges

src/domain/services/challenge_generator/progress_tracker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::presentation::game::models::StepType;
2-
use crate::presentation::game::screens::loading_screen::ProgressReporter;
2+
use crate::presentation::tui::screens::loading_screen::ProgressReporter;
33
use std::sync::{
44
atomic::{AtomicUsize, Ordering},
55
Arc,

src/domain/services/source_code_parser/source_code_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::domain::services::source_code_parser::parsers::parse_with_thread_loca
44
use crate::domain::services::source_code_parser::ChunkExtractor;
55
use crate::infrastructure::git::LocalGitRepositoryClient;
66
use crate::presentation::game::models::StepType;
7-
use crate::presentation::game::screens::loading_screen::ProgressReporter;
7+
use crate::presentation::tui::screens::loading_screen::ProgressReporter;
88
use crate::{GitTypeError, Result};
99
use rayon::prelude::*;
1010
use std::fs;

src/domain/services/source_file_extractor/source_file_extractor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::domain::models::{ExtractionOptions, Languages};
22
use crate::infrastructure::storage::file_storage::FileStorage;
33
use crate::presentation::game::models::StepType;
4-
use crate::presentation::game::screens::loading_screen::ProgressReporter;
4+
use crate::presentation::tui::screens::loading_screen::ProgressReporter;
55
use crate::Result;
66
use std::path::{Path, PathBuf};
77

src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ use clap::Parser;
22
use gittype::infrastructure::logging::log_error_to_file;
33
use gittype::presentation::cli::{run_cli, Cli};
44

5-
#[tokio::main]
6-
async fn main() -> anyhow::Result<()> {
5+
fn main() -> anyhow::Result<()> {
76
let cli = Cli::parse();
87

9-
if let Err(e) = run_cli(cli).await {
8+
if let Err(e) = run_cli(cli) {
109
log_error_to_file(&e);
1110
return Err(e.into());
1211
}

src/presentation/cli/commands/game.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use crate::domain::services::version_service::VersionService;
66
use crate::infrastructure::logging;
77
use crate::presentation::cli::args::Cli;
88
use crate::presentation::game::models::ScreenType;
9-
use crate::presentation::game::screen_manager::ScreenManager;
10-
use crate::presentation::game::screens::{VersionCheckResult, VersionCheckScreen};
9+
use crate::presentation::tui::screen_manager::ScreenManager;
10+
use crate::presentation::tui::screens::{VersionCheckResult, VersionCheckScreen};
1111
use crate::presentation::game::{GameData, SessionManager};
1212
use crate::presentation::signal_handler::setup_signal_handlers;
1313
use crate::{GitTypeError, Result};
@@ -21,8 +21,10 @@ pub fn run_game_session(cli: Cli) -> Result<()> {
2121
let event_bus = EventBus::new();
2222

2323
// Check for updates before starting the game session
24-
let should_exit = tokio::task::block_in_place(|| {
25-
tokio::runtime::Handle::current().block_on(async {
24+
let should_exit = {
25+
let rt = tokio::runtime::Runtime::new()
26+
.map_err(|e| GitTypeError::TerminalError(format!("Failed to create tokio runtime: {}", e)))?;
27+
rt.block_on(async {
2628
let version_service = VersionService::new()?;
2729
if let Ok((has_update, current_version, latest_version)) = version_service.check().await
2830
{
@@ -35,7 +37,7 @@ pub fn run_game_session(cli: Cli) -> Result<()> {
3537
}
3638
Ok(false)
3739
})
38-
})?;
40+
}?;
3941

4042
if should_exit {
4143
log::info!("User exited after update notification");

src/presentation/game/events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::any::Any;
22

33
// Re-export ScreenTransition as NavigateTo event
4-
pub use super::models::screen::ScreenTransition as NavigateTo;
4+
pub use crate::presentation::tui::ScreenTransition as NavigateTo;
55

66
/// Event emitted when user requests to exit the application (Ctrl+C)
77
#[derive(Clone, Debug)]

src/presentation/game/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ pub mod game_data;
66
pub mod models;
77
pub mod rank_colors;
88
pub mod rank_messages;
9-
pub mod screen_manager;
10-
pub mod screen_transition_manager;
11-
pub mod screens;
129
pub mod session_manager;
1310
pub mod stage_repository;
1411
pub mod text_processor;
1512
pub mod typing_core;
16-
pub mod views;
1713

1814
pub use game_data::GameData;
19-
pub use models::{Screen, ScreenDataProvider, ScreenTransition, ScreenType, UpdateStrategy};
20-
pub use screen_manager::ScreenManager;
21-
pub use screens::TypingScreen;
15+
pub use models::ScreenDataProvider;
2216
pub use session_manager::{SessionConfig, SessionManager, SessionState};
2317
pub use stage_repository::{GameMode, StageConfig, StageRepository};
18+
19+
// Re-export from tui module for backward compatibility
20+
pub use crate::presentation::tui::{
21+
Screen, ScreenManager, ScreenTransition, ScreenTransitionManager, ScreenType, UpdateStrategy,
22+
};
23+
pub use crate::presentation::tui::screens::TypingScreen;
24+
pub use crate::presentation::tui::views;

0 commit comments

Comments
 (0)