Skip to content
This repository was archived by the owner on Nov 30, 2026. It is now read-only.
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,9 @@ Managed queues are a special kind of instance. Pass the instance ID directly or
| `cloud tinker` | Tinker in your Laravel Cloud environment |
| `cloud skills:install` | Install Laravel Cloud CLI agent skills |
| `cloud completions` | Generate and install shell completions |
| `cloud feedback` | Tell the Cloud team what got in your way |

`cloud tinker` runs code against an environment, either interactively or via `--code=` for scripting (`--timeout=` caps how long to wait for output, default 60s). `cloud skills:install` installs the CLI's agent skills for supported coding agents; use `--global` or `--project` to choose the location and `--agent=` (repeatable) to pick specific agents.
`cloud tinker` runs code against an environment, either interactively or via `--code=` for scripting (`--timeout=` caps how long to wait for output, default 60s). `cloud skills:install` installs the CLI's agent skills for supported coding agents; use `--global` or `--project` to choose the location and `--agent=` (repeatable) to pick specific agents. `cloud feedback "<message>"` sends the Cloud team a wrong result, a confusing error, a docs gap, or a missing endpoint; pass `--type=question` for a question the docs could not answer, and `--tool=` or `--environment=` to say what it is about. Each organization and each user can send 20 a day.

## Configuration

Expand Down
25 changes: 25 additions & 0 deletions app/Client/Requests/SubmitFeedbackRequestData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Client\Requests;

class SubmitFeedbackRequestData extends RequestData
{
public function __construct(
public readonly string $type,
public readonly string $message,
public readonly ?string $tool = null,
public readonly ?string $environmentId = null,
) {
//
}

public function toRequestData(): array
{
return $this->filter([
'type' => $this->type,
'message' => $this->message,
'tool' => $this->tool,
'environment_id' => $this->environmentId,
]);
}
}
32 changes: 32 additions & 0 deletions app/Client/Resources/Meta/SubmitFeedbackRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Client\Resources\Meta;

use App\Client\Requests\SubmitFeedbackRequestData;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Traits\Body\HasJsonBody;

class SubmitFeedbackRequest extends Request implements HasBody
{
use HasJsonBody;

protected Method $method = Method::POST;

public function __construct(
protected SubmitFeedbackRequestData $data,
) {
//
}

public function resolveEndpoint(): string
{
return '/feedback';
}

protected function defaultBody(): array
{
return $this->data->toRequestData();
}
}
9 changes: 9 additions & 0 deletions app/Client/Resources/MetaResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace App\Client\Resources;

use App\Client\Requests\SubmitFeedbackRequestData;
use App\Client\Resources\Meta\GetOrganizationRequest;
use App\Client\Resources\Meta\ListIpAddressesRequest;
use App\Client\Resources\Meta\ListRegionsRequest;
use App\Client\Resources\Meta\SubmitFeedbackRequest;
use App\Dto\Organization;

class MetaResource extends Resource
Expand All @@ -31,4 +33,11 @@ public function ipAddresses(): array

return $response->json();
}

public function submitFeedback(SubmitFeedbackRequestData $data): array
{
$response = $this->send(new SubmitFeedbackRequest($data));

return $response->json() ?: [];
}
}
103 changes: 103 additions & 0 deletions app/Commands/Feedback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php

namespace App\Commands;

use App\Client\Requests\SubmitFeedbackRequestData;
use Carbon\CarbonInterval;
use Saloon\Exceptions\Request\Statuses\TooManyRequestsException;

use function Laravel\Prompts\intro;
use function Laravel\Prompts\select;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\text;
use function Laravel\Prompts\textarea;

