Skip to content

Simplify CLI Preload Document Path#121

Merged
SSobol77 merged 1 commit into
mainfrom
chore/cleanup-preload-cli-document
Jul 7, 2026
Merged

Simplify CLI Preload Document Path#121
SSobol77 merged 1 commit into
mainfrom
chore/cleanup-preload-cli-document

Conversation

@SSobol77

@SSobol77 SSobol77 commented Jul 7, 2026

Copy link
Copy Markdown
Owner

This PR removes dead fallback/probe logic from Ecli.preload_cli_document and delegates explicitly through open_or_create.

Changes:

  • simplifies preload_cli_document to a deterministic single path
  • removes unreachable method-name probe fallbacks
  • avoids TypeError-swallowing fallback paths
  • preserves existing-file preload behavior
  • preserves nonexistent-file clean-buffer behavior
  • keeps no-disk-touch-before-save semantics

Validation:

  • make clean-logs
  • uv run ruff check src tests
  • uv run ruff format --check src tests
  • uv run python scripts/check_runtime_imports.py
  • uv run pytest -q tests/core
  • uv run pytest -q tests/cli
  • uv run pytest -q tests/ui
  • uv run pytest -q tests/utils tests/core tests/extensions tests/packaging tests/docs

Manual smoke:

  • real PTY run with /tmp/ecli-preload-cleanup-new-file.py
  • file did not exist before save
  • file was created only after Ctrl+S
  • logs contained no Traceback, TypeError, logging error, CRITICAL, or ERROR

Non-goals:

  • no runtime UX behavior changes
  • no packaging contract changes
  • no docs changes
  • no F7/F10/F11/TextMate changes
  • no main.py wrapper cleanup in this PR

Summary by CodeRabbit

  • Bug Fixes
    • Simplified CLI document preloading so opening a path now behaves consistently and no longer probes multiple fallback methods.
    • Prevented nonexistent files from being created on disk during preload; they now open as a clean, empty buffer and are only created when saved.
    • Improved reliability for existing files by ensuring their content loads correctly and the file state stays unmodified.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The preload_cli_document method in Ecli.py was simplified to resolve the target path and delegate directly to open_or_create, removing prior reflection-based fallback logic and disk pre-creation via touch(). New regression tests validate loading behavior for existing and nonexistent paths.

Changes

Preload delegation simplification

Layer / File(s) Summary
Simplify preload_cli_document implementation
src/ecli/core/Ecli.py
preload_cli_document resolves the intended path and calls open_or_create directly, removing fallback probing methods and the disk-touch fallback.
Regression tests for preload behavior
tests/core/test_file_open_safety.py
New tests verify content loading for existing files, clean empty buffer for nonexistent paths without disk creation, correct filename assignment, absence of TypeError/traceback logs, and correct file creation on save_file() after preload.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Test
  participant Ecli
  participant OpenOrCreate
  participant Filesystem

  Test->>Ecli: preload_cli_document(path)
  Ecli->>Ecli: resolve intended path
  Ecli->>OpenOrCreate: open_or_create(intended)
  alt file exists
    OpenOrCreate->>Filesystem: read content
    Filesystem-->>OpenOrCreate: file content
    OpenOrCreate-->>Ecli: loaded buffer, modified=False
  else file missing
    OpenOrCreate-->>Ecli: empty buffer, modified=False
  end
  Test->>Ecli: save_file()
  Ecli->>Filesystem: write content
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: simplifying CLI preload document handling and routing it through a single path.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/cleanup-preload-cli-document

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/ecli/core/Ecli.py (1)

787-802: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Drop the unused _cli_intended_path field
preload_cli_document() is the only place that sets _cli_intended_path, and nothing reads it elsewhere. open_or_create() already sets current_file_path/file_path/filename to the same resolved path, so this is dead state.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/ecli/core/Ecli.py` around lines 787 - 802, The `_cli_intended_path` state
in `Ecli.preload_cli_document()` is dead and should be removed. Delete the
assignment in `preload_cli_document()` and remove the unused field from `Ecli`
if it is declared elsewhere, since `open_or_create()` already sets the active
path fields (`current_file_path`, `file_path`, `filename`) to the resolved path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/ecli/core/Ecli.py`:
- Around line 787-802: The `_cli_intended_path` state in
`Ecli.preload_cli_document()` is dead and should be removed. Delete the
assignment in `preload_cli_document()` and remove the unused field from `Ecli`
if it is declared elsewhere, since `open_or_create()` already sets the active
path fields (`current_file_path`, `file_path`, `filename`) to the resolved path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bd32ec53-dcb9-4a18-a2a4-e6386aef9aa3

📥 Commits

Reviewing files that changed from the base of the PR and between a3ea904 and 3067989.

📒 Files selected for processing (2)
  • src/ecli/core/Ecli.py
  • tests/core/test_file_open_safety.py

@SSobol77 SSobol77 merged commit 009283f into main Jul 7, 2026
7 checks passed
@SSobol77 SSobol77 deleted the chore/cleanup-preload-cli-document branch July 7, 2026 22:33
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.

1 participant