Skip to content

[codex] Add line of sight profile controls - #4

Merged
dbech merged 4 commits into
mainfrom
t3code/5dbb25bd
May 20, 2026
Merged

[codex] Add line of sight profile controls#4
dbech merged 4 commits into
mainfrom
t3code/5dbb25bd

Conversation

@dbech

@dbech dbech commented May 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a visual line-of-sight overlay to the profile chart with draggable absolute-elevation endpoint handles.
  • Add start/end elevation inputs that stay on the same vertical scale as the sampled terrain profile.
  • Replace automatic chart growth with manual resizing for the profile chart height and Profile Values panel width.

Notes

  • The feature stays renderer-only: no GDAL sampling, Electron IPC, or CSV export changes.
  • LOS is visual-only and terrain-only, with no curvature or refraction.
  • The desktop dev app was stopped before publishing so no local session is left running.

Validation

  • bun run typecheck
  • bun run format:check
  • bun run test:unit
  • bun run build
  • bun run build:electron
  • git diff --check

Summary by CodeRabbit

  • New Features
    • Resizable profile and values panels for personalized workspace layout and customization
    • Line-of-sight elevation endpoint editing with interactive draggable handles on profile charts
    • Enhanced profile visualization with line-of-sight overlays and endpoint markers for terrain analysis

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 21ee6aa9-7882-45a3-955d-2f1b675bb3ca

📥 Commits

Reviewing files that changed from the base of the PR and between 5f9a07e and fe5334b.

📒 Files selected for processing (2)
  • src/components/path-profile-app.tsx
  • src/lib/line-of-sight.ts
 ______________________________________________________________
< Ad Astra Per Codicem Fixis. To the stars through code fixes. >
 --------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
📝 Walkthrough

Walkthrough

This PR adds line-of-sight visibility calculations and interactive endpoint elevation editing to the elevation profile chart, enabling users to visualize and adjust sight lines across terrain. The changes also make the profile and values panels dynamically resizable with persistent layout state, improving the editor's usability for different screen layouts.

Changes

Line-of-sight and resizable panels

Layer / File(s) Summary
Line-of-sight library with tests
src/lib/line-of-sight.ts, src/lib/line-of-sight.test.ts
New line-of-sight.ts module exports endpoint, elevation, and chart-point types; provides functions to initialize endpoints from profile extrema, interpolate line-of-sight elevation, and build visible segments with gap/crossing handling. Internal helpers classify points, compute crossing points, and deduplicate null separators. Test suite validates endpoint defaults, interpolation, visibility classification, gap insertion, and crossing points.
ProfileChart LOS rendering and pointer interaction
src/components/profile-chart.tsx
Extended ProfileChart to render line-of-sight dashed segments and draggable endpoint markers by accepting optional lineOfSightEndpoints and onLineOfSightEndpointChange callback. Chart datasets now conditionally include LOS segments and endpoint markers, tooltip labels distinguish LOS/elevation/endpoint data, and pointer down/move/up events enable interactive endpoint elevation dragging via chart scale hit-testing. Theme colors added for lineOfSight and lineOfSightHandleBorder.
PathProfileApp state management and LOS synchronization
src/components/path-profile-app.tsx
Extended PathProfileApp to manage line-of-sight endpoints and elevation drafts via new syncLineOfSightEndpoints callback, which atomically updates endpoint state and derives synchronized draft values. After profile generation, initializes endpoints from profile points. On DEM open, path start, and path cancel/clear, clears endpoints back to null. Derives elevationUnit label from project settings. Updates multiple hook dependency arrays to include the synchronization callback.
Resizable panels interaction wiring
src/components/path-profile-app.tsx
Implements full resize interaction logic: endpoint elevation change handler updates both endpoints and drafts; draft change/commit handlers parse user input and synchronize on invalid parse. Pointer down/move/up and keyboard arrow handlers use ResizeDrag discriminator and resizeDragRef to track active resize state. Window resize listener recalculates clamped panel dimensions. Helper functions format/parse elevation drafts and clamp panel sizes with SSR safety.
Dynamic layout and resize separators
src/components/path-profile-app.tsx
Replaced fixed CSS grid sizing with dynamic gridTemplateColumns/gridTemplateRows driven by resizable state. Added horizontal resize separator for profile panel and vertical separator for values panel with pointer/keyboard event handlers. Layout disables text selection during active resize.
LOS elevation input UI and ProfileChart wiring
src/components/path-profile-app.tsx
Profile panel header conditionally renders start/end elevation numeric inputs (draft-driven with commit-on-blur and enter-to-close behavior) when LOS endpoints exist. Wires lineOfSightEndpoints and onLineOfSightEndpointChange callback into ProfileChart. Integrates elevation input lifecycle with the overall panel layout.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A rabbit hops through sight lines clear,
Where endpoints dance and panels peer,
Terrain beneath, the line above,
With draggable endpoints we move—
Resizable views make vision true! 🎯✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[codex] Add line of sight profile controls' directly and clearly describes the main feature addition—line-of-sight profile controls with draggable endpoints and resizing capability.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/5dbb25bd

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can disable the changed files summary in the walkthrough.

