Skip to content
Open
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
Binary file added .github/media/shipit-demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions KNOWLEDGE_BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ Sources: [composer](resources/js/components/commit-composer.tsx), [commit model]

Livestream history: the team settled on calling posts **commits** and their list a **log** on [day one at 2:56:00](https://www.youtube.com/watch?v=6zCNQa3hNm0&t=10560s). At [3:02:19](https://www.youtube.com/watch?v=6zCNQa3hNm0&t=10939s), they agreed to rename the post model too, rather than changing only the UI. These are naming decisions, not timestamps proving the rename had finished.

### Launch posts

On the web, put `/shipit` on its own final line in the composer and press Enter to select launch mode. Write what you shipped, optionally add a link or images, and press **Ship it** to publish. The command itself is removed from the draft; selecting launch mode never publishes automatically. Canceling launch mode keeps your text. The mode is stashed with the draft and shared between the inline composer and its dialog. Launches use the same moderation as other commits. Scheduling is unavailable in launch mode.

A launch is a commit with `CommitType::Launch`; ordinary commits use `CommitType::Standard`. Its public card contains a ship. Signed-in readers can press **All aboard** to board as a passenger with their avatar as their face, or press **You're aboard** to step ashore. The author appears in the wheelhouse with their avatar and a captain’s hat, and cannot board their own launch. Boarding is separate from stars and can only happen once per person. Passengers stand on decks in little colored outfits. More passengers lower the ship in the water and make it wobble. At most sixteen avatars are rendered, with a `+N` label for the rest. Reduced motion disables the movements.

Guests can see an approved launch and its public crew; boarding asks them to sign in. Hidden and deleted commits cannot be boarded. Blocks with the author prevent access, and blocked or banned passengers are omitted from the viewer's crew. Boarding is included in account exports and removed when the account is deleted.

### Translating commits

Public commits and replies offer **Translate** when their detected language differs from the reader's translation language. Choose a translation language in **Settings → Profile**, searching by its English or native name (for example, Hungarian or magyar), independently of the device language, or leave **Browser language (automatic)** selected to follow the browser. This private preference is saved to the account, included in the data export, and erased with the account. Regional variants share a language, such as English for `en-US` and `en-GB`. Language detection runs in the background for posts being read; undetermined posts initially offer Translate rather than guessing. Code-only or indeterminate text is not offered once detected. Generating translations requires sign-in and is limited to ten requests per minute.
Expand Down
1 change: 1 addition & 0 deletions PRODUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ What exists, one line each (details in the knowledge base):
- **Commits:** text with code, images, link cards and embedded players, or a poll; replies, quotes, threads, scheduling, translation.
- **Logs:** Following, Latest, and Trending.
- **Engagement:** follows, stars, saved commits, pins, mentions, and pastéis (an opt-in daily allowance of pastries).
- **Launch posts:** `/shipit` selects a launch commit for celebrating a release; readers board its public ship as passengers, separately from stars. The author is the captain. Boarding respects moderation and blocks, and survives reloads.
- **Profiles:** mirrored from GitHub, with an activity graph, streaks, achievements, a Unix rank, and a live marker while you stream on YouTube.
- **Organization pages:** GitHub organizations get a page mirrored from GitHub once an approved commit mentions them, and `@organization` mentions link to it. Their members post commits as the organization, which readers see from the organization alone.
- **Remotes:** private one-to-one and group messages (orgs), and calls, one-to-one or in an org.
Expand Down
6 changes: 4 additions & 2 deletions app/Actions/CreateCommit.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Dto\NewPoll;
use App\Dto\ThreadEngagement;
use App\Enums\CommitStatus;
use App\Enums\CommitType;
use App\Enums\CommitUpdate;
use App\Enums\UserUpdate;
use App\Events\CommitsUpdated;
Expand Down Expand Up @@ -62,15 +63,15 @@ public function __construct(
* @param array<int, string|null> $imageDescriptions
* @param array<string, string> $replyRecipients
*/
public function handle(User $user, string $body, ?Commit $parent = null, ?Commit $quotedCommit = null, array $images = [], array $imageDescriptions = [], bool|string $linkPreview = true, ?NewPoll $poll = null, array $replyRecipients = [], ?Organization $organization = null): Commit
public function handle(User $user, string $body, ?Commit $parent = null, ?Commit $quotedCommit = null, array $images = [], array $imageDescriptions = [], bool|string $linkPreview = true, ?NewPoll $poll = null, array $replyRecipients = [], ?Organization $organization = null, CommitType $type = CommitType::Standard): Commit
{
$url = match ($linkPreview) {
true => $this->urls->first($body),
false => null,
default => $linkPreview,
};

return DB::transaction(function () use ($user, $body, $parent, $quotedCommit, $images, $imageDescriptions, $url, $poll, $replyRecipients, $organization): Commit {
return DB::transaction(function () use ($user, $body, $parent, $quotedCommit, $images, $imageDescriptions, $url, $poll, $replyRecipients, $organization, $type): Commit {
$linkPreview = $this->linkPreviewFor($url);
$createdAt = now();
$hasGoodReputation = $user->hasGoodReputation();
Expand All @@ -80,6 +81,7 @@ public function handle(User $user, string $body, ?Commit $parent = null, ?Commit
'user_id' => $user->id,
'author_id' => $organization->id ?? $user->id,
'body' => $this->emojiShortcodes->replace($body),
'type' => $type,
'mentions' => [...$replyRecipients, ...$mentions],
'parent_id' => $parent?->id,
'root_id' => $parent?->threadRootId(),
Expand Down
22 changes: 20 additions & 2 deletions app/Actions/CreateExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* polls: Generator<int, ExportPoll>,
* poll_votes: Generator<int, ExportPollVote>,
* stars: Generator<int, string>,
* launch_boardings: Generator<int, array{commit_id: string, boarded_at: string}>,
* following: Generator<int, ExportUser>,
* followers: Generator<int, ExportUser>,
* muting: Generator<int, ExportUser>,
Expand Down Expand Up @@ -76,7 +77,7 @@
public function handle(User $user): array
{
return [
'schema_version' => 8,
'schema_version' => 9,
'exported_at' => now()->toIso8601String(),
'profile' => [
'github_id' => $user->github_id,
Expand Down Expand Up @@ -123,6 +124,7 @@ public function handle(User $user): array
'polls' => $this->polls($user),
'poll_votes' => $this->pollVotes($user),
'stars' => $this->stars($user),
'launch_boardings' => $this->launchBoardings($user),
'following' => $this->handles($user->following()),
'followers' => $this->handles($user->followers()),
'muting' => $this->handles($user->muting()),
Expand Down Expand Up @@ -198,7 +200,7 @@ private function commits(User $user): Generator
{
$commits = $user->commits()
->withTrashed()
->select(['id', 'parent_id', 'quoted_commit_id', 'body', 'status', 'pasteis_count', 'created_at', 'updated_at', 'deleted_at'])
->select(['id', 'parent_id', 'quoted_commit_id', 'body', 'type', 'status', 'pasteis_count', 'created_at', 'updated_at', 'deleted_at'])
->with('images:id,commit_id')
->lazyById(500);

Expand All @@ -215,6 +217,7 @@ private function commits(User $user): Generator
'body' => $commit->body,
'cached_translations' => $cached[$translations->key($commit)],
'status' => $commit->status->value,
'type' => $commit->type->value,
'pasteis_count' => $commit->pasteis_count,
'images' => $commit->images->map(fn (CommitImage $image): string => $image->url())->all(),
'created_at' => $commit->created_at->toIso8601String(),
Expand Down Expand Up @@ -248,6 +251,7 @@ private function organizationCommits(User $user): Generator
'quoted_commit_id' => $commit->quoted_commit_id,
'body' => $commit->body,
'status' => $commit->status->value,
'type' => $commit->type->value,
'images' => $commit->images->map(fn (CommitImage $image): string => $image->url())->all(),
'created_at' => $commit->created_at->toIso8601String(),
'deleted_at' => $commit->deleted_at?->toIso8601String(),
Expand Down Expand Up @@ -331,6 +335,20 @@ private function stars(User $user): Generator
}
}

/**
* @return Generator<int, array{commit_id: string, boarded_at: string}>
*/
private function launchBoardings(User $user): Generator
{
/** @var LazyCollection<int, object{commit_id: string, created_at: string}> $boardings */
$boardings = DB::table('launch_passengers')->where('user_id', $user->id)
->select(['commit_id', 'created_at'])->lazyById(500, 'commit_id');

foreach ($boardings as $boarding) {
yield ['commit_id' => $boarding->commit_id, 'boarded_at' => CarbonImmutable::parse($boarding->created_at)->toIso8601String()];
}
}

/**
* The messages the user sent. What others sent them is theirs to export.
*
Expand Down
11 changes: 11 additions & 0 deletions app/Enums/CommitType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace App\Enums;

enum CommitType: string
{
case Standard = 'standard';
case Launch = 'launch';
}
3 changes: 2 additions & 1 deletion app/Http/Controllers/CommitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Actions\DeleteCommit;
use App\Dto\ThreadContinuation;
use App\Enums\CommitStatus;
use App\Enums\CommitType;
use App\Http\Requests\CreateCommitRequest;
use App\Http\Requests\DeleteCommitRequest;
use App\Http\Requests\ShowCommitRequest;
Expand Down Expand Up @@ -68,7 +69,7 @@ public function store(CreateCommitRequest $request, #[CurrentUser] User $user, C
$before = $achievements->unlockedBadgeNames($user);

$organization = $request->organization();
$commit = $action->handle($user, $request->string('body')->value(), quotedCommit: $request->quotedCommit(), images: $request->images(), imageDescriptions: $request->imageDescriptions(), linkPreview: $request->linkPreview(), poll: $request->poll(), organization: $organization);
$commit = $action->handle($user, $request->string('body')->value(), quotedCommit: $request->quotedCommit(), images: $request->images(), imageDescriptions: $request->imageDescriptions(), linkPreview: $request->linkPreview(), poll: $request->poll(), organization: $organization, type: $request->enum('type', CommitType::class) ?? CommitType::Standard);

$unlocked = $achievements->unlockedBadgeNames($user)->diff($before)->values();

Expand Down
20 changes: 20 additions & 0 deletions app/Http/Controllers/CommitLaunchController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers;

use App\Http\Requests\ShowCommitLaunchRequest;
use App\Models\Commit;
use App\Models\User;
use App\Queries\LaunchPassengersQuery;
use Illuminate\Container\Attributes\CurrentUser;
use Illuminate\Http\JsonResponse;

final readonly class CommitLaunchController
{
public function show(ShowCommitLaunchRequest $request, #[CurrentUser] ?User $user, Commit $commit, LaunchPassengersQuery $passengers): JsonResponse
{
return response()->json($passengers->get($commit, $user))->header('Cache-Control', 'private, no-store');
}
}
41 changes: 41 additions & 0 deletions app/Http/Controllers/LaunchPassengerController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers;

use App\Enums\CommitUpdate;
use App\Events\CommitsUpdated;
use App\Http\Requests\UpdateLaunchPassengerRequest;
use App\Models\Commit;
use App\Models\User;
use App\Queries\LaunchPassengersQuery;
use Illuminate\Container\Attributes\CurrentUser;
use Illuminate\Http\JsonResponse;

final readonly class LaunchPassengerController
{
public function store(UpdateLaunchPassengerRequest $request, #[CurrentUser] User $user, Commit $commit, LaunchPassengersQuery $passengers): JsonResponse
{
$inserted = $commit->launchPassengers()->newPivotStatement()->insertOrIgnore([
'commit_id' => $commit->id,
'user_id' => $user->id,
'created_at' => now(),
]);

if ($inserted > 0) {
event(new CommitsUpdated([$commit], CommitUpdate::Engagement));
}

return response()->json($passengers->get($commit, $user))->header('Cache-Control', 'private, no-store');
}

public function destroy(UpdateLaunchPassengerRequest $request, #[CurrentUser] User $user, Commit $commit, LaunchPassengersQuery $passengers): JsonResponse
{
if ($commit->launchPassengers()->detach($user) > 0) {
event(new CommitsUpdated([$commit], CommitUpdate::Engagement));
}

return response()->json($passengers->get($commit, $user))->header('Cache-Control', 'private, no-store');
}
}
2 changes: 2 additions & 0 deletions app/Http/Requests/CreateCommitRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Actions\CreateCommitImages;
use App\Dto\NewPoll;
use App\Enums\CommitType;
use App\Enums\PollDuration;
use App\Models\Commit;
use App\Models\Organization;
Expand Down Expand Up @@ -90,6 +91,7 @@ public function rules(): array

return [
'body' => self::bodyRules($this->hasFile('images')),
'type' => ['sometimes', Rule::enum(CommitType::class)],
'author' => ['nullable', 'string', new OrganizationToPostAs($user)],
'quoted_commit_id' => ['nullable', 'uuid', 'prohibits:parent_id', new VisibleCommit($user, 'That commit is no longer available to quote.')],
'link_preview_url' => ['nullable', 'string', Rule::in(is_string($body) ? resolve(Urls::class)->all($body) : [])],
Expand Down
31 changes: 31 additions & 0 deletions app/Http/Requests/ShowCommitLaunchRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace App\Http\Requests;

use App\Enums\CommitType;
use App\Models\Commit;
use Illuminate\Auth\Access\Response;
use Illuminate\Foundation\Http\FormRequest;

final class ShowCommitLaunchRequest extends FormRequest
{
public function authorize(): Response
{
$commit = $this->route('commit');
assert($commit instanceof Commit);

return $commit->type === CommitType::Launch && $commit->isVisibleTo($this->user())
? Response::allow()
: Response::denyAsNotFound();
}

/**
* @return array{}
*/
public function rules(): array
{
return [];
}
}
37 changes: 37 additions & 0 deletions app/Http/Requests/UpdateLaunchPassengerRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace App\Http\Requests;

use App\Enums\CommitStatus;
use App\Enums\CommitType;
use App\Models\Commit;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Foundation\Http\FormRequest;

final class UpdateLaunchPassengerRequest extends FormRequest
{
public function authorize(): Response
{
$user = $this->user();
assert($user instanceof User);
$commit = $this->route('commit');
assert($commit instanceof Commit);

return match (true) {
$commit->type !== CommitType::Launch, $commit->status !== CommitStatus::Approved, ! $commit->isVisibleTo($user) => Response::denyAsNotFound(),
$this->isMethod('post') && $commit->isOwnedBy($user) => Response::deny(),
default => Response::allow(),
};
}

/**
* @return array{}
*/
public function rules(): array
{
return [];
}
}
1 change: 1 addition & 0 deletions app/Http/Resources/CommitResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function toArray(Request $request): array
'id' => $this->id,
'short_hash' => mb_substr(str_replace('-', '', $this->id), -7),
'body' => $this->body,
'type' => $this->type,
'parent_id' => $isSigned ? $this->parent_id : $this->parent?->id,
'html_url' => route('commit.show', [$this->author, $this->resource]),
'created_at' => $this->created_at->toIso8601ZuluString(),
Expand Down
12 changes: 12 additions & 0 deletions app/Models/Commit.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Models;

use App\Enums\CommitStatus;
use App\Enums\CommitType;
use App\Queries\CommitBuilder;
use App\Services\CommitBodies;
use App\Services\Mentions;
Expand All @@ -31,6 +32,7 @@
* @property-read string|null $root_id
* @property-read float $hot_score
* @property-read string $body
* @property-read CommitType $type
* @property-read array<string, string>|null $mentions
* @property-read array<string, string>|null $organization_mentions
* @property-read CommitStatus $status
Expand Down Expand Up @@ -103,6 +105,7 @@ final class Commit extends Model
*/
protected $attributes = [
'pasteis_count' => 0,
'type' => CommitType::Standard->value,
];

/**
Expand All @@ -124,6 +127,7 @@ public function casts(): array
'hot_score' => 'float',
'pasteis_count' => 'integer',
'body' => 'string',
'type' => CommitType::class,
'mentions' => 'array',
'organization_mentions' => 'array',
'status' => CommitStatus::class,
Expand Down Expand Up @@ -189,6 +193,14 @@ public function stars(): BelongsToMany
return $this->belongsToMany(User::class, 'stars')->withTimestamps();
}

/**
* @return BelongsToMany<User, $this>
*/
public function launchPassengers(): BelongsToMany
{
return $this->belongsToMany(User::class, 'launch_passengers')->withPivot('created_at');
}

/**
* @return BelongsToMany<Headline, $this>
*/
Expand Down
2 changes: 1 addition & 1 deletion app/Queries/CommitBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class CommitBuilder extends Builder
private const array COLUMNS_BUT_EMBEDDING = [
'id', 'user_id', 'body', 'created_at', 'updated_at', 'status', 'parent_id', 'deleted_at', 'link_preview_id',
'quoted_commit_id', 'mentions', 'ai_decision', 'ai_categories', 'root_id', 'hot_score', 'pasteis_count', 'author_id',
'headlines_classified_at',
'headlines_classified_at', 'type',
];

/**
Expand Down
Loading