Can you put “sign in” in the header for people that haven’t signed in get a…

merged…
osebo32d ago

Can you put “sign in” in the header for people that haven’t signed in get a link?

IMG_8698.jpeg
IMG_8698.jpeg
9 repliesoldestnewest
Osebotfable-5-132d ago

The screenshot shows the phone header for a signed-out visitor: door button + workspace name, and the right side (where the avatar sits when signed in) is empty. Plan:

  • New client component components/sign-in-link.tsx: a "Sign in" link to /signin?next=<current path> (so GitHub sign-in lands you back on the thread/workspace you were reading). Hidden on /signin itself.
  • app/layout.tsx renders it inside .top-user when there is no session, where UserMenu otherwise goes, so it takes the same spot in all three header modes (phone bar, top bar, ≥901px sidebar bottom).
  • CSS in the header section of app/globals.css: drawn like the other header controls (14px sans, --fill chip), spanning the column in sidebar mode like the avatar button does.

Will mock it up at 390px and desktop for a screenshot.

Osebotfable-5-132d agothreadide@bef343f

Done: signed-out visitors get a Sign in link in the header, in the same spot the avatar menu takes once signed in.

What changed

  • components/sign-in-link.tsx (new): a Sign in link to /signin?next=<current path>, so after GitHub sign-in you land back on the thread or workspace you were reading (no next on /). Renders nothing on /signin itself, so that page keeps its empty slot.
  • app/layout.tsx: span.top-user now holds {user ? <UserMenu/> : <SignInLink/>}.
  • app/globals.css: a.sign-in-link drawn as a --fill chip at the avatar button's height (14px sans, no underline, hover --fill-hover); in the ≥901px sidebar it spans the column at the bottom, like the avatar button does.

Checked

  • npx tsc --noEmit clean.
  • Static mockup over the real globals.css at 390px (light and dark), 700px (top bar with wrapped links) and 1100px (sidebar); screenshots attached. The app itself can't run in the sandbox (needs Postgres + GitHub OAuth).

The guest note under the composer ("You're posting as a guest; sign in …") is unchanged, so there are now two ways in on a thread page.

Phone (390px), signed out: Sign in chip right of the workspace name (static mockup over the real globals.css)
Phone (390px), signed out: Sign in chip right of the workspace name (static mockup over the real globals.css)
Desktop sidebar (≥901px), signed out: Sign in spans the column at the bottom where the avatar menu sits
Desktop sidebar (≥901px), signed out: Sign in spans the column at the bottom where the avatar menu sits
oseboasked Osebot32d ago

But we also don’t need the second part of the sentence that says to sign in

Osebotfable-5-132d ago

Trimming the guest note on both pages to just "You're posting as a guest." (dropping "; sign in to post under your account") now that the header carries the Sign in link. Thread page and workspace home both have the note; the signIn href on the workspace page becomes unused and goes too.

Osebotfable-5-132d agothreadide@71eb791

Done: the guest note is now just "You're posting as a guest." on both places it appears, the thread page (app/threads/[id]/page.tsx, under the compose dock) and the workspace home (app/[workspace]/page.tsx, above the start-a-thread composer). The "; sign in to post under your account" tail with its link is gone; the header's Sign in link is the one way in.

Also removed the now-unused signIn href and Link import on the workspace page. npx tsc --noEmit clean.

Note for later: the sandbox checkout had drifted back to main, so I reset to the branch tip (bef343f) before editing; both commits are on thread/c8100337.

Diff · 2 files
--- a/threadide/app/threads/[id]/page.tsx
+++ b/threadide/app/threads/[id]/page.tsx
@@ -154,8 +154,7 @@
             {!user ? (
               <p className="muted guest-note">
-                You&apos;re posting as a guest;{" "}
-                <Link href={`/signin?next=${encodeURIComponent(`/threads/${thread.id}`)}`}>sign in</Link> to post under your account.
+                You&apos;re posting as a guest.
               </p>
--- a/threadide/app/[workspace]/page.tsx
+++ b/threadide/app/[workspace]/page.tsx
@@ -1,7 +1,6 @@
 import { after } from "next/server";
-import Link from "next/link";
@@ -65,7 +64,6 @@
-  const signIn = `/signin?next=${encodeURIComponent(`/${slug}`)}`;
@@ -87,7 +86,7 @@
             <p className="muted guest-note">
-              You&apos;re posting as a guest; <Link href={signIn}>sign in</Link> to post under your account.
+              You&apos;re posting as a guest.
             </p>
oseboasked Osebot32d ago

I want to merge but I’m getting this error

IMG_8699.jpeg
IMG_8699.jpeg
Osebotfable-5-132d ago

Found the cause. The Merge button pins the merge to the PR's head commit as GitHub's pulls API reports it, and GitHub's view of #138 is stale: the API still says head = bef343f (1 commit, mergeable "unknown") while the branch thread/c8100337 is actually at 71eb791 (the guest-note commit pushed at 15:12). GitHub's merge endpoint compares the pinned sha against the real branch tip, so it answered 409, which we show as "changed while you were looking". Nothing is wrong with the PR itself; GitHub just hasn't finished syncing the PR to the second push.

Plan:

  1. lib/merge.ts: read the live branch tip (git/ref/heads/<branch>) and pin the merge to that instead of the PR's possibly stale head (same guard against a push landing between check and merge, minus the dependency on GitHub's PR sync). On a 409 include GitHub's own message.
  2. Commit + push. The push also sends GitHub a fresh "synchronize" for #138, which should unstick its head; then reloading the thread and pressing Merge again should work even before this fix is deployed.
Osebotfable-5-132d agothreadide@bd1aa64

What went wrong: nothing on your side. The Merge button pins the merge to the PR's head commit as GitHub's pulls API reports it, and GitHub's copy of #138 was stale: the API still said head = bef343f ("1 commit", mergeable "unknown") four minutes after I pushed the second commit 71eb791 to thread/c8100337. GitHub's merge endpoint checks the pinned sha against the real branch tip, so it answered 409, which the panel shows as "changed while you were looking". GitHub refreshes a PR's head in the background after a push and it can lag like this.

Now: the push below sent GitHub a fresh sync and #138 is caught up (head bd1aa64, 3 commits). Reload the thread and press Merge again; it should go through. If it says "GitHub refused the merge" instead, GitHub is still computing mergeability (it was still "unknown" a minute after the push); give it a moment and retry.

Fix for next time (lib/merge.ts, commit bd1aa64): mergeThreadPullRequest now reads the branch tip from git/ref/heads/<branch> and pins the merge to that instead of the PR's head.sha. Same guard against a push landing between the check and the merge, but no longer dependent on GitHub's PR sync. The PR head stays as a fallback if the ref read fails, and the 409 message now includes GitHub's own detail (e.g. "Head branch was modified"). npx tsc --noEmit clean. I could not exercise the PUT itself without merging your PR; the diagnosis was checked against the live API.

Also: the sandbox checkout had drifted back to main again, so I rebased onto 71eb791 before pushing; the branch is bef343f → 71eb791 → bd1aa64.

Osebot32d ago

Merged threadide #138 by @osebo (merge, c92f3ac).