Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ on:
branches: [main]

jobs:
# Style only, so it needs no database and no RAILS_ENV. Runs alongside the
# test jobs rather than gating them: a bracket-spacing nit should not hide
# whether the suite passes.
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

- name: Set up Ruby
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
with:
ruby-version: .ruby-version
bundler-cache: true

- name: Run RuboCop
run: bin/rubocop

test:
runs-on: ubuntu-latest

Expand Down
14 changes: 14 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Omakase Ruby styling for Rails
inherit_gem: { rubocop-rails-omakase: rubocop.yml }

# `merge` appends to the inherited Exclude list instead of replacing it. Without
# this, the entry below would drop rubocop-rails' own excludes (bin/*, log/**,
# public/**, app/assets/**) and we would start linting all of them.
inherit_mode:
merge:
- Exclude

AllCops:
Exclude:
# Rails regenerates this from the migrations, so any styling we applied
# would be reverted by the next `db:migrate`. Stated explicitly for the
# next reader; rubocop-rails already excludes it via `db/*schema.rb`.
- db/schema.rb

# Overwrite or add rules to create your own house style
#
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
Expand Down
1 change: 1 addition & 0 deletions app/admin/dashboard.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc { I18n.t("active_admin.dashboard") }

Expand Down
4 changes: 2 additions & 2 deletions app/admin/folders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
f.input :name
f.input :library_id, as: :select,
collection: CoPlan::Library.includes(:owner).map { |l| [ "#{l.owner.try(:name) || l.owner_id} — #{l.name}", l.id ] }
f.input :parent, collection: CoPlan::Folder.order(:name).map { |folder| [folder.path, folder.id] }
f.input :created_by_user, collection: CoPlan::User.order(:name).map { |u| [u.name, u.id] }
f.input :parent, collection: CoPlan::Folder.order(:name).map { |folder| [ folder.path, folder.id ] }
f.input :created_by_user, collection: CoPlan::User.order(:name).map { |u| [ u.name, u.id ] }
end
f.actions
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class SessionsController < ApplicationController
skip_before_action :authenticate_user!, only: [:new, :create]
skip_before_action :authenticate_user!, only: [ :new, :create ]

def new
end
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/slack_notification_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def compose_message(thread, plan)
comment_body = first_comment_body(thread).truncate(300)
plan_url = CoPlan::Engine.routes.url_helpers.plan_url(plan, **default_url_options)

lines = ["New comment on *#{plan.title}*:"]
lines = [ "New comment on *#{plan.title}*:" ]
if thread.anchor_text.present?
lines << "> _#{thread.anchor_text.truncate(120)}_"
end
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/active_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
# You can exclude possibly sensitive model attributes from being displayed,
# added to forms, or exported by default by ActiveAdmin
#
config.filter_attributes = [:encrypted_password, :password, :password_confirmation]
config.filter_attributes = [ :encrypted_password, :password, :password_confirmation ]

# == Localize Date/Time Format
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def self.up
t.references :author, polymorphic: true
t.timestamps
end
add_index :active_admin_comments, [:namespace]
add_index :active_admin_comments, [ :namespace ]
end

def self.down
Expand Down
14 changes: 7 additions & 7 deletions db/migrate/20260226200000_create_coplan_schema.co_plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def change
end

add_index :coplan_plan_versions, :plan_id
add_index :coplan_plan_versions, [:plan_id, :revision], unique: true
add_index :coplan_plan_versions, [:plan_id, :created_at]
add_index :coplan_plan_versions, [ :plan_id, :revision ], unique: true
add_index :coplan_plan_versions, [ :plan_id, :created_at ]
add_foreign_key :coplan_plan_versions, :coplan_plans, column: :plan_id

# Now that coplan_plan_versions exists, add the FK for current_plan_version_id
Expand All @@ -72,7 +72,7 @@ def change
add_index :coplan_plan_collaborators, :plan_id
add_index :coplan_plan_collaborators, :user_id
add_index :coplan_plan_collaborators, :added_by_user_id
add_index :coplan_plan_collaborators, [:plan_id, :user_id], unique: true
add_index :coplan_plan_collaborators, [ :plan_id, :user_id ], unique: true
add_foreign_key :coplan_plan_collaborators, :coplan_plans, column: :plan_id
add_foreign_key :coplan_plan_collaborators, :coplan_users, column: :user_id
add_foreign_key :coplan_plan_collaborators, :coplan_users, column: :added_by_user_id
Expand All @@ -96,8 +96,8 @@ def change
t.timestamps
end

