libtmux
libtmux copied to clipboard
`Pane.capture_pane` helpers
Changes
feat: Add test_snapshot
Test plan
Coverage
uv run pytest --cov=libtmux.snapshot tests/test_snapshot.py -v
Automatic
Summary by Sourcery
Introduce snapshot and recording functionality for tmux panes. This allows capturing and analyzing pane content and metadata at various points in time. Add tests to verify the correctness of the new features.
New Features:
- Introduce
Pane.snapshot()to create a snapshot of the pane's current state. - Introduce
Pane.record()to create a recording of pane snapshots. - Add
PaneSnapshotclass to store pane content and metadata. - Add
PaneRecordingclass to manage a time-series of pane snapshots. - Add
test_snapshotto test the snapshot functionality and ensure correctness of capturing pane content and metadata. - Add
test_pane_recordingto test the recording functionality, including adding snapshots, iterating through them, and filtering by time.
Tests:
- Add tests for snapshot and recording functionality.
Reviewer's Guide by Sourcery
This pull request introduces snapshot and recording functionality for tmux panes. It adds PaneSnapshot and PaneRecording classes, along with corresponding methods in the Pane class, to facilitate capturing and managing pane states for testing and debugging.
Sequence diagram for creating a PaneSnapshot
sequenceDiagram
participant User
participant Pane
participant PaneSnapshot
User->>Pane: snapshot(start, end)
Pane->>PaneSnapshot: from_pane(self, start, end)
activate PaneSnapshot
PaneSnapshot-->>Pane: PaneSnapshot instance
deactivate PaneSnapshot
Pane-->>User: PaneSnapshot instance
Sequence diagram for creating a PaneRecording and adding a snapshot
sequenceDiagram
participant User
participant Pane
participant PaneRecording
participant PaneSnapshot
User->>Pane: record()
Pane->>PaneRecording: PaneRecording()
activate PaneRecording
PaneRecording-->>Pane: PaneRecording instance
deactivate PaneRecording
User->>PaneRecording: add_snapshot(pane, start, end)
PaneRecording->>Pane: snapshot(start, end)
Pane->>PaneSnapshot: from_pane(self, start, end)
activate PaneSnapshot
PaneSnapshot-->>Pane: PaneSnapshot instance
deactivate PaneSnapshot
Pane->>PaneRecording: append(PaneSnapshot)
PaneRecording-->>User: void
Updated class diagram for Pane, PaneSnapshot, and PaneRecording
classDiagram
class Pane {
+capture_pane()
+snapshot()
+record()
}
class PaneSnapshot {
+content: list[str]
+timestamp: datetime
+pane_id: str
+window_id: str
+session_id: str
+server_name: str
+metadata: dict[str, str]
+from_pane()
+content_str
}
class PaneRecording {
+snapshots: list[PaneSnapshot]
+add_snapshot()
+latest
+get_snapshots_between()
}
Pane -- PaneSnapshot : creates
Pane -- PaneRecording : creates
PaneRecording -- PaneSnapshot : contains
File-Level Changes
| Change | Details | Files |
|---|---|---|
Introduces PaneSnapshot and PaneRecording classes for capturing and recording pane states. |
|
src/libtmux/snapshot.pytests/test_snapshot.py |
Adds snapshot and record methods to the Pane class. |
|
src/libtmux/pane.py |
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment@sourcery-ai reviewto trigger a new review! - Generate a plan of action for an issue: Comment
@sourcery-ai planon an issue to generate a plan of action for it.
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
Codecov Report
Attention: Patch coverage is 99.03846% with 2 lines in your changes missing coverage. Please review.
Project coverage is 89.27%. Comparing base (
92660e4) to head (734d41a).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/libtmux/snapshot.py | 97.01% | 1 Missing and 1 partial :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## context-managers #568 +/- ##
====================================================
+ Coverage 88.84% 89.27% +0.42%
====================================================
Files 36 38 +2
Lines 4080 4288 +208
Branches 376 378 +2
====================================================
+ Hits 3625 3828 +203
- Misses 310 313 +3
- Partials 145 147 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.