Repository navigation
Conversation
Write previews to the directory the Railtie searches and use current preview URLs. Forward preview parameters to the generated agent call. Look for new preview files on each discovery, and leave generation objects intact in the mail-specific image interceptor. Cover the original failures and retain inline-image handling for mail objects.
The Railtie registers preview routes but ships no controller for them. Render escaped Markdown requests, list namespaced previews and download only declared preview actions. Apply Rails diagnostic-page access rules. Register default, legacy and configured preview directories with the Rails reloader. Exercise generated previews in fresh framework-only hosts, including reloads, disabled routes and refused remote requests. The tests fail if a preview executes the mock provider.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows up #187, which was closed with "Previews are back … the railtie mounts
/rails/agents". The routes are registered, but nothing behind them works:/rails/agentsroutes torails/agents#index, and noRails::AgentsControllerexists, so every preview URL raisesuninitialized constant Rails::AgentsController.test/docs/previews, while the Railtie searchestest/agents/previews. A generated preview is never found./active_agent/agents/...(the URL reported in How to get agent previews working #187) and say "Preview this email".ActiveAgent::Preview.allloads files only while no preview class exists, so a preview added after the first lookup is never discovered.InlinePreviewInterceptorcallshtml_part, which only exists on mail objects, soPreview.callraisesNoMethodErroron everyActiveAgent::Generation.What changes
lib/rails/agents_controller.rb(new, autoloaded asRails::AgentsControllerlikeRails::MailersController):Generation#prompt_previewas escaped Markdown, which never calls the provider.text/markdown.Preview.promptsrun; unknown previews or actions (includingobject_id) return 404.require_local!is inherited fromRails::ApplicationController, the same restriction as/rails/info.lib/active_agent/preview/templates.format: false, so.../greet.mdisn't parsed as a format.test/agents/previews, the legacytest/docs/previewsand any configuredpreview_pathsjoin the autoload paths when previews are enabled, so preview files reload in development. Discovery usesrequire_dependencyand rescans on each lookup.test/agents/previews, with/rails/agents/...URLs, and callAgent.with(params).actionso query parameters reach the agent.InlinePreviewInterceptor: skips objects withouthtml_part, and keeps rewritingcid:images for mail-shaped objects.docs/framework/rails.md; generator output paths fixed there and inAGENTS.md.show_previewsstill defaults to development only, and theactionagentdashboard gem is not needed.Checks
test/preview_integration_test.rb(new) generates plain and namespaced agents into fresh framework-only hosts (no Active Record) and drives them through an integration session. The mock provider is patched to raise, so any provider call fails the test.<script>in parameters.host/script_namequery parameters.text/markdownattachment that contains the passed parameter.object_idreturn 404.reloader.reload!picks up the change.rails/agentsroutes.test/preview_test.rb(new): the interceptor accepts a Generation and still rewrites inline images for mail-shaped objects. A preview file added after the first discovery is found.with(params), old interceptor, cached discovery, no autoload paths (reload fails), norequire_local!(remote request accepted).bin/test: 4098 runs, 0 failures, 0 errors.bin/rubocopreports no offenses.🤖 Generated with Claude Code