Skip to content

feat(entities): deterministic window-title parser for VS Code / Cursor - #48

Open
shariqueahmad108-ship-it wants to merge 1 commit into
nossa-y:mainfrom
shariqueahmad108-ship-it:feat/window-title-parser-vscode-38
Open

feat(entities): deterministic window-title parser for VS Code / Cursor#48
shariqueahmad108-ship-it wants to merge 1 commit into
nossa-y:mainfrom
shariqueahmad108-ship-it:feat/window-title-parser-vscode-38

Conversation

@shariqueahmad108-ship-it

Copy link
Copy Markdown

Closes #38.

Native developer tools (VS Code, Cursor) carry only a window title, not a URL, so _pages_for_segment produced zero typed pages for them — even though the title encodes the file, project, and branch.

What this adds

  • parse_window_title(app, window) -> PageRef | None in entities.py, with an _APP_WINDOW_PARSERS dispatch dict analogous to _SITE_PARSERS.
  • Wired into _pages_for_segment (frames.py): when a frame has no url but has a window, the title is typed as a repository_file page, 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 Code would break into file="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

  • em-dash + hyphen separators, the [branch] suffix, and the unsaved marker all handled
  • unrecognized title → None; unknown app → None (never guesses)
  • total: the parser never raises, and any failure degrades to None, so frame compilation is never broken

Tests

8 cases added to test_entities.py (the 7 from the issue + the hyphenated-name regression). pytest -q115 passing.

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.
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.

feat(entities): deterministic window-title parser for VS Code / Cursor

1 participant