feat(entities): deterministic window-title parser for VS Code / Cursor - #48
Open
shariqueahmad108-ship-it wants to merge 1 commit into
Conversation
nossa-y#38) Native dev tools (VS Code, Cursor) carry no URL, so _pages_for_segment produced zero typed pages for them even though the window title encodes the file, project, and branch. Adds parse_window_title(app, window) -> PageRef | None with an _APP_WINDOW_PARSERS dispatch dict analogous to _SITE_PARSERS, and wires it into _pages_for_segment: when a frame has no url but has a window, its title is typed as a repository_file page (e.g. "activity-frames/main.py@main"). The separator is matched space-padded (\s+[—-]\s+) rather than as a bare "-"/"—": VS Code's separator is always surrounded by whitespace, whereas the hyphens inside file names ("my-file.py") and project names ("activity-frames") are not — so a bare split would mis-parse both. Handles the em-dash (macOS default) and hyphen separators, the [branch] suffix, and the ● unsaved marker; unrecognized titles and unknown apps return None (never guesses), and the parser never raises. Builds on the proposal in nossa-y#38 by @Lokeshm25. Adds 8 tests (including the hyphenated-name regression) in test_entities.py; full suite green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #38.
Native developer tools (VS Code, Cursor) carry only a window title, not a URL, so
_pages_for_segmentproduced zero typed pages for them — even though the title encodes the file, project, and branch.What this adds
parse_window_title(app, window) -> PageRef | Noneinentities.py, with an_APP_WINDOW_PARSERSdispatch dict analogous to_SITE_PARSERS._pages_for_segment(frames.py): when a frame has nourlbut has awindow, the title is typed as arepository_filepage, e.g.activity-frames/main.py@main.On the separator ambiguity (the tricky part)
@Lokeshm25's sketch (thanks!) split on a bare
(?:—|-). That mis-parses when a file or project name contains a hyphen — e.g.my-file.py - cool-project - Visual Studio Codewould break intofile="my". Since VS Code's separator is always space-padded while in-name hyphens are not, this matches it as\s+[—-]\s+, which handles both the em-dash (macOS default) and hyphen configs correctly. There's a dedicated regression test for it.Behavior
[branch]suffix, and the●unsaved marker all handledNone; unknown app →None(never guesses)None, so frame compilation is never brokenTests
8 cases added to
test_entities.py(the 7 from the issue + the hyphenated-name regression).pytest -q→ 115 passing.