class Feedback extends BaseCommand
{
protected $signature = 'feedback
{message? : What got in the way (a wrong result, a confusing error, a docs gap, a missing endpoint), or the question}
{--type= : feedback (a problem) or question (something the docs and CLI could not answer)}
{--tool= : The CLI command, API endpoint, or MCP tool the feedback is about, e.g. deploy:monitor}
{--environment= : The ID of the environment the feedback is about}';

protected $description = 'Tell the Laravel Cloud team what got in your way, or ask a question the docs could not answer';

public function handle()
{
$this->ensureClient();

intro('Feedback');

$response = $this->loopUntilValid(fn () => $this->submit());

$this->outputJsonIfWanted(['sent' => true, ...$response]);

success('Thanks! Your feedback was sent to the Laravel Cloud team.');
}

protected function submit(): array
{
$this->form()->prompt(
'type',
fn ($resolver) => $resolver
->fromInput(fn (?string $value) => select(
label: 'What kind of feedback is this?',
options: [
'feedback' => 'Something got in the way',
'question' => 'A question the docs and CLI could not answer',
],
default: $value ?? 'feedback',
info: fn ($value) => match ($value) {
'feedback' => 'Wrong result, confusing error, docs gap, missing endpoint',
default => '',
},
))
->nonInteractively(fn () => 'feedback'),
);

if (! in_array($this->form()->get('type'), ['feedback', 'question'], true)) {
$this->failAndExit('--type must be feedback or question.');
}

$this->form()->prompt(
'message',
fn ($resolver) => $resolver->fromInput(fn (?string $value) => textarea(
label: $this->form()->get('type') === 'question' ? 'What is your question?' : 'What got in the way?',
default: $value ?? '',
required: true,
validate: fn (string $value) => mb_strlen($value) > 4000 ? 'Keep it under 4,000 characters.' : null,
)),
);

$this->form()->prompt(
'tool',
fn ($resolver) => $resolver
->fromInput(fn (?string $value) => text(
label: 'Which command is it about?',
placeholder: 'deploy:monitor',
default: $value ?? '',
hint: 'Optional. A CLI command, API endpoint, or MCP tool.',
))
->nonInteractively(fn () => ''),
);

try {
return spin(
fn () => $this->client->meta()->submitFeedback(new SubmitFeedbackRequestData(
type: $this->form()->get('type'),
message: $this->form()->get('message'),
tool: $this->form()->get('tool') ?: null,
environmentId: $this->option('environment') ?: null,
)),
'Sending feedback...',
);
} catch (TooManyRequestsException $e) {
$seconds = (int) $e->getResponse()->header('Retry-After');

$this->failAndExit(
'Feedback is limited to 20 submissions a day for each organization and each user, and that limit has been reached.'
.($seconds > 0 ? ' Try again in '.CarbonInterval::seconds($seconds)->cascade()->forHumans(['parts' => 2]).'.' : ' Try again tomorrow.'),
);
}
}
}
2 changes: 2 additions & 0 deletions skills/deploying-to-cloud/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ For multi-step operations, see [reference/checklists.md](reference/checklists.md
4. Fix the issue and rerun the command.
5. If the same error occurs after one fix, stop and ask the user rather than repeating the operation.

When the CLI, API, or docs got in the way (a wrong result, a confusing error, a docs gap, a missing command or endpoint), tell the Cloud team with `cloud feedback "<what happened>" --tool=<command> -n`. For a question the docs could not answer, add `--type=question`. Tell the user what you are sending first, and leave out secrets, environment variable values, and customer data. Keep it to one short note per problem; each organization and each user can send 20 a day.

Always run `cloud deploy:monitor -n` after every deploy. If it fails, run `cloud deployment:logs {deploymentId} --json -n` to find the build or deploy step with `"status": "failed"` and read its `output`. Show the user what went wrong before attempting a fix.

### Subagent Delegation
Expand Down
137 changes: 137 additions & 0 deletions tests/Feature/FeedbackTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?php

use App\Client\Resources\Meta\GetOrganizationRequest;
use App\Client\Resources\Meta\SubmitFeedbackRequest;
use App\ConfigRepository;
use App\Prompts\Renderer;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Testing\PendingCommand;
use Laravel\Prompts\Key;
use Laravel\Prompts\Prompt;
use Saloon\Http\Faking\MockClient;
use Saloon\Http\Faking\MockResponse;
use Saloon\Http\PendingRequest;
use Tests\Fixtures\InteractiveFeedbackCommand;

beforeEach(function () {
$this->mockConfig = Mockery::mock(ConfigRepository::class);
$this->mockConfig->shouldReceive('apiTokens')->andReturn(collect(['test-api-token']));
$this->app->instance(ConfigRepository::class, $this->mockConfig);
});

afterEach(function () {
MockClient::destroyGlobal();
});

/**
* @return Closure(): stdClass the feedback request that was sent, if any
*/
function setupFeedbackMocks(?MockResponse $response = null): Closure
{
$sent = new stdClass;

MockClient::global([
GetOrganizationRequest::class => MockResponse::make(organizationResponse(), 200),
SubmitFeedbackRequest::class => function (PendingRequest $request) use ($sent, $response) {
$sent->url = $request->getUrl();
$sent->body = $request->body()?->all();

return $response ?? MockResponse::make([], 200);
},
]);

return fn () => $sent;
}

it('sends feedback with only a message, defaulting the type to feedback', function () {
$sent = setupFeedbackMocks();

$this->artisan('feedback', ['message' => 'The logs were empty.', '--no-interaction' => true])
->assertSuccessful();

expect($sent()->url)->toEndWith('/feedback');
expect($sent()->body)->toBe(['type' => 'feedback', 'message' => 'The logs were empty.']);
});

it('sends a question about a tool and an environment', function () {
$sent = setupFeedbackMocks();

$this->artisan('feedback', [
'message' => 'How do I rotate a bucket key?',
'--type' => 'question',
'--tool' => 'bucket-key:update',
'--environment' => 'env-1',
'--no-interaction' => true,
])->assertSuccessful();

expect($sent()->body)->toBe([
'type' => 'question',
'message' => 'How do I rotate a bucket key?',
'tool' => 'bucket-key:update',
'environment_id' => 'env-1',
]);
});

it('refuses an unknown type', function () {
$sent = setupFeedbackMocks();

$this->artisan('feedback', ['message' => 'Hi', '--type' => 'bug', '--no-interaction' => true])
->assertFailed();

expect($sent()->url ?? null)->toBeNull();
});

it('requires a message when run non-interactively', function () {
$sent = setupFeedbackMocks();

$this->artisan('feedback', ['--no-interaction' => true])->assertFailed();

expect($sent()->url ?? null)->toBeNull();
});

function runInteractiveFeedback(): PendingCommand
{
Artisan::registerCommand(new InteractiveFeedbackCommand);

// Accept the default type, then leave the optional command blank.
Prompt::fake([Key::ENTER, Key::ENTER]);

return test()->artisan('test:interactive-feedback', ['message' => 'Hi']);
}

it('explains the daily limit and when to try again', function () {
setupFeedbackMocks(MockResponse::make(['message' => 'Too Many Attempts.'], 429, ['Retry-After' => '7260']));

$suppressed = Renderer::$suppressOutput;

try {
runInteractiveFeedback()
// The error box wraps the message and is one write, which only one expectation can claim.
->expectsOutputToContain('Try again in 2 hours 1')
->assertFailed();
} finally {
Renderer::$suppressOutput = $suppressed;
}
});

it('says to try again tomorrow when the limit response has no Retry-After', function () {
setupFeedbackMocks(MockResponse::make(['message' => 'Too Many Attempts.'], 429));

$suppressed = Renderer::$suppressOutput;

try {
runInteractiveFeedback()
->expectsOutputToContain('Try again tomorrow.')
->assertFailed();
} finally {
Renderer::$suppressOutput = $suppressed;
}
});

it('outputs JSON', function () {
setupFeedbackMocks();

Artisan::call('feedback', ['message' => 'Hi', '--json' => true]);

expect(json_decode(Artisan::output(), true))->toBe(['sent' => true]);
});
37 changes: 37 additions & 0 deletions tests/Fixtures/InteractiveFeedbackCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Tests\Fixtures;

use App\Commands\Feedback;
use App\Prompts\Renderer;
use Laravel\Prompts\Prompt;
use Symfony\Component\Console\Input\InputInterface;

/**
* STDIN is not a TTY under the test runner, so this forces the interactive path of feedback.
*/
class InteractiveFeedbackCommand extends Feedback
{
public function __construct()
{
$this->signature = preg_replace('/^feedback/', 'test:interactive-feedback', $this->signature);
$this->aliases = [];

parent::__construct();
}

protected function isInteractive(): bool
{
return true;
}

protected function configurePrompts(InputInterface $input): void
{
// The test runner can look like an agent or CI, which hides the human output under test.
Renderer::$suppressOutput = false;

parent::configurePrompts($input);

Prompt::interactive(true);
}
}