add_index :coplan_comment_threads, [:plan_id, :status]
add_index :coplan_comment_threads, [:plan_id, :out_of_date]
add_index :coplan_comment_threads, [ :plan_id, :status ]
add_index :coplan_comment_threads, [ :plan_id, :out_of_date ]
add_foreign_key :coplan_comment_threads, :coplan_plans, column: :plan_id
add_foreign_key :coplan_comment_threads, :coplan_plan_versions, column: :plan_version_id
add_foreign_key :coplan_comment_threads, :coplan_plan_versions, column: :addressed_in_plan_version_id
Expand All @@ -114,7 +114,7 @@ def change
t.timestamps
end

add_index :coplan_comments, [:comment_thread_id, :created_at]
add_index :coplan_comments, [ :comment_thread_id, :created_at ]
add_foreign_key :coplan_comments, :coplan_comment_threads, column: :comment_thread_id

create_table :coplan_edit_leases, id: { type: :string, limit: 36 } do |t|
Expand Down Expand Up @@ -145,7 +145,7 @@ def change
t.timestamps
end

add_index :coplan_edit_sessions, [:plan_id, :status]
add_index :coplan_edit_sessions, [ :plan_id, :status ]
add_foreign_key :coplan_edit_sessions, :coplan_plans, column: :plan_id
add_foreign_key :coplan_edit_sessions, :coplan_plan_versions, column: :plan_version_id

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def change
t.timestamps
end

add_index :coplan_plan_viewers, [:plan_id, :user_id], unique: true
add_index :coplan_plan_viewers, [ :plan_id, :user_id ], unique: true
add_index :coplan_plan_viewers, :last_seen_at
add_foreign_key :coplan_plan_viewers, :coplan_plans, column: :plan_id
add_foreign_key :coplan_plan_viewers, :coplan_users, column: :user_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def change
t.timestamps
end

add_index :coplan_notifications, [:user_id, :read_at], name: "index_coplan_notifications_on_user_id_and_read_at"
add_index :coplan_notifications, [:comment_thread_id, :user_id], name: "index_coplan_notifications_on_thread_and_user"
add_index :coplan_notifications, [ :user_id, :read_at ], name: "index_coplan_notifications_on_user_id_and_read_at"
add_index :coplan_notifications, [ :comment_thread_id, :user_id ], name: "index_coplan_notifications_on_thread_and_user"
add_index :coplan_notifications, :plan_id, name: "index_coplan_notifications_on_plan_id"

add_foreign_key :coplan_notifications, :coplan_users, column: :user_id
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20260403220000_create_coplan_tags.co_plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def change
t.timestamps
end

add_index :coplan_plan_tags, [:plan_id, :tag_id], unique: true
add_index :coplan_plan_tags, [ :plan_id, :tag_id ], unique: true
add_index :coplan_plan_tags, :tag_id
add_foreign_key :coplan_plan_tags, :coplan_plans, column: :plan_id
add_foreign_key :coplan_plan_tags, :coplan_tags, column: :tag_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def change
t.timestamps
end

add_index :coplan_references, [:plan_id, :key], unique: true
add_index :coplan_references, [:plan_id, :url], unique: true
add_index :coplan_references, [ :plan_id, :key ], unique: true
add_index :coplan_references, [ :plan_id, :url ], unique: true
add_index :coplan_references, :target_plan_id
add_index :coplan_references, :source
add_foreign_key :coplan_references, :coplan_plans, column: :plan_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def change
t.datetime :created_at, null: false

t.index :plan_id
t.index [:plan_id, :created_at]
t.index [ :plan_id, :created_at ]
t.index :event_type
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def change
t.timestamp :created_at, null: false
end

