feat(iterm2): add tab-level notification and click-to-restore#9
Conversation
- capture iterm2 session id at init for tab identity tracking - detect tab switches in same window via session id comparison - extend click-to-focus to restore original iterm2 tab via applescript - preserve iterm2 session id through deduplication file rewrites - add tests for init capture, tab-switch detection, focus command
- mention iterm2 tab restore in readme features and how-it-works - document iterm2 session id in session file format - update context flows for init/notify with iterm2 tab tracking - sync test context count to 70 tests (61 core + 9 integration)
- collapse conditional save_window_id call into single unconditional call - fix applescript string quoting to use consistent single-quoted style - collapse multi-line escaped_session_id assignment to one line - update test assertion to match new save_window_id signature
80990a1 to
120292b
Compare
|
Thanks for putting this together The iTerm2 gating is clean, backward compatibility is preserved, and the AppleScript escaping is the feelsl ike the right defensive move. A few quick things before merging: 1. Add a dedup test for the 5th line
Suggested test (sibling to def test_dedup_preserves_iterm2_session_id(self, tmp_path):
"""check_deduplication must preserve the iTerm2 session ID on rewrite."""
session_dir = tmp_path / "cc_notifier"
session_dir.mkdir()
session_file = session_dir / "dedup-iterm"
# Timestamp old enough to bypass the dedup window
session_file.write_text(
f"win123\n/Applications/iTerm.app\n0\n$20\nw0t1p0"
)
assert cc_notifier.check_deduplication(session_file) is False
lines = session_file.read_text().strip().split("\n")
assert len(lines) == 5
assert lines[4] == "w0t1p0"2. Tighten the tab-switch notify test
execute_args = terminal_notifier_calls[0]
execute_idx = execute_args.index("-execute")
assert "osascript" in execute_args[execute_idx + 1]
assert "w0t1p0" in execute_args[execute_idx + 1]3. Update two docstrings
Non-blocking notes
Happy to merge once the dedup test and docstrings are in — the tighter assertion is nice-to-have. And I'm guessing you tested this on your machine and are happy with the iterm2 tab restoration? I'll test it myself after the changes and your confirmation that it's working well for you. |
…args - document three switched-away detection scenarios in send_local_notification_if_needed - add iterm2_session_id parameter description to create_focus_command
- add test_dedup_preserves_iterm2_session_id to verify timestamp rewrites keep session id - enhance tab notification test to verify osascript restore in execute chain - update tests.context.md with new test count (71 total, 62 core)
I think I adressed your points. I will test it from my local |
|
Looks clean to me @dgokcin once you report back that it's working well for you, I'll give it a try, and then we can merge it. |
|
@trentmcnitt I think it's working pretty good. you can give it a test yourself and we can merge if you also do not see any issues 🙌 |
|
Great work, @dgokcin – Played with it today, and it's working nicely 💪 |
Closes #8
Summary
initvia AppleScript (id of current session of current window)Test plan
make testpasses (5 new tests added)make checkpasses (lint, typecheck, deadcode)