Skip to content

fix: resolve kernel singleton issues and implement 'j' command direct…#27

Merged
AkshajSinghal merged 2 commits into
TruFoundation:mainfrom
ElianThorne:elian-bug-fixes
Jun 6, 2026
Merged

fix: resolve kernel singleton issues and implement 'j' command direct…#27
AkshajSinghal merged 2 commits into
TruFoundation:mainfrom
ElianThorne:elian-bug-fixes

Conversation

@ElianThorne
Copy link
Copy Markdown
Contributor

Screenshot 2026-06-06 134207
  • Removed module-level TruKernel instantiation in cli.py to prevent multiple kernel instances.
  • Updated app_with_lower() and run_interactive_shell() to use get_kernel() singleton.
  • Implemented TRUSHELL_CD sentinel handling in TruKernel._execute_entry().
  • Added os.chdir() logic to actually change the REPL working directory when 'j' returns a path.
  • Added tests/test_trukernel.py to verify sentinel parsing and directory changes.
  • Fixed PYTHONPATH issues in test execution.

Resolves issues with 'j' command printing raw sentinel strings and failing to navigate.

@exlier
Copy link
Copy Markdown
Contributor

exlier commented Jun 6, 2026

Nice idea man, we gotta fix some issues before we go any further. I'll do the same

@AkshajSinghal
Copy link
Copy Markdown
Collaborator

Well done

@AkshajSinghal AkshajSinghal merged commit 78a6bea into TruFoundation:main Jun 6, 2026
3 checks passed
exlier added a commit to exlier/TruShell that referenced this pull request Jun 6, 2026
Process Management (Issue TruFoundation#11):
- Wrapped _run_external_command polling loop in try/finally block
- Ensures process.wait() is called in finally block to prevent zombie processes
- Gracefully handles psutil exceptions without losing process cleanup

UI/UX Improvements (Issues TruFoundation#12, TruFoundation#13):
- Fixed argv mutation in app_with_lower() - now creates sys.argv.copy() instead of mutating global
- Fixed Windows emoji crash in _prompt_command() - added try/except for UnicodeEncodeError
- Fallback to plain ASCII 'trushell> ' prompt when UTF-8 emojis fail on limited terminals

Readline & History Support (Issue TruFoundation#22):
- Added prompt_toolkit>=3.0.0 to dependencies in pyproject.toml
- Replaced input() with toolkit_prompt() in _prompt_command()
- Enables command history and tab completion on all platforms

Settings Data Integrity (Issue TruFoundation#15):
- Implemented dirty_settings dict to track all setting changes
- Added watch_value() handlers on Input/Select/Switch widgets
- _save_settings() now safely persists all changes without querying unmounted widgets
- Prevents data loss when switching categories without saving

Help System Enhancements (Issues TruFoundation#25, TruFoundation#27):
- run_help() now accepts command name argument
- Shows specific command docstrings when 'help <command>' is used
- Fixed typo in help text: 'showtask' → 'showtasks'
- Updated help message to indicate 'help <command>' is now available
AkshajSinghal added a commit that referenced this pull request Jun 6, 2026
* fix: resolve critical windows compatibility and core stability issues

* testcommit

* fix: resolve infinite recursion in database initialization and implement security hardening

Database Layer (Issue #24):
- Refactored _ensure_initialized() to use direct sqlite3.connect() instead of get_db_connection()
- Added global _INITIALIZED flag to prevent redundant table creation
- Separated _get_db_path() function to avoid circular dependencies
- Resolves RecursionError during shell startup or first DB access

OS Passthrough Security (Issue #19):
- Added 'import shlex' for safe command parsing
- Replaced subprocess.run(shell=True) with subprocess.run(shlex.split(), shell=False)
- Added validation to block pipes (|) and redirects (>, <) before execution
- Prevents shell injection vulnerabilities

Plugin System (Issue #10):
- Added @classmethod reset() to PluginManager for singleton reset during testing
- Created tests/conftest.py with autouse fixture for proper test isolation

Configuration Cleanup (Issue #6):
- Removed broken theme_engine plugin reference from plugins.md (path doesn't exist)

* polish: improve UI, fix process management, and enhance help system

Process Management (Issue #11):
- Wrapped _run_external_command polling loop in try/finally block
- Ensures process.wait() is called in finally block to prevent zombie processes
- Gracefully handles psutil exceptions without losing process cleanup

UI/UX Improvements (Issues #12, #13):
- Fixed argv mutation in app_with_lower() - now creates sys.argv.copy() instead of mutating global
- Fixed Windows emoji crash in _prompt_command() - added try/except for UnicodeEncodeError
- Fallback to plain ASCII 'trushell> ' prompt when UTF-8 emojis fail on limited terminals

Readline & History Support (Issue #22):
- Added prompt_toolkit>=3.0.0 to dependencies in pyproject.toml
- Replaced input() with toolkit_prompt() in _prompt_command()
- Enables command history and tab completion on all platforms

Settings Data Integrity (Issue #15):
- Implemented dirty_settings dict to track all setting changes
- Added watch_value() handlers on Input/Select/Switch widgets
- _save_settings() now safely persists all changes without querying unmounted widgets
- Prevents data loss when switching categories without saving

Help System Enhancements (Issues #25, #27):
- run_help() now accepts command name argument
- Shows specific command docstrings when 'help <command>' is used
- Fixed typo in help text: 'showtask' → 'showtasks'
- Updated help message to indicate 'help <command>' is now available

---------

Co-authored-by: Akshaj Singhal <85437940+AkshajSinghal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants