Commit Graph
2673 Commits
Author SHA1 Message Date
Ofek ce3e976acd Fix #8013: Pinkify opt-pipeline view (#8016) 2025-08-09 20:59:49 +03:00
Matt Godbolt 50ec53d0e7 Add comprehensive Cypress E2E tests for Claude Explain feature (#7751)
- Add comprehensive test suite covering all Claude Explain functionality:
  - Basic pane opening and consent flow
  - no-ai directive detection
  - API interactions and error handling
  - Options/customization features
  - Caching behavior and persistence
  - Compilation state handling
  - State persistence across page loads

- Fix caching bug in explain-view.ts:
  - Cache was incorrectly implemented as instance variable, losing cached explanations when panes were closed/reopened
  - Made cache static to persist across all pane instances (matches consent persistence pattern)
  - Fixes failing "Caching and reload" Cypress test
  - Aligns implementation with documented behavior: "shared across all explain views in the session"

- Add test utilities and helpers:
  - Monaco editor content manipulation using clipboard events
  - Claude Explain specific helpers moved to test file
  - General utilities remain in utils.ts

- Performance optimizations:
  - Clear Cypress intercepts in afterEach to prevent O(n²) degradation
  - Use :visible selectors to avoid GoldenLayout template elements
  - Proper mock setup timing to prevent race conditions

- Add comprehensive README with lessons learned and best practices

All tests use fake test data (test_first, focus_a, etc.) to clearly distinguish from production values and prevent accidental API calls.
2025-08-05 16:42:48 -05:00
Matt GodboltandClaude c29ad46f3a [Not Live; disabled by default] Add Claude Explain feature for AI-powered assembly explanations (#7749)
Add Claude Explain feature for AI-powered code explanations

This PR introduces Claude Explain, a new feature that provides AI-powered explanations of compiler output directly within Compiler Explorer.

Key features:

Claude Explain functionality:
  - New explain view pane
  - Explains compiler output with full context of source code and compilation output
  - Configurable audience level and explanation type
  - Response caching to improve performance and reduce API calls
  - Usage statistics display showing requests used and token counts

User experience:
  - Consent flow on first use explaining data handling and privacy
  - AI disclaimer banner warning about potential LLM inaccuracies
  - Respects "no-ai" directive in source code for users who don't want AI processing

Privacy and security:
  - Data sent to Anthropic's Claude API as documented in privacy policy
  - No data used for model training
  - Clear consent required before first use
  - Support for opting out via "no-ai" directive

The feature is marked as beta and can be enabled via configuration.

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-05 09:31:48 -05:00
Iain Buclaw 1055430504 Add alias option for gcc tree/rtl viewer (#7985) (#7987)
This option is undocumented, but has been around since 2010 for GCC
4.6.0
2025-08-04 15:44:08 +02:00
Matt Godbolt ef264acace Update to Privacy Policy (#7983)
A whole bunch of changes I've been meaning to make:
- Clarify things and put the TLDR at the top
- Remove my own darn address etc (after checking this is OK)
- Clarifying the goo.gl situation
- Paving the way for the explain feature
2025-08-02 16:20:20 -05:00
Matt GodboltandClaude 12ae4246a0 SCSS Migration Phase 2: Complete @import to @use conversion (#7971)
## Summary

This PR completes Phase 2 of the SCSS migration to prepare for Dart Sass
3.0.0 compatibility. This phase focused on converting the complex
conditional theme system from deprecated `@import` statements to modern
`@use` statements.

## What Changed

### 🎯 Major Achievements
- **Eliminated 43+ SCSS deprecation warnings** (down from 45+ to only 2
remaining)
- **96% reduction** in deprecation warnings
- **Converted all SCSS-to-SCSS imports** from `@import` to `@use`
- **Modernized all color functions**: `lighten()`, `darken()`,
`adjust-color()`, `transparentize()`, `opacify()` → `color.scale()` and
`color.adjust()`
- **Implemented CSS custom properties** for theme variable sharing
- **Fixed theme isolation** - themes now properly scope their styles

### 🔧 Technical Changes
- Added `@use` statements for all theme files at top of `explorer.scss`
- Wrapped all theme file contents in `html[data-theme='...']` selectors
- Added CSS custom properties (`:root { --lighter: #{$lighter}; }`) for
theme variables
- Scoped custom golden-layout themes within their respective theme
selectors
- Removed all conditional `@import` statements for SCSS files

### 📁 Files Modified
- `static/styles/explorer.scss` - Added theme `@use` statements, removed
conditional imports
- `static/styles/themes/pink-theme.scss` - Scoped all styles, added CSS
custom properties
- `static/styles/themes/one-dark-theme.scss` - Scoped all styles, added
CSS custom properties
- `static/styles/themes/dark-theme.scss` - Scoped all styles
- `static/styles/themes/default-theme.scss` - Scoped all styles
- `static/styles/themes/custom-golden-layout-themes/pink.scss` - Scoped
to pink theme
- `static/styles/themes/custom-golden-layout-themes/one-dark.scss` -
Scoped to one-dark theme

## Remaining Issues (Phase 3)

⚠️ **2 deprecation warnings remain** - these will eventually break in
Dart Sass 3.0.0:

```
Line 1161: @import '~golden-layout/src/css/goldenlayout-light-theme';
Line 1168: @import '~golden-layout/src/css/goldenlayout-dark-theme';
```

These are external CSS imports from the golden-layout library that
cannot be converted to `@use` because:
1. They're CSS files, not SCSS files
2. They use webpack's `~` syntax for node_modules resolution
3. They're conditionally imported based on theme

**Phase 3 will need to address these** by either:
- Converting to regular CSS `@import` at top level
- Using webpack's CSS importing mechanism
- Including CSS files directly in HTML
- Finding alternative golden-layout integration approach

## Testing

- ✅ Webpack build succeeds with only 2 expected warnings
- ✅ Visual testing confirms themes work correctly
- ✅ Pink theme now shows proper light golden-layout theme (was showing
dark before)
- ✅ All theme styles properly isolated - no global style conflicts
- ✅ CSS custom properties working for theme variables

## Build Output

Current warnings (only external CSS imports remain):
```
WARNING: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0
Line 1161: @import '~golden-layout/src/css/goldenlayout-light-theme';
Line 1168: @import '~golden-layout/src/css/goldenlayout-dark-theme';
```

All other webpack warnings are performance-related (bundle sizes), not
SCSS deprecations.

## Migration Progress

- ✅ **Phase 1**: Basic color function and simple import conversions
(merged)
- ✅ **Phase 2**: Complex conditional theme system conversion (this PR)  
- 🔄 **Phase 3**: External CSS import resolution (future work)

This PR makes Compiler Explorer's SCSS mostly compatible with Dart Sass
3.0.0, with only 2 external library imports remaining to be addressed.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-31 11:42:28 -05:00
Matt Godbolt 2e91e7dec8 Filter out network-level jQuery failures from Sentry reports (#7972)
## Summary

This PR fixes Sentry issue COMPILER-EXPLORER-BFA which has generated
over 33,000 occurrences of non-actionable error reports.

## Problem

The issue occurs when jQuery `.get()` requests fail with `readyState: 0`
and `status: 0`, which typically indicates:
- Ad blockers blocking requests to static assets (icons.html,
sponsors.html)
- Network connectivity issues
- Browser security policies 
- User navigating away during request

These network-level failures are not application bugs and create noise
in Sentry monitoring.

## Solution

- Filter out network failures (`readyState === 0 && status === 0`)
before sending to Sentry
- Only capture actual server errors (`status >= 400`) for debugging
- Log network failures to console for debugging instead
- For sponsors.html specifically, silently fail on network issues per
request

## Test Plan

- [x] TypeScript compilation passes
- [x] All tests pass
- [x] Pre-commit hooks complete successfully
- Verified logic handles both network failures and real server errors
appropriately

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-07-30 18:08:53 -05:00
Matt GodboltandClaude 506575bb3e SCSS Migration Phase 1: Modernize color functions and @import statements (#7970)
## Summary

**Phase 1 of systematic SCSS modernization** to prepare for Dart Sass
3.0.0 compatibility. This PR eliminates **all deprecated color function
warnings** and converts straightforward `@import` statements to modern
`@use` syntax.

## What This PR Accomplishes

### ✅ **All Color Function Deprecations Eliminated** (11 instances)
- `adjust-color()` → `color.adjust()` (5 instances in `colours.scss`)
- `lighten()` → `color.scale($lightness: +%)` (2 instances in
`dark-theme.scss`)
- `darken()` → `color.scale($lightness: -%)` (4 instances across themes)
- Added `@use 'sass:color'` imports to all theme files

### ✅ **@import to @use Conversion** (4 instances)
- Internal SCSS-to-SCSS imports converted to modern `@use` syntax
- `ansi-dark.scss` imports in theme files
- Custom golden layout theme imports
- All `@use` statements properly moved to top of files per SCSS
requirements

### ✅ **Zero Visual Changes**
- All themes render identically to before
- Extensive testing across all 4 themes (default, dark, pink, one-dark)
- Build process unchanged, functionality preserved

## Technical Approach

**5 incremental commits** with systematic validation at each step:
1. Add `@use 'sass:color'` imports (preparation)
2. Convert `colours.scss` color functions 
3. Convert `dark-theme.scss` color functions
4. Convert remaining theme color functions
5. Convert internal SCSS `@import` to `@use`

Each commit was individually tested for build success and visual
consistency.

## What This PR Does NOT Include

This is **Phase 1 only** - the following complex migrations are
intentionally deferred to **Phase 2**:

### 🔄 **Remaining for Phase 2: Architectural Changes**
- **Complex conditional theme system** in `explorer.scss` (lines
1157-1180)
  - Currently uses HTML attribute-based conditional `@import` statements
- Requires architectural redesign (CSS variables or separate entry
points)
- **CSS imports from node_modules** (FontAwesome, Golden Layout)
  - Kept as `@import` due to webpack compatibility requirements
- **Theme switching mechanism** updates if needed

### 📊 **Migration Progress**
- ✅ **Phase 1**: Color functions + simple imports (this PR)
- 🔄 **Phase 2**: Conditional theme system redesign  
- 🔄 **Phase 3**: Final cleanup and optimization

## Deprecation Warning Reduction

**Before this PR**: 45+ deprecation warnings
**After this PR**: ~15 deprecation warnings (only complex `@import`
statements remain)

All remaining warnings are the challenging conditional imports that
require Phase 2 architectural work.

## Testing

- ✅ Build succeeds: `npm run webpack`, `npm run ts-check`, `npm run
lint`
- ✅ All themes render correctly: default, dark, pink, one-dark
- ✅ No visual regressions or functional changes
- ✅ Theme switching works identically
- ✅ Form controls, scrollbars, and all UI elements maintain proper
styling

## Benefits

1. **Future-proofing**: Ready for Dart Sass 3.0.0 color function changes
2. **Maintainability**: Modern, namespaced color functions are clearer
3. **Performance**: Modern `@use` system loads modules once vs `@import`
duplication
4. **Incremental approach**: Safe, testable changes with easy rollback
if needed

## Follow-up Work

This establishes the foundation for **Phase 2**, which will tackle the
complex conditional theme system. The architectural decisions for Phase
2 can now be made independently without blocking this foundational
modernization.

Closes part of #7112

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-30 15:09:10 -05:00
Jacob Panov f2fb988af6 Fix SCSS deprecation warnings in theme files (#7968)
Fixed the SCSS deprecation warnings in three themes - default, one-dark,
and pink.

- Replaced deprecated lighten() and darken() functions with
color.adjust()
- Add @use 'sass:color' imports to all theme files
- Add standard background-clip property alongside
-webkit-background-clip for CSS compatibility
- Fixes the warnings for the files mentioned in #7112: 45 SCSS
deprecation warnings

I tried the automatic migrator mentioned in #7112 and here's how it
went:

What worked perfectly:
Color function migration: npx sass-migrator color successfully converted
all deprecated color functions:

lighten($color, 10%) → color.adjust($color, $lightness: 10%)
darken($color, 15%) → color.adjust($color, $lightness: -15%)

Individual theme file migration: npx sass-migrator module worked well
for standalone theme files like:
static/styles/themes/default-theme.scss
static/styles/themes/pink-theme.scss
static/styles/themes/one-dark-theme.scss

Automatic @use imports: The migrator correctly added @use 'sass:color';
imports at the top of files

However, the migrator couldn't handle:
Complex nested import structures: The conditional theme loading system
in static/styles/explorer.scss was too complex for automatic migration.

and Conditional @import statements in explorer.scss: The migrator failed
on lines like: &[data-theme='pink'] {
    @import 'themes/pink-theme';
}

Therefore the migrator can be used in conjunction with manual editing of
files.
2025-07-30 10:21:39 -05:00
Matt GodboltandClaude 60d3cc321c Fix CEFSharp bot errors in Sentry - Fixes COMPILER-EXPLORER-C14 (#7965)
## Summary
- Suppress "Object Not Found Matching Id" errors from CEFSharp bots
- Generalizes existing suppression for Id:2 to catch all Id values
- Analysis shows 100% of these 76,000+ errors come from Windows + Chrome
(CEFSharp signature)

## Background
We're seeing thousands of `Object Not Found Matching Id:1,
MethodName:update, ParamCount:4` errors in Sentry. Investigation
reveals:

1. **These are bot errors, not user errors** - The error format is
specific to CEFSharp (.NET Chromium wrapper) used by automated scanners
2. **100% come from Windows + Chrome** - Analysis of all events shows
this consistent pattern, confirming they're from CEFSharp bots
3. **Likely Microsoft Outlook SafeLink** - Based on similar reports from
other projects, these are URL security scanners
4. **We already suppress Id:2** - PR #7103 added suppression for the
same error with Id:2

## Changes
Updated the Sentry ignore pattern from `/Object Not Found Matching
Id:2/` to `/Object Not Found Matching Id:\d+/` to catch all variants.

## References
- Similar issue reported:
https://github.com/DataDog/browser-sdk/issues/2715
- TrackJS documentation:
https://trackjs.com/javascript-errors/object-not-found-matching-id-methodname-paramcount/
- Previous PR that added Id:2 suppression: #7103

## Test plan
- [x] TypeScript checks pass
- [x] Tests pass
- [x] Pre-commit hooks pass

cc @OfekShilon - could you review this since you added the original
suppression?

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-29 13:55:32 -05:00
Matt Godbolt 8734c3e492 Update biome (#7956)
- latest biome, and fix its configuration
- fixes "static" content to be globally configured too (instead of
per-line)
- fixes issues:
  - imports fixed up
  - `Date.now()` vs `+new Date()`
  - some unused things `_` prefixed
 
After discussion with the team, turned off the unused parameter warning.
2025-07-28 10:34:46 -05:00
Jacob PanovandMats Jun Larsen 5edc911180 Refactor Enhance Type Saftey in Library Elements (#7925)
Co-authored-by: Mats Jun Larsen <mats@jun.codes>
2025-07-20 07:36:38 +00:00
aabhinavg1 ef416b71ea Fix social share link colors for better readability (#7903) 2025-07-09 09:46:51 +00:00
Mats Jun Larsen 55210745dc Infer pane state from pane constructor (#7880) 2025-07-04 07:46:54 +00:00
woruyu 42cf30d7a6 Decouple Site Template images from template name (#7883) 2025-07-04 06:01:20 +00:00
Mats Jun Larsen 4e41be977f Return the editor instance from codeEditorFactory (#7857)
I have no clue how Golden Layout ever picked this one up since the call
to `registerComponent` passes a function that returns void...
2025-06-30 17:09:55 -05:00
Mats Jun Larsen 9fb8d192ed Add back toolname data attribute
I have no recollection of even touching this, but it appears to have regressed in03546bc4ef98ee95828b0d085e26af5b8b715f1b
2025-06-29 13:28:49 +09:00
Partouf c79cf686e6 hotfix diff view 2025-06-28 23:15:27 +02:00
Mats Jun Larsen 03546bc4ef Conditionally render img tags for language logos (#7873) 2025-06-28 16:33:07 +02:00
Mats Jun Larsen fcd1e2741b Remove extra leading slash from tool logos 2025-06-28 22:16:31 +09:00
Mats Jun Larsen d92de076cb Always specify full non-null paths and fix cpp image (#7871) 2025-06-28 14:49:43 +02:00
Mats Jun Larsen d147341663 Serve all static asset files over the CDN (#7795) 2025-06-28 14:01:36 +02:00
narpfel c9c8f35677 Add cursor: pointer to some clickable texts (#7863)
Before #7797, elements such as “Toggle full version output” in the
compiler version popup or the share buttons (“Short Link” etc.) would
change the cursor to a pointer on hover (like normal links do), but this
was lost when they were switched to use `link-primary`.

This PR restores the previous behaviour.
2025-06-25 10:54:12 +09:00
Jeremy Rifkin bb08a6042a Add option for how parents are placed in control flow layout (#7850)
This PR implements this part of the cutter graph layout algorithm:

![image](https://github.com/user-attachments/assets/134e1717-ba24-4e22-bd83-b64b5333fb96)


![image](https://github.com/user-attachments/assets/27c35f4f-73c8-487d-bb2c-cf9ac57787e8)


![image](https://github.com/user-attachments/assets/661a1afe-4e1e-42fd-8b9d-5ca38a2e8a18)
2025-06-22 13:55:53 -05:00
Matt Godbolt de31120810 Fix unhandled promise rejections in compiler and executor panes - Fixes COMPILER-EXPLORER-BY1 (#7836) 2025-06-21 14:52:04 +02:00
Jeremy Rifkin e58ef76a7b Fix missing call from refactor 2025-06-21 01:32:19 -05:00
Jeremy Rifkin c15d45dc0e Refactor graph layout system (#7847) 2025-06-21 00:51:54 -05:00
Partouf 5879253b94 hotfix miracle url has changed 2025-06-20 17:27:15 +02:00
Patrick Quist b5e7219baa Add dedicated PTX assembly parser to fix directive filtering (#7839) 2025-06-20 14:46:24 +02:00
Patrick Quist d0da32c241 Refactor artifact handling into shared ArtifactHandler class (#7825) 2025-06-20 12:00:01 +02:00
Matt GodboltandClaude 23fad10939 Unit testing the frontend (#7829)
This adds some unit tests for the front end.

- configures "frontend tests" as a unit tests in `static/tests`,
removing the old cypress-requiring "unit" tests
- hack enough of a DOM  to get things working
- port motd and id tests
- *adds* a golden layout checks  (see #7807)
- Updates READMEs etc

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-19 08:46:57 -05:00
Matt GodboltandClaude 81f811b87f Fix Monaco Editor error filtering using ignoreErrors - Fixes COMPILER-EXPLORER-CGQ
Root cause: Source mapping happens AFTER beforeSend/ignoreErrors processing, so
frame.filename contains minified bundle paths, not readable source paths.

Changes:
- Add 'Canceled' to ignoreErrors array for clipboard cancellation errors
- Remove frame-based clipboard filtering (doesn't work with minified code)
- Add comprehensive comments explaining source mapping timing issue
- Keep hit testing filter using error message content (works with minified code)
- Document that frame-based filtering is unreliable for Monaco errors

This should finally stop the 20k+ COMPILER-EXPLORER-CGQ clipboard cancellation errors.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 22:59:23 -05:00
Matt GodboltandClaude 72e293c990 Add temporary debugging for clipboard cancellation filter
Adds Sentry debugging to capture actual runtime filter data including:
- Error value and type received by filter
- Frame filenames array
- Boolean results of hasClipboardFrame and isCancellationError checks
- Whether filter should have triggered

This will help identify why the filter isn't working despite appearing correct.
Will be removed once issue is identified.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 22:32:55 -05:00
Mats Jun Larsen 0e0ecd72df Give a proper type to .pug files on the client (#7828) 2025-06-19 03:06:24 +00:00
Matt GodboltandClaude d054958a66 Fix clipboard cancellation filter to use startsWith - Fixes COMPILER-EXPLORER-CGQ (#7834)
## Summary

Fixed the clipboard cancellation filter that was deployed but not
working due to `SentryCapture` context modification.

## Root Cause

The filter was checking for exact equality:
```typescript
event.exception.values[0].value === 'Canceled'
```

But `SentryCapture()` modifies error messages by adding context:
- Original: `"Canceled"`
- Modified: `"Canceled\nSentryCapture Context: Unhandled Promise
Rejection"`

## Solution

Changed to use `startsWith('Canceled')` which:
- ✅ Catches original error: `"Canceled"`
- ✅ Catches modified error: `"Canceled\nSentryCapture Context: ..."`
- ✅ More precise than `includes()` - reduces false positives
- ✅ Still combined with specific stack trace check for safety

## Test Plan

- [x] TypeScript type checking passes
- [x] Pre-commit hooks pass
- [ ] Deploy and verify clipboard cancellation errors are filtered

This should finally stop the 20k+ COMPILER-EXPLORER-CGQ occurrences.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-18 22:05:14 -05:00
Matt GodboltandClaude b9689671ec Fix Monaco Editor Sentry filters - Fixes COMPILER-EXPLORER-CGQ and COMPILER-EXPLORER-AXA (#7833)
## Summary

Fixed two Monaco Editor error filters that weren't working due to
misunderstanding the Sentry event structure:

• **COMPILER-EXPLORER-CGQ (Clipboard cancellation)**: Filter was
checking for `'Canceled: Canceled'` but actual error value is just
`'Canceled'`
• **COMPILER-EXPLORER-AXA (Hit testing)**: Filter was checking
`frames[0].function` but due to Sentry wrapping, the function name
appears in the error message instead

## Root Cause

The key insight was examining the actual JSON from Sentry UI rather than
making assumptions:
- Sentry UI displays "type: value" format but JSON has separate `type`
and `value` fields
- `frames[0]` is often Sentry's wrapper (`sentryWrapped`), not the
original error source
- Function names may appear in error messages rather than frame metadata

## Changes

1. **Fixed clipboard filter**: Changed error value check from
`'Canceled: Canceled'` to `'Canceled'`
2. **Fixed hit testing filter**: Changed from checking
`frames[0].function` to checking error message content
3. **Added debugging comments**: Comprehensive notes for future Sentry
filter debugging

## Test Plan

- [x] TypeScript type checking passes
- [x] Minimal test suite passes  
- [x] Pre-commit hooks pass
- [ ] Deploy and verify errors are filtered in production

Both issues have 10k+ occurrences so this should significantly reduce
Sentry noise.

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-18 21:20:22 -05:00
Matt Godbolt 49218197b8 Filter Monaco Editor clipboard cancellation errors - Fixes COMPILER-EXPLORER-CGQ (#7831)
## Summary

- Adds `beforeSend` filter to suppress Monaco Editor clipboard
cancellation errors from Sentry
- Specifically targets "Canceled: Canceled" errors from
`monaco-editor/esm/vs/platform/clipboard/browser/clipboardService.js`
- Fixes Sentry issue COMPILER-EXPLORER-CGQ which has 20,139+ occurrences
but 0 user impact

## Problem

The Monaco Editor clipboard service generates cancellation errors when
clipboard operations are interrupted (e.g., user navigates away during
copy operation). These represent expected behavior rather than
actionable bugs, but were creating noise in Sentry with thousands of
error reports.

## Solution

Following the pattern established in PR #7830, this adds a `beforeSend`
filter that:
1. Checks if the error message is "Canceled: Canceled"  
2. Verifies the stack trace contains the Monaco clipboard service file
3. Filters out the error if both conditions are met

## Test Plan

- [x] TypeScript compilation passes (`npm run ts-check`)
- [x] Linting passes (`npm run lint`) 
- [x] Minimal test suite passes (`npm run test-min`)
- [x] Pre-commit hooks executed successfully

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-06-18 19:38:11 -05:00
Matt GodboltandClaude dcc2922287 Fix unhandled promise rejections causing Sentry noise (#7832)
## Summary
- Fixes unhandled promise rejections being logged as "Non-Error capture"
in Sentry issue COMPILER-EXPLORER-BT9
- Converts all promise rejections to use proper Error objects instead of
plain objects/strings/undefined
- Adds defensive handling in Sentry's unhandled rejection listener

## Root Cause
The Sentry issue was caused by services rejecting promises with
non-Error objects:
- `CompilerService.handleRequestError()` rejected with `{request,
error}` plain objects
- Various other services rejected with strings or undefined values
- These triggered the global unhandled rejection handler, which logged
them as "Non-Error capture"

## Changes Made
1. **CompilerService**: Modified `handleRequestError()` to reject with
Error objects while preserving request context
2. **Sentry**: Enhanced unhandled rejection handler to defensively
convert non-Error reasons to Error objects
3. **MultifileService**: Changed string rejections to Error objects
4. **SharingService**: Added descriptive Error objects for link failures
5. **TreePane**: Used Error objects for user cancellation scenarios
6. **CfgView**: Used Error objects for canvas blob creation failures

## Test Plan
- [x] TypeScript compilation passes
- [x] All tests pass (npm run test-min)
- [x] Linter passes
- [x] Pre-commit hooks validated

## Impact
- Reduces Sentry noise from "Non-Error capture" events
- Provides better stack traces for debugging
- Maintains backwards compatibility (consuming code handles both Error
objects and other types)
- More robust error handling throughout the application

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-18 19:24:15 -05:00
5a69f99383 Filter Monaco Editor hit testing errors in Sentry (#7830)
## Summary
- Replace broken regex filter with proper `beforeSend` handler for
Monaco Editor errors
- Fixes noise from Monaco Editor hit testing bug in Firefox (190K+
occurrences)
- Uses structured stack frame checking instead of string parsing

## Root Cause
COMPILER-EXPLORER-AXA was caused by a known Monaco Editor bug in Firefox
where hit testing fails with null reference errors during mouse
operations. The existing regex filter `/i is null
_doHitTestWithCaretPositionFromPoint/` was ineffective because Sentry's
`ignoreErrors` only matches error messages, not stack traces.

## Solution
Added a `beforeSend` callback that:
- Checks if the top stack frame function is
`_doHitTestWithCaretPositionFromPoint`
- Filters out any error thrown directly from this Monaco Editor function
- Uses Sentry's structured stack frames for reliable detection

## References
- Fixes Sentry issue: COMPILER-EXPLORER-AXA (190K+ occurrences)
- Related Monaco Editor bug:
https://github.com/microsoft/monaco-editor/issues/4527

## Test plan
- [x] TypeScript checks pass
- [x] Test suite passes
- [x] Pre-commit hooks pass

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-18 19:13:41 -05:00
Matt GodboltandClaude 4ef43a86e5 Improve GoldenLayout type safety (Phase 1) (#7801)
## Summary

This PR significantly improves type safety for GoldenLayout
configurations, continuing work from issue #4490 "The War of The Types".
This is an **incremental improvement** that establishes a solid
foundation for future work.

## ✅ What We've Accomplished

### Core Type Infrastructure
- **Created comprehensive type system** in
`static/components.interfaces.ts`
- **Added `ComponentConfig<K>`** with proper generic constraints for
type-safe component configurations
- **Added `GoldenLayoutConfig`** to replace unsafe `any[]` content with
strongly-typed `ItemConfig[]`
- **Created `ComponentStateMap`** mapping component names to their
expected state types
- **Added proper TypeScript component name constants** with `as const`
for literal type inference

### Component Configuration Type Safety  
- **All component factory functions** now return strongly-typed
configurations
- **Clean type syntax**: `ComponentConfig<'compiler'>` using the
exported constants
- **Eliminated unsafe casts** in component creation and drag source
setup
- **Fixed hub method signatures** that incorrectly expected
`ContentItem` instead of `ItemConfig`

### Bug Fixes and Code Quality
- **Fixed Jeremy's TODO**: Improved `fixBugsInConfig` function typing 
- **Discovered and fixed hub type bug**:
`addAtRoot`/`addInEditorStackIfPossible` now accept correct types
- **Removed legacy conversion functions** that were no longer needed
- **Replaced verbose TODO comments** with GitHub issue references for
better organization

### Documentation and Planning
- **Created GitHub issues**
[#7807](https://github.com/compiler-explorer/compiler-explorer/issues/7807)
and
[#7808](https://github.com/compiler-explorer/compiler-explorer/issues/7808)
for remaining work
- **Documented type safety approach** with clear explanations of design
decisions
- **Added comprehensive implementation notes** for future contributors

## 🚧 What's Next (GitHub Issues)

- **Issue #7807**: [Type-safe
serialization/deserialization](https://github.com/compiler-explorer/compiler-explorer/issues/7807)
  - localStorage persistence and URL sharing 
  - SerializedLayoutState implementation
  - Version migration support

- **Issue #7808**: [Configuration validation and remaining type
gaps](https://github.com/compiler-explorer/compiler-explorer/issues/7808)
  - Enable `fromGoldenLayoutConfig` validation
  - Fix upstream GoldenLayout TypeScript definitions
  - State type normalization (addresses #4490)

## 📊 Impact

### Type Safety Improvements
- **No more `any` casts** in component configuration creation
- **Compile-time validation** of component names and state types
- **Better IDE support** with autocomplete and type checking
- **Runtime safety** through proper TypeScript interfaces

### Code Quality
- **~100 lines of verbose TODO comments** replaced with concise GitHub
issue references
- **Technical debt reduction** through elimination of unsafe casting
patterns
- **Improved maintainability** with centralized type definitions
- **Better error messages** when component configurations are incorrect

### Files Modified
- `static/components.interfaces.ts` - Core type definitions
- `static/components.ts` - Component factory functions and utilities  
- `static/main.ts` - Layout initialization and configuration handling
- `static/hub.ts` - Fixed method signatures
- `static/panes/*.ts` - Updated component creation patterns

## ✅ Testing & Validation

- **All existing tests pass** - no runtime regressions
- **TypeScript compilation succeeds** with strict type checking
- **Linting passes** with no new warnings
- **Pre-commit hooks validated** all changes
- **Manual testing confirmed** layout functionality works correctly

## 🎯 Ready to Merge

This PR represents a **significant incremental improvement** that:
- ✅ **Provides immediate value** through better type safety
- ✅ **Maintains full backward compatibility** 
- ✅ **Establishes solid foundation** for future improvements
- ✅ **Centralizes remaining work** in well-documented GitHub issues
- ✅ **Ready for production use** with no runtime changes

The remaining work is clearly tracked in the linked GitHub issues and
can be tackled incrementally in future PRs.

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-18 09:22:24 -05:00
Matt Godbolt 9e9e035b28 Rephrase frontend imports (#7824)
- Removes `rootDirs` so all imports will be relative in the frontend
- Updates (and unifies) imports to be `../types/...` etc instead of
relying on "types" being in the rootDir for the frontend.
- Fixes one type that was being picked up from `lib` in the frontend.
- Adds a precommit hook to check in future

Paves the way to writing _unit_ tests for the frontend for the subset of
the frontend code we can import from `node` (which might be a lot of
it!)
2025-06-18 09:04:23 -05:00
narpfel 9b3b1bb557 Re-enable Monaco autoformatting for Rust (#7819)
#7766 changed the Monaco language identifier for Rust, but missed a spot
in `formatter-registry.ts`, so now Monaco can’t autoformat (right click
→ “Format Document”) Rust code any more.
2025-06-16 14:02:51 -05:00
Mats Jun Larsen 5dbb5fff15 Eliminate all usages of require() in the client (#7796) 2025-06-12 21:35:00 +00:00
Mats Jun Larsen 47e8e6d3a7 Replace href=javascript:; with bootstrap link class (#7797)
Fixes #7792

Bootstrap styles `a:has([href])` as a link so the attribute had been
used in the past for things that aren't actually links, yet we want the
style for. It's better to just use `.link-primary` so it doesn't affect
the contents as discovered in #7792
2025-06-13 02:43:14 +09:00
Matt GodboltandClaude e2a834bcc8 Various package updates (#7799)
Updated all packages with npm update -S. Removed deprecated
@types/url-join

Fixed TypeScript error caused by package updates:
- The `at()` method is ES2022, but frontend code targets ES5 for
compatibility
- Changed `this.compilerPickers.at(-1)` to
`this.compilerPickers[this.compilerPickers.length - 1]`

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-12 09:17:14 -05:00
Matt Godbolt 25023620f3 Fix race condition in pane container closing (#7770)
## Summary

Fixes COMPILER-EXPLORER-3W3: Prevents "Can't remove child item. Unknown
content item" errors (4830 occurrences) when attempting to close
containers that have already been destroyed or removed from the layout
hierarchy.

- Uses modern TypeScript optional chaining to check container validity
before close operations
- Prevents race conditions between compiler close events and
GoldenLayout's destruction process
- Addresses issue where deferred `container.close()` calls were
executing on already-destroyed containers

## Root Cause

The error occurred when:
1. A compiler close event triggers `onCompilerClose()` which defers
`container.close()`
2. Meanwhile, GoldenLayout destroys the container through its own
process
3. The deferred close attempt executes on an already-destroyed
container, causing the GoldenLayout error

## Test plan

- [ ] Open multiple compiler panes with associated tool/output panes
- [ ] Quickly close compilers while panes are still loading/updating
- [ ] Verify no "Can't remove child item" errors appear in console
- [ ] Verify panes still close properly in normal scenarios

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-06-11 16:04:31 -05:00
Matt GodboltandClaude 2a4e688ff2 Fix null reference errors in gccdump view selection handling (#7764)
## Summary

Fixes two related null reference errors in the GCC dump view's TomSelect
dropdown handling that occur during user interactions.

## Root Cause Analysis

**COMPILER-EXPLORER-96P** (1067 occurrences):
- Error: `TypeError: undefined is not an object (evaluating
't.filename_suffix')`
- Location: `gccdump-view.ts:318` in `onPassSelect()`
- Trigger: User deletes a selection via TomSelect → `deleteSelection()`
→ `removeItem()` → `trigger('change')` → `onPassSelect()` called with
passId that no longer exists in `this.selectize.options`

**COMPILER-EXPLORER-E44** (34 occurrences):
- Error: `TypeError: Cannot read properties of undefined (reading '0')`
- Location: `gccdump-view.ts:237` in dropdown open handler
- Trigger: `find()` returns undefined when searching for pass by
filename_suffix, but code uses non-null assertion `activeOption![0]`

Both errors occur due to timing issues when dropdown options are being
updated while user interactions are happening.

## Changes

1. **Added null check in `onPassSelect()`**: Safely handle case where
`this.selectize.options[passId]` returns undefined
2. **Removed unsafe non-null assertion**: Replace `activeOption![0]`
with proper null check and early return
3. **Added CLAUDE.md guidance**: Include preference for modern
TypeScript features like optional chaining

## Impact

- Prevents crashes with 1100+ reported occurrences combined
- Maintains existing user experience - dropdowns continue to work
normally
- No behavioral changes for valid interactions

Fixes COMPILER-EXPLORER-96P
Fixes COMPILER-EXPLORER-E44

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-09 11:00:27 -05:00
Matt GodboltandClaude 7d4555f252 Fix dropdown menus showing double arrows (#7765)
## Summary

Fixes issue #7684 where dropdown menus displayed two arrows instead of
one, particularly visible in light theme.

## Root Cause

The double arrows were caused by conflicts between:
1. **TomSelect's Bootstrap 5 theme** - provides automatic dropdown
arrows via `background-image`
2. **Custom legacy CSS** - was adding duplicate arrows using `::after`
pseudo-elements
3. **Bootstrap 4 leftovers** - manual `<b class="caret">` elements in
templates

## Changes

- **Removed conflicting custom TomSelect arrow CSS** from
`explorer.scss`
- **Removed leftover `#[b.caret]` element** from font-size dropdown
template
- **Fixed theme background properties** - changed `background` to
`background-color` to preserve TomSelect's arrow images
- **Added reusable SCSS function** `dropdown-arrow-svg()` for generating
themed dropdown arrows
- **Updated dark themes** to override arrow colors using TomSelect's
exact CSS selector for precision

## Test Plan

- [x] Verify all dropdown menus show only one arrow in default/light
theme
- [x] Test dropdown arrows are visible and correctly colored in all
themes:
  - [x] Default theme: dark gray arrow
  - [x] Pink theme: dark gray arrow  
  - [x] Dark theme: light gray arrow
  - [x] One-dark theme: medium gray arrow
- [x] Confirm dropdown functionality works correctly across all themes
- [x] Check that font-size dropdown works properly without manual caret
element

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-09 11:00:11 -05:00
Christoffer Lerno 896071f905 Update C3 default compiler and compiler support up to 0.7.2 (#7754)
…and do some further fixes to C3-mode.
2025-06-09 10:18:33 -05:00
Matt Godbolt c532d00f45 Fix null reference error in CFG view birds-eye zoom (#7768)
## Summary

Fixes COMPILER-EXPLORER-BY7: TypeError accessing 'blocks' property of
undefined layout when clicking zoom-out button before any CFG has been
generated.

- Uses modern TypeScript optional chaining for null-safe access 
- Prevents crashes when users click zoom-out before compiling code

## Test plan

- [ ] Load CFG view pane
- [ ] Click zoom-out button before generating any CFG (should not crash)
- [ ] Generate a CFG and verify zoom-out still works as expected

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-06-06 17:15:21 -05:00