Fix hang detection crash when foreground stats are missing (#58464)

Register the foreground thread with the GPUI profiler before starting
hang detection, so foreground task statistics are available when the
hang detection thread samples profiler data.

cc: @yara-blue I choose to leave the expect statements because it seems
like an invariant that we should uphold. Let me know if you would rather
have early returns and telemetry if they're hit

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes FR-58

Release Notes:

- Fixed a crash in hang detection when foreground thread statistics were
missing.

---------

Co-authored-by: Yara <git@yara.blue>
b76e0bc9ddAnthony Eid committed on 6/3/2026, 9:58:23 PM· committed by GitHubparentca0fd8d
2 files changedLine totals unavailable