Skip to content

Conversation

@lmac-1
Copy link
Collaborator

@lmac-1 lmac-1 commented Dec 31, 2025

I'm still working on this (almost done!) but raising this in case you want to have a look.

Still to do:

  • unit tests for preview and diff
  • manual testing
  • writing up PR and "additional notes for reviewer" with extra design decisions needed
  • one final self-code review of everything

Description

[todo]

Closes #3369

Validation steps

  1. (How can a reviewer validate your work?)

Additional notes for the reviewer

  1. [TODO]

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Pre-submission checklist

  • I have performed a self-review of my code.
  • I have implemented and tested all related authorization policies. (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

Implement backend support for coordinating job code apply operations
across multiple collaborators, mirroring the workflow apply pattern.

Backend changes:
- Extract code field from Apollo responses in ai_assistant.ex
- Support Apollo PR #259 'suggested_code' field with markdown fallback
- Add channel handlers for start/done job code apply coordination
- Broadcast apply state to prevent concurrent modifications

Tests:
- Add channel tests for job code apply coordination
- Add end-to-end coordination test
- Verify broadcasts include user metadata
Implement "Generated Job Code" display with APPLY/COPY buttons,
coordinating apply operations across all collaborators.

Frontend changes:
- Add job code apply handler to AIAssistantPanelWrapper
- Display "Generated Job Code" section in MessageList for job chat
- Add store coordination functions for job code apply state
- Disable save button during apply operation
- Hide inline ADD buttons when message.code exists
- Sync apply state across all connected users via broadcasts

Coordination:
- All users see "APPLYING..." state during apply
- Apply buttons disabled for all users during operation
- Graceful degradation when channel unavailable
Create foundational support for inline code diff previews:
- Add MonacoRefContext to share Monaco ref without prop drilling
- Implement showDiff/clearDiff methods in CollaborativeMonaco
- Use dual-container pattern (standard editor + diff overlay)
- Add dismiss button on diff overlay

This infrastructure enables job chat to preview AI-suggested code
changes directly in the Monaco editor.
Enable users to preview AI-suggested code changes:
- Add PREVIEW button to job code messages (alongside APPLY/COPY)
- Allow PREVIEW in readonly mode (removed isWriteDisabled check)
- Auto-preview diffs when AI responds with code
- Auto-dismiss diff when user changes workflow version
- Track previewing state to prevent duplicate operations

Addresses phase 2 enhancements from issue #3369.
@github-project-automation github-project-automation bot moved this to New Issues in v2 Dec 31, 2025
@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.38%. Comparing base (93647d0) to head (9274483).

Files with missing lines Patch % Lines
lib/lightning/ai_assistant/ai_assistant.ex 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4283      +/-   ##
==========================================
+ Coverage   89.29%   89.38%   +0.09%     
==========================================
  Files         425      425              
  Lines       19899    19914      +15     
==========================================
+ Hits        17768    17800      +32     
+ Misses       2131     2114      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

AI Assistant: insert code suggestions straight into the user's code

2 participants