Skip to content

Syntax attention enhancements#77

Merged
ghirpara merged 2 commits intomainfrom
syntax-attention-enhancements
Mar 29, 2026
Merged

Syntax attention enhancements#77
ghirpara merged 2 commits intomainfrom
syntax-attention-enhancements

Conversation

@ghirpara
Copy link
Copy Markdown
Member

No description provided.

ghirpara and others added 2 commits March 28, 2026 15:24
… changes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nd Stats tab improvements

## Syntax Highlighting (TextMate + Semantic Tokens)

- Add `lib/renpy.tmLanguage.json`: comprehensive TextMate grammar for Ren'Py with 40+
  patterns covering labels, init/python blocks, define/default, screen/transform
  definitions, jump/call/scene/show/hide/play/stop statements, ATL keywords, screen
  language, character dialogue, string interpolation, and builtins
- Add `lib/textmateGrammar.ts`: async TextMate engine bridge using `vscode-textmate` +
  `vscode-oniguruma`; loads onig.wasm via fetch and registers a Monaco TokensProvider
  that replaces the Monarch tokenizer after async init (Monarch kept as immediate fallback)
- Add `lib/renpySemanticTokens.ts`: 9 semantic token types (renpyLabel, renpyLabelUndefined,
  renpyCharacter, renpyCharacterUnknown, renpyImage, renpyImageUnknown, renpyScreen,
  renpyScreenUnknown, renpyVariable) with dark/light theme rules; cross-references live
  analysis data so undefined jump targets and unknown screen refs highlight distinctly
- Add `public/onig.wasm`: Oniguruma WASM binary (copied from vscode-oniguruma release)
- Update `components/EditorView.tsx`: register semantic tokens provider with
  `monaco.Emitter<void>` wired to re-fire on analysis changes; expand renpy-dark/light
  themes to ~30+ rules; set `semanticHighlighting.enabled: true` in editor options
- Add `vscode-textmate` and `vscode-oniguruma` to package.json

## Diagnostics Tab (replaces Punchlist)

- Add `hooks/useDiagnostics.ts`: `useDiagnostics()` hook aggregating 8 diagnostic sources
  into a unified `DiagnosticsResult` — invalid jump/call targets, syntax validation on all
  blocks, missing images, missing audio, undefined characters, undefined screens, unused
  characters, and unreachable labels; also exports `migratePunchlistToTasks()` for
  backwards-compatible migration of saved punchlist data
- Add `components/DiagnosticsPanel.tsx`: two-section panel — Issues (auto-detected,
  non-dismissible, grouped by file with collapsible sections and severity filter pills)
  and Tasks (user-created work items with inline add/complete/delete; sticky notes from
  canvas auto-appear as pinned tasks); tab badge shows live error count
- Delete `components/PunchlistManager.tsx`: fully replaced by DiagnosticsPanel
- Update `types.ts`: add `DiagnosticSeverity`, `DiagnosticIssue`, `DiagnosticsTask`,
  `DiagnosticsResult`; add `'diagnostics'` to `EditorTab.type` union; add
  `diagnosticsTasks` to `ProjectSettings`
- Update `App.tsx`: call `useDiagnostics()` at top level so badge count is available
  even when the panel is not mounted; load/save `diagnosticsTasks`; migrate old
  `punchlistMetadata` and `punchlist` tab type on project load
- Update `electron.js`: rename Punchlist → Diagnostics in View menu

## Toolbar & View Menu UX

- Move Stats and Diagnostics buttons to the toolbar middle group (after Tidy Up),
  separated by a divider; Diagnostics button shows a live red error count badge
- Remove Stats button from the right action group (it was semantically misplaced)
- Add Stats to the View menu so it appears alongside all other views
- Update `Toolbar.tsx`: add `diagnosticsErrorCount` prop; update `onOpenStaticTab`
  type to include `'diagnostics'`

## Stats Tab Improvements

- Restructure into three labeled sections: Writing, Structure, Assets & Health
- Writing: Total Words, Estimated Playtime, Dialogue Words, Narration Words (with
  percentage-of-total subtitles showing the dialogue/narration split)
- Structure: Script Files, Characters (total defined, sub-label shows speaking count),
  Labels, Menus/Branches, Identified Routes; complexity score replaced with a bucketed
  label (Linear / Branching / Complex / Non-linear) based on branching density rather
  than a formula that maxes out at 10 for any large project
- Assets & Health: Image Assets, Audio Assets, Script Errors (clickable card that
  navigates to Diagnostics tab when errors exist)
- Character word count chart switched to vertical layout (matching Lines by File);
  adds Top 5 / Top 15 / All toggle; subtitle shows "Showing X of Y speaking characters
  (Z defined with no dialogue)" to account for silent defined characters
- Lines by File: extended to Top 15 / Top 30 / All toggle

## Validator False Positive Fixes (lib/renpyValidator.ts)

- `init offset = N`: excluded from init-block-missing-colon rule (`init offset` is a
  valid assignment statement, not a block opener)
- `label _("text")` screen displayable: added screen-block context tracker (similar to
  existing python-block tracker); suppresses `checkMissingColon` and
  `checkMenuChoiceCondition` inside `screen name(...):` blocks, fixing false positives
  for `label title`, `label _("Display")`, and similar screen language displayables
- Multi-line `define` dict literals: `"key" : value` dict entries no longer trigger the
  menu-choice rule (bail when `afterQuote` starts with `:`)
- Triple-quoted strings: closing `"""` line no longer triggers menu-choice rule (was
  parsed as empty string `""` + dangling `"`, producing garbled error message)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ghirpara ghirpara merged commit 30fe8db into main Mar 29, 2026
1 check failed
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