Skip to content

Conversation

@gino-m
Copy link
Collaborator

@gino-m gino-m commented Jan 22, 2026

Fixes #2395

@auto-assign auto-assign bot requested a review from rfontanarosa January 22, 2026 15:11
@gemini-code-assist
Copy link

Summary of Changes

Hello @gino-m, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the way draft survey state is managed within the application. By making the DraftSurveyService stateless and centralizing state management in the EditSurveyComponent using Angular Signals, the change aims to improve the maintainability, testability, and reactivity of the survey editing workflow. This architectural shift ensures that all modifications to a draft survey are handled consistently and efficiently, providing a more robust foundation for future development.

Highlights

  • Stateless DraftSurveyService: The DraftSurveyService has been refactored to be stateless. Its methods now take a Survey object as an argument and return a new, modified Survey object, promoting immutability and predictability.
  • Angular Signals for State Management: The EditSurveyComponent now centrally manages the draft survey's state using Angular Signals. This includes tracking the current survey, its original state, and its dirty/valid status, leveraging Angular's reactive primitives.
  • Centralized Edit Survey Logic: All components that interact with the draft survey (e.g., EditDetailsComponent, EditJobComponent, ShareSurveyComponent) now communicate through the EditSurveyComponent to modify the survey state, ensuring a single source of truth and consistent behavior.
  • Enhanced Survey Header: The SurveyHeaderComponent now includes 'Cancel' and 'Publish changes' buttons, which are dynamically enabled/disabled based on the survey's dirty and valid status, as managed by the EditSurveyComponent.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request effectively refactors the DraftSurveyService to be stateless and integrates Angular Signals for state management within EditSurveyComponent and related components. This change significantly improves the predictability and maintainability of the survey editing flow by centralizing state in the component and making the service a pure utility for data transformations. The updates to various components to use inputs, outputs, and signals are consistent and well-executed, removing redundant subscriptions and simplifying component logic. The create-survey.component.ts also benefits from a cleaner survey loading mechanism. Overall, this is a positive architectural improvement.

// If we re-assign `this.tasks`, the editor might reset cursor/focus.
// However, if we added a task via `addOrUpdateTasks` (which calls `draftSurveyService`),
// the survey update will reflect that.
this.tasks = this.job?.tasks?.toList().sortBy(task => task.index);

Choose a reason for hiding this comment

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

medium

The comment above indicates a potential issue with resetting the tasks editor's state if this.tasks is always reassigned. To improve user experience and prevent loss of focus or cursor position, consider checking if the incoming job.tasks are different from the current this.tasks before reassigning. This would avoid unnecessary updates to the editor component.

    if (!this.tasks?.equals(this.job?.tasks?.toList())) {
      this.tasks = this.job?.tasks?.toList().sortBy(task => task.index);
    }

@gino-m gino-m marked this pull request as draft January 22, 2026 15:20
@gino-m
Copy link
Collaborator Author

gino-m commented Jan 22, 2026

This PR has snowballed into multiple refactors, so closing for now to address each on separately, starting with

@gino-m gino-m closed this Jan 22, 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.

[Code health] Move survey$ and originalSurvey from DraftSurveyService into components

1 participant