Disable the reviews.changed_files_summary setting to disable the changed files summary in the walkthrough.

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Note

Docstrings generation - SUCCESS
Generated docstrings and committed to branch t3code/5dbb25bd (commit: 5f9a07e9cb2e4e915540086ec1d91b8e06a6ecfc)

@dbech

dbech commented May 20, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/profile-chart.tsx (1)

231-299: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

options object recreated on every render.

The options object is defined inside the render function without memoization, causing Chart.js to potentially re-process options on every render. Since it depends on theme, lastDistance, onHoverPoint, and points, consider wrapping it in useMemo with those dependencies.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/profile-chart.tsx` around lines 231 - 299, The Chart.js
options object (options) is being recreated on every render; wrap its
construction in useMemo so it only recalculates when its dependencies change —
include theme, lastDistance, onHoverPoint, and points in the dependency array;
ensure the memo returns the exact options object (including plugins.tooltip
callbacks and onHover logic that references onHoverPoint and points) so Chart
receives a stable reference between renders.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/line-of-sight.ts`:
- Around line 19-21: The current endElevation calculation copies and reverses
points then calls find; replace that pattern with a direct reverse-find using
the built-in findLast: change the expression that computes endElevation
(currently using
[...points].reverse().find(isFiniteProfileElevation)?.elevation) to use
points.findLast(isFiniteProfileElevation)?.elevation so no intermediate array is
created; ensure isFiniteProfileElevation remains the predicate and that your
runtime/polyfill supports Array.prototype.findLast.

---

Outside diff comments:
In `@src/components/profile-chart.tsx`:
- Around line 231-299: The Chart.js options object (options) is being recreated
on every render; wrap its construction in useMemo so it only recalculates when
its dependencies change — include theme, lastDistance, onHoverPoint, and points
in the dependency array; ensure the memo returns the exact options object
(including plugins.tooltip callbacks and onHover logic that references
onHoverPoint and points) so Chart receives a stable reference between renders.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b58cd55c-3dd6-41b5-b6ac-a4c6e4a7ac5e

📥 Commits

Reviewing files that changed from the base of the PR and between 7354a73 and 80c159c.

📒 Files selected for processing (4)
  • src/components/path-profile-app.tsx
  • src/components/profile-chart.tsx
  • src/lib/line-of-sight.test.ts
  • src/lib/line-of-sight.ts

Comment thread src/lib/line-of-sight.ts Outdated
Docstrings generation was requested by @dbech.

The following files were modified:

* `src/components/path-profile-app.tsx`
* `src/components/profile-chart.tsx`
* `src/lib/line-of-sight.ts`

These files were ignored:
* `src/lib/line-of-sight.test.ts`
@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

❌ Failed to clone repository into sandbox. Please try again.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80c159cafd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/profile-chart.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/line-of-sight.ts`:
- Around line 62-69: Update the function docblock above the line-of-sight chart
builder in src/lib/line-of-sight.ts to state that null entries represent both
missing terrain data and occluded (blocked) stretches, not just gaps; keep
references to the inputs (points and endpoints) and the return type
(LineOfSightChartPoint | null[]) and ensure the description explains that null
separators mark either unavailable data or portions of the profile where the
sight line is blocked by terrain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4583e786-9816-4144-92dc-d05c50386041

📥 Commits

Reviewing files that changed from the base of the PR and between 80c159c and 5f9a07e.

📒 Files selected for processing (3)
  • src/components/path-profile-app.tsx
  • src/components/profile-chart.tsx
  • src/lib/line-of-sight.ts

Comment thread src/lib/line-of-sight.ts Outdated
@dbech
dbech merged commit a96703c into main May 20, 2026
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