Skip to content

fix: merge custom manual sources correctly and add management UI#321

Merged
arran4 merged 3 commits into
mainfrom
fix-custom-source-merging-7811112850366669182
Jul 16, 2026
Merged

fix: merge custom manual sources correctly and add management UI#321
arran4 merged 3 commits into
mainfrom
fix-custom-source-merging-7811112850366669182

Conversation

@arran4

@arran4 arran4 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Fixes the custom source merging and adds a management interface.

  • Modified normalizeSourceId to fully strip sources/ and github/ so custom source IDs match API source IDs.
  • Set isCustom: true flag in NewSessionDialog for manual entries, and preserved it during API model updates.
  • Added showManageCustomSourcesDialog() to MainWindow, integrated as "Manage Custom Sources" in kjulesui.rc.
  • Added removeSource() to SourceModel.

PR created automatically by Jules for task 7811112850366669182 started by @arran4

This fixes an issue where custom (manual) sources inputted via the New Session dialog were not correctly merged with incoming API sources during a refresh due to unstripped ID prefixes.
Additionally, this provides a "Manage Custom Sources..." UI action under the Actions menu, enabling users to remove mistyped or unwanted manual sources from the SourceModel.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a feature to manage and remove custom sources. It adds a "Manage Custom Sources" dialog to the main window, tracks custom sources using an isCustom property, and implements a removeSource method in SourceModel. Feedback was provided to improve showManageCustomSourcesDialog by fixing inconsistent indentation, using Qt::DisplayRole for robust display names, and simplifying item deletion in Qt by directly deleting the item.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/mainwindow.cpp
@arran4

arran4 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@jules please fix lint issues:

Run find src -name "*.h" -o -name "*.cpp" | xargs -r clang-format --dry-run --Werror
src/sourcemodel.cpp:387:61: error: code should be clang-formatted [-Wclang-format-violations]
        if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                            ^
src/sourcemodel.cpp:387:107: error: code should be clang-formatted [-Wclang-format-violations]
        if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                                                                          ^
src/sourcemodel.cpp:388:49: error: code should be clang-formatted [-Wclang-format-violations]
            source[QStringLiteral("isCustom")] = existing.value(QStringLiteral("isCustom"));
                                                ^
src/sourcemodel.cpp:454:61: error: code should be clang-formatted [-Wclang-format-violations]
        if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                            ^
src/sourcemodel.cpp:454:107: error: code should be clang-formatted [-Wclang-format-violations]
        if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                                                                          ^
src/sourcemodel.cpp:455:49: error: code should be clang-formatted [-Wclang-format-violations]
            source[QStringLiteral("isCustom")] = existing.value(QStringLiteral("isCustom"));
                                                ^
src/sourcemodel.cpp:585:59: error: code should be clang-formatted [-Wclang-format-violations]
      if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                          ^
src/sourcemodel.cpp:585:105: error: code should be clang-formatted [-Wclang-format-violations]
      if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                                                                        ^
src/sourcemodel.cpp:586:47: error: code should be clang-formatted [-Wclang-format-violations]
          source[QStringLiteral("isCustom")] = existing.value(QStringLiteral("isCustom"));
                                              ^
src/mainwindow.cpp:2388:32: error: code should be clang-formatted [-Wclang-format-violations]
  m_manageCustomSourcesAction = new QAction(QIcon::fromTheme(QStringLiteral("view-list-details")), i18n("Manage Custom Sources..."), this);
                               ^
src/mainwindow.cpp:2388:99: error: code should be clang-formatted [-Wclang-format-violations]
  m_manageCustomSourcesAction = new QAction(QIcon::fromTheme(QStringLiteral("view-list-details")), i18n("Manage Custom Sources..."), this);
                                                                                                  ^
src/mainwindow.cpp:2389:73: error: code should be clang-formatted [-Wclang-format-violations]
  actionCollection()->addAction(QStringLiteral("manage_custom_sources"), m_manageCustomSourcesAction);
                                                                        ^