add_index :coplan_search_queries, [:user_id, :created_at]
add_index :coplan_search_queries, [ :user_id, :created_at ]
add_foreign_key :coplan_search_queries, :coplan_users, column: :user_id
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def change
# Unique per sibling group. MySQL treats NULLs as distinct in unique
# indexes, so root-level (parent_id IS NULL) uniqueness is enforced by
# the model validation instead — same approach either way for app code.
t.index [:parent_id, :name], unique: true
t.index [ :parent_id, :name ], unique: true
t.index :created_by_user_id
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def change
unless column_exists?(:coplan_api_tokens, :parent_id)
add_column :coplan_api_tokens, :parent_id, :string, limit: 36
end
unless index_exists?(:coplan_api_tokens, [:parent_id, :revoked_at])
add_index :coplan_api_tokens, [:parent_id, :revoked_at]
unless index_exists?(:coplan_api_tokens, [ :parent_id, :revoked_at ])
add_index :coplan_api_tokens, [ :parent_id, :revoked_at ]
end
unless foreign_key_exists?(:coplan_api_tokens, column: :parent_id)
add_foreign_key :coplan_api_tokens, :coplan_api_tokens, column: :parent_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def show
CoPlan::Current.user = current_user

@instructions_url = coplan.agent_instructions_url
@instructions_markdown = render_to_string(:show, formats: [:text], layout: false)
render :show, formats: [:html]
@instructions_markdown = render_to_string(:show, formats: [ :text ], layout: false)
render :show, formats: [ :html ]
else
render layout: false, content_type: "text/markdown", formats: [:text]
render layout: false, content_type: "text/markdown", formats: [ :text ]
end
end

Expand All @@ -58,7 +58,7 @@ def organizing
@auth_instructions = CoPlan.configuration.agent_auth_instructions
@curl = CoPlan.configuration.agent_curl_prefix
@base = "#{request.base_url}#{root_path.chomp("/")}"
render layout: false, content_type: "text/markdown", formats: [:text]
render layout: false, content_type: "text/markdown", formats: [ :text ]
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def rebase_and_resolve(operations, base_revision, current_content)

# Advance the working base snapshot so the next op resolves
# against the result of this one (sequential semantics).
apply_result = Plans::ApplyOperations.call(content: working_base, operations: [op])
apply_result = Plans::ApplyOperations.call(content: working_base, operations: [ op ])
working_base = apply_result[:content]

rebased_op = op.dup
Expand All @@ -169,7 +169,7 @@ def rebase_and_resolve(operations, base_revision, current_content)

# Advance verification content so the next op's conflict check
# runs against the incrementally updated snapshot.
verify_step = Plans::ApplyOperations.call(content: verification_content, operations: [rebased_op])
verify_step = Plans::ApplyOperations.call(content: verification_content, operations: [ rebased_op ])
verification_content = verify_step[:content]
rescue Plans::TransformRange::Conflict => e
render json: {
Expand Down Expand Up @@ -292,7 +292,7 @@ def verify_transformed_ranges!(op, transformed_ranges, content)
if include_heading
# Verify the heading is the first line of the section range
first_line_end = content.index("\n", tr[0]) || tr[1]
first_line = content[tr[0]...[first_line_end, tr[1]].min]
first_line = content[tr[0]...[ first_line_end, tr[1] ].min]
unless first_line&.rstrip == op["heading"]&.rstrip
render json: {
error: "Conflict: section at target position has changed",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module V1
class SessionsController < BaseController
before_action :set_plan
before_action :authorize_plan_access!
before_action :set_session, only: [:show, :commit]
before_action :set_session, only: [ :show, :commit ]

# POST /api/v1/plans/:plan_id/sessions
# Cloud personas create sessions via direct Ruby service calls, not this endpoint.
Expand Down
4 changes: 2 additions & 2 deletions engine/app/controllers/coplan/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create
# broadcast echoes back.
respond_to do |format|
format.turbo_stream do
html = render_to_string(partial: "coplan/comments/comment", locals: locals, formats: [:html])
html = render_to_string(partial: "coplan/comments/comment", locals: locals, formats: [ :html ])
render turbo_stream: turbo_stream.append(target, html)
end
format.html { redirect_to plan_path(@plan), notice: "Reply added." }
Expand All @@ -59,7 +59,7 @@ def destroy
locals = { comment: comment }
# Requestless render for the broadcast; request-scoped only inline.
Broadcaster.replace_to(@plan, target: target, partial: "coplan/comments/comment", locals: locals)
html = render_to_string(partial: "coplan/comments/comment", locals: locals, formats: [:html])
html = render_to_string(partial: "coplan/comments/comment", locals: locals, formats: [ :html ])
inline_stream = turbo_stream.replace(target, html)
end

Expand Down
2 changes: 1 addition & 1 deletion engine/app/controllers/coplan/llms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class LlmsController < ApplicationController
skip_before_action :authenticate_coplan_user!

def show
render layout: false, content_type: "text/markdown", formats: [:text]
render layout: false, content_type: "text/markdown", formats: [ :text ]
end
end
end
4 changes: 2 additions & 2 deletions engine/app/controllers/coplan/notifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class NotificationsController < ApplicationController
def index
@filter = params[:filter] == "all" ? "all" : "unread"
@notifications = current_user.notifications
.includes(:plan, :comment, comment_thread: [:created_by_user])
.includes(:plan, :comment, comment_thread: [ :created_by_user ])
.newest_first
.limit(INDEX_LIMIT)

Expand Down Expand Up @@ -53,7 +53,7 @@ def mark_all_read
respond_to do |format|
format.turbo_stream {
@notifications = current_user.notifications
.includes(:plan, :comment, comment_thread: [:created_by_user])
.includes(:plan, :comment, comment_thread: [ :created_by_user ])
.newest_first
.unread
@unread_count = 0
Expand Down
4 changes: 2 additions & 2 deletions engine/app/controllers/coplan/plan_versions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module CoPlan
class PlanVersionsController < ApplicationController
before_action :set_plan
before_action :set_version, only: [:show, :diff]
before_action :set_diff, only: [:show, :diff]
before_action :set_version, only: [ :show, :diff ]
before_action :set_diff, only: [ :show, :diff ]

def show
authorize!(@plan, :show?)
Expand Down
2 changes: 1 addition & 1 deletion engine/app/controllers/coplan/plans_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module CoPlan
class PlansController < ApplicationController
before_action :set_plan, only: [:show, :edit, :update, :publish, :hide, :archive, :unarchive, :move_to_folder, :toggle_checkbox, :history, :edit_content, :update_content, :preview]
before_action :set_plan, only: [ :show, :edit, :update, :publish, :hide, :archive, :unarchive, :move_to_folder, :toggle_checkbox, :history, :edit_content, :update_content, :preview ]

PER_PAGE = 20

Expand Down
4 changes: 2 additions & 2 deletions engine/app/controllers/coplan/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def search

def user_json(user)
if user.respond_to?(:id)
ALLOWED_FIELDS.to_h { |f| [f, user.public_send(f)] }
ALLOWED_FIELDS.to_h { |f| [ f, user.public_send(f) ] }
else
ALLOWED_FIELDS.to_h { |f| [f, user[f]] }
ALLOWED_FIELDS.to_h { |f| [ f, user[f] ] }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion engine/app/helpers/coplan/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module ApplicationHelper
FAVICON_COLORS = {
"production" => { start: "#3B82F6", stop: "#1E40AF" },
"staging" => { start: "#F59E0B", stop: "#D97706" },
"development" => { start: "#10B981", stop: "#047857" },
"development" => { start: "#10B981", stop: "#047857" }
}.freeze

def coplan_favicon_tag
Expand Down
2 changes: 1 addition & 1 deletion engine/app/models/coplan/edit_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def has_operations?
end

def add_operation(op)
self.operations_json = operations_json + [op]
self.operations_json = operations_json + [ op ]
save!
end

Expand Down
2 changes: 1 addition & 1 deletion engine/app/models/coplan/plan_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PlanTag < ApplicationRecord

# Plan-level after_save_commit doesn't fire when tags change (the Plan row
# itself isn't dirty), so re-denormalize the parent's `search_text` here.
after_commit :refresh_plan_search_text, on: [:create, :destroy]
after_commit :refresh_plan_search_text, on: [ :create, :destroy ]

def self.ransackable_attributes(auth_object = nil)
%w[id plan_id tag_id created_at updated_at]
Expand Down
1 change: 0 additions & 1 deletion engine/app/models/coplan/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,5 @@ def voice_hotkey=(value)
self.metadata ||= {}
self.metadata["voice_hotkey"] = value
end

end
end
Loading
Loading