src/mainwindow.cpp:2390:66: error: code should be clang-formatted [-Wclang-format-violations]
  connect(m_manageCustomSourcesAction, &QAction::triggered, this, &MainWindow::showManageCustomSourcesDialog);
                                                                 ^
src/mainwindow.cpp:3177:56: error: code should be clang-formatted [-Wclang-format-violations]
  for (int i = 0; i < m_sourceModel->rowCount(); ++i) {
                                                       ^
src/mainwindow.cpp:3178:52: error: code should be clang-formatted [-Wclang-format-violations]
      QModelIndex idx = m_sourceModel->index(i, 0);
                                                   ^
src/mainwindow.cpp:3179:24: error: code should be clang-formatted [-Wclang-format-violations]
      QJsonObject raw = m_sourceModel->data(idx, SourceModel::RawDataRole).toJsonObject();
                       ^
src/mainwindow.cpp:3179:91: error: code should be clang-formatted [-Wclang-format-violations]
      QJsonObject raw = m_sourceModel->data(idx, SourceModel::RawDataRole).toJsonObject();
                                                                                          ^
src/mainwindow.cpp:3180:60: error: code should be clang-formatted [-Wclang-format-violations]
      if (raw.value(QStringLiteral("isCustom")).toBool()) {
                                                           ^
src/mainwindow.cpp:3181:55: error: code should be clang-formatted [-Wclang-format-violations]
          QListWidgetItem *item = new QListWidgetItem(raw.value(QStringLiteral("name")).toString(), listWidget);
                                                      ^
src/mainwindow.cpp:3181:113: error: code should be clang-formatted [-Wclang-format-violations]
          QListWidgetItem *item = new QListWidgetItem(raw.value(QStringLiteral("name")).toString(), listWidget);
                                                                                                                ^
src/mainwindow.cpp:3182:83: error: code should be clang-formatted [-Wclang-format-violations]
          item->setData(Qt::UserRole, raw.value(QStringLiteral("id")).toString());
                                                                                  ^
src/mainwindow.cpp:3190:32: error: code should be clang-formatted [-Wclang-format-violations]
  QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, &dialog);
                               ^
src/mainwindow.cpp:3194:52: error: code should be clang-formatted [-Wclang-format-violations]
  connect(removeBtn, &QPushButton::clicked, [&]() {
                                                   ^
src/mainwindow.cpp:3195:48: error: code should be clang-formatted [-Wclang-format-violations]
      auto items = listWidget->selectedItems();
                                               ^
src/mainwindow.cpp:3196:27: error: code should be clang-formatted [-Wclang-format-violations]
      if (items.isEmpty()) return;
                          ^
src/mainwindow.cpp:3196:35: error: code should be clang-formatted [-Wclang-format-violations]
      if (items.isEmpty()) return;
                                  ^
src/mainwindow.cpp:3198:28: error: code should be clang-formatted [-Wclang-format-violations]
      QStringList toRemove;
                           ^
src/mainwindow.cpp:3199:32: error: code should be clang-formatted [-Wclang-format-violations]
      for (auto item : items) {
                               ^
src/mainwindow.cpp:3200:64: error: code should be clang-formatted [-Wclang-format-violations]
          toRemove.append(item->data(Qt::UserRole).toString());
                                                               ^
src/mainwindow.cpp:3201:62: error: code should be clang-formatted [-Wclang-format-violations]
          delete listWidget->takeItem(listWidget->row(item));
                                                             ^
src/mainwindow.cpp:3202:8: error: code should be clang-formatted [-Wclang-format-violations]
      }
       ^
src/mainwindow.cpp:3204:25: error: code should be clang-formatted [-Wclang-format-violations]
      for (const QString& id : toRemove) {
                        ^
src/mainwindow.cpp:3204:26: error: code should be clang-formatted [-Wclang-format-violations]
      for (const QString& id : toRemove) {
                         ^
src/mainwindow.cpp:3204:43: error: code should be clang-formatted [-Wclang-format-violations]
      for (const QString& id : toRemove) {
                                          ^
src/mainwindow.cpp:3205:43: error: code should be clang-formatted [-Wclang-format-violations]
          m_sourceModel->removeSource(id);
                                          ^

google-labs-jules Bot and others added 2 commits July 15, 2026 04:03
This fixes an issue where custom (manual) sources inputted via the New Session dialog were not correctly merged with incoming API sources during a refresh due to unstripped ID prefixes.
Additionally, this provides a "Manage Custom Sources..." UI action under the Actions menu, enabling users to remove mistyped or unwanted manual sources from the SourceModel.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
This fixes an issue where custom (manual) sources inputted via the New Session dialog were not correctly merged with incoming API sources during a refresh due to unstripped ID prefixes.
Additionally, this provides a "Manage Custom Sources..." UI action under the Actions menu, enabling users to remove mistyped or unwanted manual sources from the SourceModel.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
@arran4

arran4 commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

@jules manage sources fails to pick up on sources that were added prior to this change

@arran4
arran4 merged commit 3733eec into main Jul 16, 2026
24 of 26 checks passed
@arran4
arran4 deleted the fix-custom-source-merging-7811112850366669182 branch July 16, 2026 09:52
@google-labs-jules

Copy link
Copy Markdown
Contributor

@jules please fix lint issues:

Run find src -name "*.h" -o -name "*.cpp" | xargs -r clang-format --dry-run --Werror
src/sourcemodel.cpp:387:61: error: code should be clang-formatted [-Wclang-format-violations]
        if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                            ^
src/sourcemodel.cpp:387:107: error: code should be clang-formatted [-Wclang-format-violations]
        if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                                                                          ^
src/sourcemodel.cpp:388:49: error: code should be clang-formatted [-Wclang-format-violations]
            source[QStringLiteral("isCustom")] = existing.value(QStringLiteral("isCustom"));
                                                ^
src/sourcemodel.cpp:454:61: error: code should be clang-formatted [-Wclang-format-violations]
        if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                            ^
src/sourcemodel.cpp:454:107: error: code should be clang-formatted [-Wclang-format-violations]
        if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                                                                          ^
src/sourcemodel.cpp:455:49: error: code should be clang-formatted [-Wclang-format-violations]
            source[QStringLiteral("isCustom")] = existing.value(QStringLiteral("isCustom"));
                                                ^
src/sourcemodel.cpp:585:59: error: code should be clang-formatted [-Wclang-format-violations]
      if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                          ^
src/sourcemodel.cpp:585:105: error: code should be clang-formatted [-Wclang-format-violations]
      if (existing.contains(QStringLiteral("isCustom")) && !source.contains(QStringLiteral("github"))) {
                                                                                                        ^
src/sourcemodel.cpp:586:47: error: code should be clang-formatted [-Wclang-format-violations]
          source[QStringLiteral("isCustom")] = existing.value(QStringLiteral("isCustom"));
                                              ^
src/mainwindow.cpp:2388:32: error: code should be clang-formatted [-Wclang-format-violations]
  m_manageCustomSourcesAction = new QAction(QIcon::fromTheme(QStringLiteral("view-list-details")), i18n("Manage Custom Sources..."), this);
                               ^
src/mainwindow.cpp:2388:99: error: code should be clang-formatted [-Wclang-format-violations]
  m_manageCustomSourcesAction = new QAction(QIcon::fromTheme(QStringLiteral("view-list-details")), i18n("Manage Custom Sources..."), this);
                                                                                                  ^
src/mainwindow.cpp:2389:73: error: code should be clang-formatted [-Wclang-format-violations]
  actionCollection()->addAction(QStringLiteral("manage_custom_sources"), m_manageCustomSourcesAction);
                                                                        ^
src/mainwindow.cpp:2390:66: error: code should be clang-formatted [-Wclang-format-violations]
  connect(m_manageCustomSourcesAction, &QAction::triggered, this, &MainWindow::showManageCustomSourcesDialog);
                                                                 ^
src/mainwindow.cpp:3177:56: error: code should be clang-formatted [-Wclang-format-violations]
  for (int i = 0; i < m_sourceModel->rowCount(); ++i) {
                                                       ^
src/mainwindow.cpp:3178:52: error: code should be clang-formatted [-Wclang-format-violations]
      QModelIndex idx = m_sourceModel->index(i, 0);
                                                   ^
src/mainwindow.cpp:3179:24: error: code should be clang-formatted [-Wclang-format-violations]
      QJsonObject raw = m_sourceModel->data(idx, SourceModel::RawDataRole).toJsonObject();
                       ^
src/mainwindow.cpp:3179:91: error: code should be clang-formatted [-Wclang-format-violations]
      QJsonObject raw = m_sourceModel->data(idx, SourceModel::RawDataRole).toJsonObject();
                                                                                          ^
src/mainwindow.cpp:3180:60: error: code should be clang-formatted [-Wclang-format-violations]
      if (raw.value(QStringLiteral("isCustom")).toBool()) {
                                                           ^
src/mainwindow.cpp:3181:55: error: code should be clang-formatted [-Wclang-format-violations]
          QListWidgetItem *item = new QListWidgetItem(raw.value(QStringLiteral("name")).toString(), listWidget);
                                                      ^
src/mainwindow.cpp:3181:113: error: code should be clang-formatted [-Wclang-format-violations]
          QListWidgetItem *item = new QListWidgetItem(raw.value(QStringLiteral("name")).toString(), listWidget);
                                                                                                                ^
src/mainwindow.cpp:3182:83: error: code should be clang-formatted [-Wclang-format-violations]
          item->setData(Qt::UserRole, raw.value(QStringLiteral("id")).toString());
                                                                                  ^
src/mainwindow.cpp:3190:32: error: code should be clang-formatted [-Wclang-format-violations]
  QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, &dialog);
                               ^
src/mainwindow.cpp:3194:52: error: code should be clang-formatted [-Wclang-format-violations]
  connect(removeBtn, &QPushButton::clicked, [&]() {
                                                   ^
src/mainwindow.cpp:3195:48: error: code should be clang-formatted [-Wclang-format-violations]
      auto items = listWidget->selectedItems();
                                               ^
src/mainwindow.cpp:3196:27: error: code should be clang-formatted [-Wclang-format-violations]
      if (items.isEmpty()) return;
                          ^
src/mainwindow.cpp:3196:35: error: code should be clang-formatted [-Wclang-format-violations]
      if (items.isEmpty()) return;
                                  ^
src/mainwindow.cpp:3198:28: error: code should be clang-formatted [-Wclang-format-violations]
      QStringList toRemove;
                           ^
src/mainwindow.cpp:3199:32: error: code should be clang-formatted [-Wclang-format-violations]
      for (auto item : items) {
                               ^
src/mainwindow.cpp:3200:64: error: code should be clang-formatted [-Wclang-format-violations]
          toRemove.append(item->data(Qt::UserRole).toString());
                                                               ^
src/mainwindow.cpp:3201:62: error: code should be clang-formatted [-Wclang-format-violations]
          delete listWidget->takeItem(listWidget->row(item));
                                                             ^
src/mainwindow.cpp:3202:8: error: code should be clang-formatted [-Wclang-format-violations]
      }
       ^
src/mainwindow.cpp:3204:25: error: code should be clang-formatted [-Wclang-format-violations]
      for (const QString& id : toRemove) {
                        ^
src/mainwindow.cpp:3204:26: error: code should be clang-formatted [-Wclang-format-violations]
      for (const QString& id : toRemove) {
                         ^
src/mainwindow.cpp:3204:43: error: code should be clang-formatted [-Wclang-format-violations]
      for (const QString& id : toRemove) {
                                          ^
src/mainwindow.cpp:3205:43: error: code should be clang-formatted [-Wclang-format-violations]
          m_sourceModel->removeSource(id);
                                          ^

I have applied clang-format to all affected C++ files to fix the formatting violations.

@google-labs-jules

Copy link
Copy Markdown
Contributor

@jules manage sources fails to pick up on sources that were added prior to this change

Fixed. The condition in showManageCustomSourcesDialog() now also checks if the source's id does NOT start with sources/. This ensures any manually added sources from prior versions (which lack the new isCustom tag but only have owner/repo as an ID) will also appear and be manageable.

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