gh-manager-cli 1.6.2 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,15 +1,25 @@
1
1
  #!/usr/bin/env node
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __commonJS = (cb, mod) => function __require() {
4
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
5
- };
2
+ import {
3
+ __commonJS,
4
+ archiveRepositoryById,
5
+ deleteRepositoryRest,
6
+ fetchViewerOrganizations,
7
+ fetchViewerReposPageUnified,
8
+ getViewerLogin,
9
+ inspectCacheStatus,
10
+ makeClient,
11
+ purgeApolloCacheFiles,
12
+ searchRepositoriesUnified,
13
+ syncForkWithUpstream,
14
+ unarchiveRepositoryById
15
+ } from "./chunk-OQGG2X5P.js";
6
16
 
7
17
  // package.json
8
18
  var require_package = __commonJS({
9
19
  "package.json"(exports, module) {
10
20
  module.exports = {
11
21
  name: "gh-manager-cli",
12
- version: "1.6.2",
22
+ version: "1.8.0",
13
23
  private: false,
14
24
  description: "Interactive CLI to manage your GitHub repos (personal) with Ink",
15
25
  license: "MIT",
@@ -125,12 +135,12 @@ var require_package = __commonJS({
125
135
  });
126
136
 
127
137
  // src/index.tsx
128
- import { render, Box as Box3, Text as Text3 } from "ink";
138
+ import { render, Box as Box4, Text as Text4 } from "ink";
129
139
  import "dotenv/config";
130
140
 
131
141
  // src/ui/App.tsx
132
- import { useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
133
- import { Box as Box2, Text as Text2, useApp as useApp2, useStdout as useStdout2, useInput as useInput2 } from "ink";
142
+ import { useEffect as useEffect3, useMemo as useMemo2, useState as useState3 } from "react";
143
+ import { Box as Box3, Text as Text3, useApp as useApp2, useStdout as useStdout2, useInput as useInput3 } from "ink";
134
144
  import TextInput2 from "ink-text-input";
135
145
 
136
146
  // src/config.ts
@@ -186,490 +196,23 @@ function storeUIPrefs(patch) {
186
196
  writeConfig({ ...existing, ui: mergedUI });
187
197
  }
188
198
 
189
- // src/github.ts
190
- import { graphql as makeGraphQL } from "@octokit/graphql";
191
- import { ApolloClient, InMemoryCache, HttpLink, gql } from "@apollo/client/core/index.js";
192
- import { persistCache } from "apollo3-cache-persist";
193
- import fs2 from "fs";
194
- import path2 from "path";
195
- import envPaths2 from "env-paths";
196
- function makeClient(token) {
197
- return makeGraphQL.defaults({
198
- headers: { authorization: `token ${token}` }
199
- });
200
- }
201
- async function makeApolloClient(token) {
202
- try {
203
- if (typeof globalThis.fetch === "undefined") {
204
- throw new Error("Fetch API not available. Node 18+ is required.");
205
- }
206
- const cache = new InMemoryCache();
207
- const storage = {
208
- async getItem(key) {
209
- try {
210
- const p = envPaths2("gh-manager-cli").data;
211
- const file = path2.join(p, "apollo-cache.json");
212
- return fs2.readFileSync(file, "utf8");
213
- } catch {
214
- return null;
215
- }
216
- },
217
- async setItem(key, value) {
218
- try {
219
- const p = envPaths2("gh-manager-cli").data;
220
- fs2.mkdirSync(p, { recursive: true });
221
- const file = path2.join(p, "apollo-cache.json");
222
- fs2.writeFileSync(file, value, "utf8");
223
- if (process.platform !== "win32") {
224
- try {
225
- fs2.chmodSync(file, 384);
226
- } catch {
227
- }
228
- }
229
- } catch {
230
- }
231
- },
232
- async removeItem(key) {
233
- try {
234
- const p = envPaths2("gh-manager-cli").data;
235
- const file = path2.join(p, "apollo-cache.json");
236
- fs2.unlinkSync(file);
237
- } catch {
238
- }
239
- }
240
- };
241
- await persistCache({ cache, storage, debounce: 500, maxSize: 5 * 1024 * 1024 });
242
- const link = new HttpLink({
243
- uri: "https://api.github.com/graphql",
244
- fetch: globalThis.fetch,
245
- headers: { authorization: `Bearer ${token}` }
246
- });
247
- const client = new ApolloClient({ cache, link });
248
- return { client, gql };
249
- } catch (error) {
250
- const debug = process.env.GH_MANAGER_DEBUG === "1";
251
- if (debug) {
252
- process.stderr.write(`
253
- \u274C Failed to initialize Apollo Client: ${error.message}
254
- `);
255
- if (error.stack) {
256
- process.stderr.write(`Stack: ${error.stack}
257
- `);
258
- }
259
- }
260
- throw new Error(`Apollo Client initialization failed: ${error.message}`);
261
- }
262
- }
263
- async function getViewerLogin(client) {
264
- const query = (
265
- /* GraphQL */
266
- `
267
- query ViewerLogin {
268
- viewer {
269
- login
270
- }
271
- }
272
- `
273
- );
274
- const res = await client(query);
275
- return res.viewer.login;
276
- }
277
- async function fetchViewerReposPage(client, first, after, orderBy, includeForkTracking = true) {
278
- const sortField = orderBy?.field || "UPDATED_AT";
279
- const sortDirection = orderBy?.direction || "DESC";
280
- const query = (
281
- /* GraphQL */
282
- `
283
- query ViewerRepos(
284
- $first: Int!
285
- $after: String
286
- $sortField: RepositoryOrderField!
287
- $sortDirection: OrderDirection!
288
- ) {
289
- rateLimit {
290
- limit
291
- remaining
292
- resetAt
293
- }
294
- viewer {
295
- repositories(
296
- ownerAffiliations: OWNER
297
- first: $first
298
- after: $after
299
- orderBy: { field: $sortField, direction: $sortDirection }
300
- ) {
301
- totalCount
302
- pageInfo {
303
- endCursor
304
- hasNextPage
305
- }
306
- nodes {
307
- id
308
- name
309
- nameWithOwner
310
- description
311
- visibility
312
- isPrivate
313
- isFork
314
- isArchived
315
- stargazerCount
316
- forkCount
317
- primaryLanguage {
318
- name
319
- color
320
- }
321
- updatedAt
322
- pushedAt
323
- diskUsage
324
- ${includeForkTracking ? `
325
- parent {
326
- nameWithOwner
327
- defaultBranchRef {
328
- name
329
- target {
330
- ... on Commit {
331
- history(first: 0) {
332
- totalCount
333
- }
334
- }
335
- }
336
- }
337
- }
338
- defaultBranchRef {
339
- name
340
- target {
341
- ... on Commit {
342
- history(first: 0) {
343
- totalCount
344
- }
345
- }
346
- }
347
- }` : `
348
- parent {
349
- nameWithOwner
350
- }
351
- defaultBranchRef { name }
352
- `}
353
- }
354
- }
355
- }
356
- }
357
- `
358
- );
359
- const res = await client(query, {
360
- first,
361
- after: after ?? null,
362
- sortField,
363
- sortDirection
364
- });
365
- const data = res.viewer.repositories;
366
- return {
367
- nodes: data.nodes,
368
- endCursor: data.pageInfo.endCursor,
369
- hasNextPage: data.pageInfo.hasNextPage,
370
- totalCount: data.totalCount,
371
- rateLimit: res.rateLimit
372
- };
373
- }
374
- async function fetchViewerReposPageUnified(token, first, after, orderBy, includeForkTracking = true, fetchPolicy = "cache-first") {
375
- const isApolloEnabled = true;
376
- const debug = process.env.GH_MANAGER_DEBUG === "1";
377
- if (debug) {
378
- console.log(`\u{1F50D} Apollo enabled: ${isApolloEnabled}, Policy: ${fetchPolicy}, After: ${after || "null"}`);
379
- }
380
- try {
381
- if (isApolloEnabled) {
382
- if (debug) console.log("\u{1F680} Attempting Apollo Client...");
383
- const ap = await makeApolloClient(token);
384
- const sortField = orderBy?.field || "UPDATED_AT";
385
- const sortDirection = orderBy?.direction || "DESC";
386
- const q = ap.gql`
387
- query ViewerRepos($first: Int!, $after: String, $sortField: RepositoryOrderField!, $sortDirection: OrderDirection!) {
388
- rateLimit { limit remaining resetAt }
389
- viewer {
390
- repositories(ownerAffiliations: OWNER, first: $first, after: $after, orderBy: { field: $sortField, direction: $sortDirection }) {
391
- totalCount
392
- pageInfo { endCursor hasNextPage }
393
- nodes {
394
- id
395
- name
396
- nameWithOwner
397
- description
398
- visibility
399
- isPrivate
400
- isFork
401
- isArchived
402
- stargazerCount
403
- forkCount
404
- primaryLanguage { name color }
405
- updatedAt
406
- pushedAt
407
- diskUsage
408
- ${includeForkTracking ? `
409
- parent { nameWithOwner defaultBranchRef { name target { ... on Commit { history(first: 0) { totalCount } } } } }
410
- defaultBranchRef { name target { ... on Commit { history(first: 0) { totalCount } } } }` : `
411
- parent { nameWithOwner }
412
- defaultBranchRef { name }`}
413
- }
414
- }
415
- }
416
- }
417
- `;
418
- const startTime = Date.now();
419
- const res = await ap.client.query({
420
- query: q,
421
- variables: { first, after: after ?? null, sortField, sortDirection },
422
- fetchPolicy
423
- });
424
- const duration = Date.now() - startTime;
425
- if (debug) {
426
- console.log(`\u26A1 Apollo query completed in ${duration}ms`);
427
- console.log(`\u{1F4CA} From cache: ${res.loading === false && duration < 50 ? "YES" : "NO"}`);
428
- console.log(`\u{1F504} Network status: ${res.networkStatus}`);
429
- }
430
- const data = res.data.viewer.repositories;
431
- return {
432
- nodes: data.nodes,
433
- endCursor: data.pageInfo.endCursor,
434
- hasNextPage: data.pageInfo.hasNextPage,
435
- totalCount: data.totalCount,
436
- rateLimit: res.data.rateLimit
437
- };
438
- }
439
- } catch (e) {
440
- if (debug) console.log(`\u274C Apollo failed, falling back to Octokit:`, e.message);
441
- }
442
- if (debug) console.log("\u{1F4E1} Using Octokit fallback...");
443
- const octo = makeClient(token);
444
- return fetchViewerReposPage(octo, first, after, orderBy, includeForkTracking);
445
- }
446
- async function searchRepositoriesUnified(token, viewer, text, first, after, sortKey = "UPDATED_AT", sortDir = "DESC", includeForkTracking = true, fetchPolicy = "network-only") {
447
- const q = `${text} user:${viewer} in:name,description fork:true`;
448
- try {
449
- const ap = await makeApolloClient(token);
450
- const queryDoc = ap.gql`
451
- query SearchRepos($q: String!, $first: Int!, $after: String) {
452
- rateLimit { limit remaining resetAt }
453
- search(query: $q, type: REPOSITORY, first: $first, after: $after) {
454
- repositoryCount
455
- pageInfo { endCursor hasNextPage }
456
- nodes {
457
- ... on Repository {
458
- id
459
- name
460
- nameWithOwner
461
- description
462
- visibility
463
- isPrivate
464
- isFork
465
- isArchived
466
- stargazerCount
467
- forkCount
468
- primaryLanguage { name color }
469
- updatedAt
470
- pushedAt
471
- diskUsage
472
- ${includeForkTracking ? `
473
- parent { nameWithOwner defaultBranchRef { name target { ... on Commit { history(first: 0) { totalCount } } } } }
474
- defaultBranchRef { name target { ... on Commit { history(first: 0) { totalCount } } } }` : `
475
- parent { nameWithOwner }
476
- defaultBranchRef { name }`}
477
- }
478
- }
479
- }
480
- }
481
- `;
482
- const res = await ap.client.query({
483
- query: queryDoc,
484
- variables: { q, first, after: after ?? null },
485
- fetchPolicy
486
- });
487
- const data = res.data.search;
488
- return {
489
- nodes: data.nodes,
490
- endCursor: data.pageInfo.endCursor,
491
- hasNextPage: data.pageInfo.hasNextPage,
492
- totalCount: data.repositoryCount,
493
- rateLimit: res.data.rateLimit
494
- };
495
- } catch (e) {
496
- const debug = process.env.GH_MANAGER_DEBUG === "1";
497
- if (debug) {
498
- process.stderr.write(`
499
- \u274C Search failed: ${e.message}
500
- `);
501
- if (e.graphQLErrors) {
502
- process.stderr.write(`GraphQL errors: ${JSON.stringify(e.graphQLErrors, null, 2)}
503
- `);
504
- }
505
- if (e.networkError) {
506
- process.stderr.write(`Network error: ${e.networkError.message}
507
- `);
508
- }
509
- }
510
- throw e;
511
- }
512
- }
513
- async function deleteRepositoryRest(token, owner, repo) {
514
- const url = `https://api.github.com/repos/${owner}/${repo}`;
515
- const res = await fetch(url, {
516
- method: "DELETE",
517
- headers: {
518
- "Authorization": `token ${token}`,
519
- "Accept": "application/vnd.github+json",
520
- "User-Agent": "gh-manager-cli"
521
- }
522
- });
523
- if (res.status === 204) return;
524
- let msg = `GitHub REST delete failed (status ${res.status})`;
525
- try {
526
- const body = await res.json();
527
- if (body && body.message) msg += `: ${body.message}`;
528
- } catch {
529
- }
530
- throw new Error(msg);
531
- }
532
- async function archiveRepositoryById(client, repositoryId) {
533
- const mutation = (
534
- /* GraphQL */
535
- `
536
- mutation ArchiveRepo($repositoryId: ID!) {
537
- archiveRepository(input: { repositoryId: $repositoryId }) {
538
- clientMutationId
539
- }
540
- }
541
- `
542
- );
543
- await client(mutation, { repositoryId });
544
- }
545
- async function unarchiveRepositoryById(client, repositoryId) {
546
- const mutation = (
547
- /* GraphQL */
548
- `
549
- mutation UnarchiveRepo($repositoryId: ID!) {
550
- unarchiveRepository(input: { repositoryId: $repositoryId }) {
551
- clientMutationId
552
- }
553
- }
554
- `
555
- );
556
- await client(mutation, { repositoryId });
557
- }
558
- async function syncForkWithUpstream(token, owner, repo, branch = "main") {
559
- const url = `https://api.github.com/repos/${owner}/${repo}/merge-upstream`;
560
- const res = await fetch(url, {
561
- method: "POST",
562
- headers: {
563
- "Authorization": `token ${token}`,
564
- "Accept": "application/vnd.github+json",
565
- "User-Agent": "gh-manager-cli"
566
- },
567
- body: JSON.stringify({ branch })
568
- });
569
- if (res.status === 204) {
570
- return { message: "Already up-to-date", merge_type: "none", base_branch: branch };
571
- }
572
- if (res.status === 200) {
573
- const body = await res.json();
574
- return body;
575
- }
576
- let msg = `Fork sync failed (status ${res.status})`;
577
- try {
578
- const body = await res.json();
579
- if (body && body.message) {
580
- msg += `: ${body.message}`;
581
- if (res.status === 409) {
582
- msg += " (conflicts detected - manual merge required)";
583
- }
584
- }
585
- } catch {
586
- }
587
- throw new Error(msg);
588
- }
589
- async function purgeApolloCacheFiles() {
590
- try {
591
- const fs4 = await import("fs");
592
- const path4 = await import("path");
593
- const envPaths4 = (await import("env-paths")).default;
594
- const p = envPaths4("gh-manager-cli").data;
595
- const cacheFile = path4.join(p, "apollo-cache.json");
596
- const metaFile = path4.join(p, "apollo-cache-meta.json");
597
- if (process.env.GH_MANAGER_DEBUG === "1") {
598
- console.log(`\u{1F5D1}\uFE0F Purging cache files from: ${p}`);
599
- }
600
- try {
601
- fs4.unlinkSync(cacheFile);
602
- } catch {
603
- }
604
- try {
605
- fs4.unlinkSync(metaFile);
606
- } catch {
607
- }
608
- } catch {
609
- }
610
- }
611
- async function inspectCacheStatus() {
612
- try {
613
- const fs4 = await import("fs");
614
- const path4 = await import("path");
615
- const envPaths4 = (await import("env-paths")).default;
616
- const p = envPaths4("gh-manager-cli").data;
617
- const cacheFile = path4.join(p, "apollo-cache.json");
618
- const metaFile = path4.join(p, "apollo-cache-meta.json");
619
- process.stderr.write(`
620
- \u{1F4C2} Cache directory: ${p}
621
- `);
622
- try {
623
- const cacheStats = fs4.statSync(cacheFile);
624
- process.stderr.write(`\u{1F4BE} Cache file: ${Math.round(cacheStats.size / 1024)}KB (${cacheStats.mtime.toISOString()})
625
- `);
626
- } catch {
627
- process.stderr.write(`\u{1F4BE} Cache file: NOT FOUND
628
- `);
629
- }
630
- try {
631
- const metaStats = fs4.statSync(metaFile);
632
- const metaContent = fs4.readFileSync(metaFile, "utf8");
633
- const meta = JSON.parse(metaContent);
634
- process.stderr.write(`\u{1F4CA} Meta file: ${Object.keys(meta.fetched || {}).length} entries (${metaStats.mtime.toISOString()})
635
- `);
636
- const entries = Object.entries(meta.fetched || {});
637
- if (entries.length > 0) {
638
- process.stderr.write("\u{1F4CB} Recent cache entries:\n");
639
- entries.slice(-3).forEach(([key, timestamp]) => {
640
- const age = Date.now() - Date.parse(timestamp);
641
- process.stderr.write(` ${key} (${Math.round(age / 1e3)}s ago)
642
- `);
643
- });
644
- }
645
- } catch {
646
- process.stderr.write(`\u{1F4CA} Meta file: NOT FOUND
647
- `);
648
- }
649
- process.stderr.write("\n");
650
- } catch (e) {
651
- process.stderr.write(`\u274C Cache inspection failed: ${e.message}
652
- `);
653
- }
654
- }
655
-
656
199
  // src/ui/RepoList.tsx
657
- import React, { useEffect, useMemo, useState } from "react";
658
- import { Box, Text, useApp, useInput, useStdout } from "ink";
200
+ import React2, { useEffect as useEffect2, useMemo, useState as useState2 } from "react";
201
+ import { Box as Box2, Text as Text2, useApp, useInput as useInput2, useStdout } from "ink";
659
202
  import TextInput from "ink-text-input";
660
- import chalk from "chalk";
203
+ import chalk2 from "chalk";
661
204
 
662
205
  // src/apolloMeta.ts
663
- import fs3 from "fs";
664
- import path3 from "path";
665
- import envPaths3 from "env-paths";
666
- var paths2 = envPaths3("gh-manager-cli");
206
+ import fs2 from "fs";
207
+ import path2 from "path";
208
+ import envPaths2 from "env-paths";
209
+ var paths2 = envPaths2("gh-manager-cli");
667
210
  var dataDir = paths2.data;
668
- var metaPath = path3.join(dataDir, "apollo-cache-meta.json");
211
+ var metaPath = path2.join(dataDir, "apollo-cache-meta.json");
669
212
  var VERSION = 1;
670
213
  function readMeta() {
671
214
  try {
672
- const raw = fs3.readFileSync(metaPath, "utf8");
215
+ const raw = fs2.readFileSync(metaPath, "utf8");
673
216
  const parsed = JSON.parse(raw);
674
217
  if (parsed && typeof parsed === "object" && parsed.fetched) return parsed;
675
218
  } catch {
@@ -678,11 +221,11 @@ function readMeta() {
678
221
  }
679
222
  function writeMeta(meta) {
680
223
  try {
681
- fs3.mkdirSync(dataDir, { recursive: true });
682
- fs3.writeFileSync(metaPath, JSON.stringify(meta, null, 2), "utf8");
224
+ fs2.mkdirSync(dataDir, { recursive: true });
225
+ fs2.writeFileSync(metaPath, JSON.stringify(meta, null, 2), "utf8");
683
226
  if (process.platform !== "win32") {
684
227
  try {
685
- fs3.chmodSync(metaPath, 384);
228
+ fs2.chmodSync(metaPath, 384);
686
229
  } catch {
687
230
  }
688
231
  }
@@ -691,7 +234,9 @@ function writeMeta(meta) {
691
234
  }
692
235
  function makeApolloKey(opts) {
693
236
  const v = opts.viewer || "unknown";
694
- return `viewer:${v}|sort:${opts.sortKey}:${opts.sortDir}|ps:${opts.pageSize}|forks:${opts.forkTracking ? "1" : "0"}`;
237
+ const context = opts.ownerContext || "personal";
238
+ const affiliations = opts.affiliations || "OWNER";
239
+ return `viewer:${v}|context:${context}|affiliations:${affiliations}|sort:${opts.sortKey}:${opts.sortDir}|ps:${opts.pageSize}|forks:${opts.forkTracking ? "1" : "0"}`;
695
240
  }
696
241
  function makeSearchKey(opts) {
697
242
  const v = opts.viewer || "unknown";
@@ -714,18 +259,89 @@ function markFetched(key) {
714
259
 
715
260
  // src/ui/RepoList.tsx
716
261
  import { exec } from "child_process";
717
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
262
+
263
+ // src/ui/OrgSwitcher.tsx
264
+ import { useEffect, useState } from "react";
265
+ import { Box, Text, useInput } from "ink";
266
+ import chalk from "chalk";
267
+ import { jsx, jsxs } from "react/jsx-runtime";
268
+ function OrgSwitcher({ token, currentContext, onSelect, onClose }) {
269
+ const [organizations, setOrganizations] = useState([]);
270
+ const [loading, setLoading] = useState(true);
271
+ const [error, setError] = useState(null);
272
+ const [cursor, setCursor] = useState(0);
273
+ const isPersonalContext = currentContext === "personal";
274
+ useEffect(() => {
275
+ const loadOrgs = async () => {
276
+ try {
277
+ setLoading(true);
278
+ const client = await import("./github-TWXF5AWM.js").then((m) => m.makeClient(token));
279
+ const orgs = await fetchViewerOrganizations(client);
280
+ setOrganizations(orgs);
281
+ if (!isPersonalContext) {
282
+ const orgLogin2 = currentContext.login;
283
+ const index = orgs.findIndex((org) => org.login === orgLogin2);
284
+ if (index !== -1) {
285
+ setCursor(index + 1);
286
+ }
287
+ }
288
+ } catch (e) {
289
+ setError(e.message || "Failed to load organizations");
290
+ } finally {
291
+ setLoading(false);
292
+ }
293
+ };
294
+ loadOrgs();
295
+ }, [token, currentContext, isPersonalContext]);
296
+ useInput((input, key) => {
297
+ if (key.escape) {
298
+ onClose();
299
+ return;
300
+ }
301
+ if (key.return) {
302
+ if (cursor === 0) {
303
+ onSelect("personal");
304
+ } else if (cursor <= organizations.length) {
305
+ const org = organizations[cursor - 1];
306
+ onSelect({
307
+ type: "organization",
308
+ login: org.login,
309
+ name: org.name || void 0
310
+ });
311
+ }
312
+ return;
313
+ }
314
+ if (key.upArrow) {
315
+ setCursor((c) => Math.max(0, c - 1));
316
+ } else if (key.downArrow) {
317
+ setCursor((c) => Math.min(organizations.length, c + 1));
318
+ }
319
+ });
320
+ const totalItems = organizations.length + 1;
321
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 3, paddingY: 2, width: 60, children: [
322
+ /* @__PURE__ */ jsx(Text, { bold: true, children: "Switch Account/Organization" }),
323
+ loading ? /* @__PURE__ */ jsx(Text, { color: "yellow", children: "Loading organizations..." }) : error ? /* @__PURE__ */ jsx(Text, { color: "red", children: error }) : /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
324
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { children: cursor === 0 ? chalk.bgCyan.black(" \u2192 ") + " " + chalk.bold("Personal Account") : " " + chalk.gray("Personal Account") }) }),
325
+ organizations.map((org, index) => /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { children: cursor === index + 1 ? chalk.bgCyan.black(" \u2192 ") + " " + chalk.bold(org.name || org.login) + chalk.gray(` (@${org.login})`) : " " + chalk.gray(org.name || org.login) + chalk.gray(` (@${org.login})`) }) }, org.id)),
326
+ organizations.length === 0 && /* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: "No organizations found" })
327
+ ] }),
328
+ /* @__PURE__ */ jsx(Box, { marginTop: 2, children: /* @__PURE__ */ jsx(Text, { color: "gray", children: "\u2191/\u2193 Navigate \u2022 Enter Select \u2022 Esc Cancel" }) })
329
+ ] });
330
+ }
331
+
332
+ // src/ui/RepoList.tsx
333
+ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
718
334
  var PAGE_SIZE = process.env.GH_MANAGER_DEV === "1" || process.env.NODE_ENV === "development" ? 5 : 15;
719
335
  function SlowSpinner() {
720
336
  const frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
721
- const [frame, setFrame] = useState(0);
722
- useEffect(() => {
337
+ const [frame, setFrame] = useState2(0);
338
+ useEffect2(() => {
723
339
  const timer = setInterval(() => {
724
340
  setFrame((f) => (f + 1) % frames.length);
725
341
  }, 500);
726
342
  return () => clearInterval(timer);
727
343
  }, [frames.length]);
728
- return /* @__PURE__ */ jsx(Text, { children: frames[frame] });
344
+ return /* @__PURE__ */ jsx2(Text2, { children: frames[frame] });
729
345
  }
730
346
  function truncate(str, max = 80) {
731
347
  if (str.length <= max) return str;
@@ -750,90 +366,93 @@ function RepoRow({ repo, selected, index, maxWidth, spacingLines, dim, forkTrack
750
366
  const commitsBehind = hasCommitData ? repo.parent.defaultBranchRef.target.history.totalCount - repo.defaultBranchRef.target.history.totalCount : 0;
751
367
  const showCommitsBehind = forkTracking && hasCommitData;
752
368
  let line1 = "";
753
- const numColor = selected ? chalk.cyan : chalk.gray;
754
- const nameColor = selected ? chalk.cyan.bold : chalk.white;
369
+ const numColor = selected ? chalk2.cyan : chalk2.gray;
370
+ const nameColor = selected ? chalk2.cyan.bold : chalk2.white;
755
371
  line1 += numColor(`${String(index).padStart(3, " ")}.`);
756
372
  line1 += nameColor(` ${repo.nameWithOwner}`);
757
- if (repo.isPrivate) line1 += chalk.yellow(" Private");
758
- if (repo.isArchived) line1 += " " + chalk.bgGray.whiteBright(" Archived ") + " ";
373
+ if (repo.isPrivate) line1 += chalk2.yellow(" Private");
374
+ if (repo.isArchived) line1 += " " + chalk2.bgGray.whiteBright(" Archived ") + " ";
759
375
  if (repo.isFork && repo.parent) {
760
- line1 += chalk.blue(` Fork of ${repo.parent.nameWithOwner}`);
376
+ line1 += chalk2.blue(` Fork of ${repo.parent.nameWithOwner}`);
761
377
  if (showCommitsBehind) {
762
378
  if (commitsBehind > 0) {
763
- line1 += chalk.yellow(` (${commitsBehind} behind)`);
379
+ line1 += chalk2.yellow(` (${commitsBehind} behind)`);
764
380
  } else {
765
- line1 += chalk.green(` (0 behind)`);
381
+ line1 += chalk2.green(` (0 behind)`);
766
382
  }
767
383
  }
768
384
  }
769
385
  let line2 = " ";
770
- const metaColor = selected ? chalk.white : chalk.gray;
771
- if (langName) line2 += chalk.hex(langColor)("\u25CF ") + metaColor(`${langName} `);
386
+ const metaColor = selected ? chalk2.white : chalk2.gray;
387
+ if (langName) line2 += chalk2.hex(langColor)("\u25CF ") + metaColor(`${langName} `);
772
388
  line2 += metaColor(`\u2605 ${repo.stargazerCount} \u2442 ${repo.forkCount} Updated ${formatDate(repo.updatedAt)}`);
773
389
  const line3 = repo.description ? ` ${truncate(repo.description, Math.max(30, maxWidth - 10))}` : null;
774
390
  let fullText = line1 + "\n" + line2;
775
391
  if (line3) fullText += "\n" + metaColor(line3);
776
- return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", backgroundColor: selected ? "gray" : void 0, children: [
777
- /* @__PURE__ */ jsx(Text, { children: dim ? chalk.dim(fullText) : fullText }),
778
- spacingLines > 0 && /* @__PURE__ */ jsx(Box, { height: spacingLines, children: /* @__PURE__ */ jsx(Text, { children: " " }) })
392
+ return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", backgroundColor: selected ? "gray" : void 0, children: [
393
+ /* @__PURE__ */ jsx2(Text2, { children: dim ? chalk2.dim(fullText) : fullText }),
394
+ spacingLines > 0 && /* @__PURE__ */ jsx2(Box2, { height: spacingLines, children: /* @__PURE__ */ jsx2(Text2, { children: " " }) })
779
395
  ] });
780
396
  }
781
- function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
397
+ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextChange }) {
782
398
  const { exit } = useApp();
783
399
  const { stdout } = useStdout();
784
400
  const client = useMemo(() => makeClient(token), [token]);
785
- const [debugMessages, setDebugMessages] = useState([]);
401
+ const [debugMessages, setDebugMessages] = useState2([]);
786
402
  const addDebugMessage = (msg) => {
787
403
  if (process.env.GH_MANAGER_DEBUG === "1") {
788
404
  setDebugMessages((prev) => [...prev.slice(-9), msg]);
789
405
  }
790
406
  };
791
- React.useEffect(() => {
407
+ React2.useEffect(() => {
792
408
  addDebugMessage(`[RepoList] Component mounted`);
793
409
  }, []);
794
410
  const terminalWidth = stdout?.columns ?? 80;
795
411
  const availableHeight = maxVisibleRows ?? 20;
796
- const [items, setItems] = useState([]);
797
- const [cursor, setCursor] = useState(0);
798
- const [endCursor, setEndCursor] = useState(null);
799
- const [hasNextPage, setHasNextPage] = useState(false);
800
- const [totalCount, setTotalCount] = useState(0);
801
- const [loading, setLoading] = useState(true);
802
- const [sortingLoading, setSortingLoading] = useState(false);
803
- const [refreshing, setRefreshing] = useState(false);
804
- const [loadingMore, setLoadingMore] = useState(false);
805
- const [error, setError] = useState(null);
806
- const [rateLimit, setRateLimit] = useState(void 0);
807
- const [prevRateLimit, setPrevRateLimit] = useState(void 0);
808
- const [density, setDensity] = useState(2);
809
- const [prefsLoaded, setPrefsLoaded] = useState(false);
810
- const [searchItems, setSearchItems] = useState([]);
811
- const [searchEndCursor, setSearchEndCursor] = useState(null);
812
- const [searchHasNextPage, setSearchHasNextPage] = useState(false);
813
- const [searchTotalCount, setSearchTotalCount] = useState(0);
814
- const [searchLoading, setSearchLoading] = useState(false);
815
- const [deleteMode, setDeleteMode] = useState(false);
816
- const [deleteTarget, setDeleteTarget] = useState(null);
817
- const [deleteCode, setDeleteCode] = useState("");
818
- const [typedCode, setTypedCode] = useState("");
819
- const [deleting, setDeleting] = useState(false);
820
- const [deleteError, setDeleteError] = useState(null);
821
- const [deleteConfirmStage, setDeleteConfirmStage] = useState(false);
822
- const [confirmFocus, setConfirmFocus] = useState("delete");
823
- const [archiveMode, setArchiveMode] = useState(false);
824
- const [archiveTarget, setArchiveTarget] = useState(null);
825
- const [archiving, setArchiving] = useState(false);
826
- const [archiveError, setArchiveError] = useState(null);
827
- const [archiveFocus, setArchiveFocus] = useState("confirm");
828
- const [syncMode, setSyncMode] = useState(false);
829
- const [syncTarget, setSyncTarget] = useState(null);
830
- const [syncing, setSyncing] = useState(false);
831
- const [syncError, setSyncError] = useState(null);
832
- const [syncFocus, setSyncFocus] = useState("confirm");
833
- const [infoMode, setInfoMode] = useState(false);
834
- const [logoutMode, setLogoutMode] = useState(false);
835
- const [logoutFocus, setLogoutFocus] = useState("confirm");
836
- const [logoutError, setLogoutError] = useState(null);
412
+ const [items, setItems] = useState2([]);
413
+ const [cursor, setCursor] = useState2(0);
414
+ const [endCursor, setEndCursor] = useState2(null);
415
+ const [hasNextPage, setHasNextPage] = useState2(false);
416
+ const [totalCount, setTotalCount] = useState2(0);
417
+ const [loading, setLoading] = useState2(true);
418
+ const [sortingLoading, setSortingLoading] = useState2(false);
419
+ const [refreshing, setRefreshing] = useState2(false);
420
+ const [loadingMore, setLoadingMore] = useState2(false);
421
+ const [error, setError] = useState2(null);
422
+ const [rateLimit, setRateLimit] = useState2(void 0);
423
+ const [prevRateLimit, setPrevRateLimit] = useState2(void 0);
424
+ const [density, setDensity] = useState2(2);
425
+ const [prefsLoaded, setPrefsLoaded] = useState2(false);
426
+ const [ownerContext, setOwnerContext] = useState2("personal");
427
+ const [ownerAffiliations, setOwnerAffiliations] = useState2(["OWNER"]);
428
+ const [orgSwitcherOpen, setOrgSwitcherOpen] = useState2(false);
429
+ const [searchItems, setSearchItems] = useState2([]);
430
+ const [searchEndCursor, setSearchEndCursor] = useState2(null);
431
+ const [searchHasNextPage, setSearchHasNextPage] = useState2(false);
432
+ const [searchTotalCount, setSearchTotalCount] = useState2(0);
433
+ const [searchLoading, setSearchLoading] = useState2(false);
434
+ const [deleteMode, setDeleteMode] = useState2(false);
435
+ const [deleteTarget, setDeleteTarget] = useState2(null);
436
+ const [deleteCode, setDeleteCode] = useState2("");
437
+ const [typedCode, setTypedCode] = useState2("");
438
+ const [deleting, setDeleting] = useState2(false);
439
+ const [deleteError, setDeleteError] = useState2(null);
440
+ const [deleteConfirmStage, setDeleteConfirmStage] = useState2(false);
441
+ const [confirmFocus, setConfirmFocus] = useState2("delete");
442
+ const [archiveMode, setArchiveMode] = useState2(false);
443
+ const [archiveTarget, setArchiveTarget] = useState2(null);
444
+ const [archiving, setArchiving] = useState2(false);
445
+ const [archiveError, setArchiveError] = useState2(null);
446
+ const [archiveFocus, setArchiveFocus] = useState2("confirm");
447
+ const [syncMode, setSyncMode] = useState2(false);
448
+ const [syncTarget, setSyncTarget] = useState2(null);
449
+ const [syncing, setSyncing] = useState2(false);
450
+ const [syncError, setSyncError] = useState2(null);
451
+ const [syncFocus, setSyncFocus] = useState2("confirm");
452
+ const [infoMode, setInfoMode] = useState2(false);
453
+ const [logoutMode, setLogoutMode] = useState2(false);
454
+ const [logoutFocus, setLogoutFocus] = useState2("confirm");
455
+ const [logoutError, setLogoutError] = useState2(null);
837
456
  function closeArchiveModal() {
838
457
  setArchiveMode(false);
839
458
  setArchiveTarget(null);
@@ -848,6 +467,18 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
848
467
  setSyncError(null);
849
468
  setSyncFocus("confirm");
850
469
  }
470
+ function handleOrgContextChange(newContext) {
471
+ setOwnerContext(newContext);
472
+ storeUIPrefs({ ownerContext: newContext });
473
+ setCursor(0);
474
+ setOrgSwitcherOpen(false);
475
+ const newAffiliations = newContext === "personal" ? ["OWNER"] : ["ORGANIZATION_MEMBER"];
476
+ setOwnerAffiliations(newAffiliations);
477
+ storeUIPrefs({ ownerAffiliations: newAffiliations });
478
+ if (onOrgContextChange) {
479
+ onOrgContextChange(newContext);
480
+ }
481
+ }
851
482
  function cancelDeleteModal() {
852
483
  setDeleteMode(false);
853
484
  setDeleteTarget(null);
@@ -877,11 +508,11 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
877
508
  setDeleteError("Failed to delete repository. Ensure delete_repo scope and admin permissions.");
878
509
  }
879
510
  }
880
- const [filter, setFilter] = useState("");
881
- const [filterMode, setFilterMode] = useState(false);
882
- const [sortKey, setSortKey] = useState("updated");
883
- const [sortDir, setSortDir] = useState("desc");
884
- const [forkTracking, setForkTracking] = useState(true);
511
+ const [filter, setFilter] = useState2("");
512
+ const [filterMode, setFilterMode] = useState2(false);
513
+ const [sortKey, setSortKey] = useState2("updated");
514
+ const [sortDir, setSortDir] = useState2("desc");
515
+ const [forkTracking, setForkTracking] = useState2(true);
885
516
  const sortFieldMap = {
886
517
  "updated": "UPDATED_AT",
887
518
  "pushed": "PUSHED_AT",
@@ -901,13 +532,16 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
901
532
  field: sortFieldMap[sortKey],
902
533
  direction: sortDir.toUpperCase()
903
534
  };
535
+ const orgLogin2 = ownerContext !== "personal" ? ownerContext.login : void 0;
904
536
  const page = await fetchViewerReposPageUnified(
905
537
  token,
906
538
  PAGE_SIZE,
907
539
  after ?? null,
908
540
  orderBy,
909
541
  overrideForkTracking ?? forkTracking,
910
- policy ?? (after ? "network-only" : "cache-first")
542
+ policy ?? (after ? "network-only" : "cache-first"),
543
+ ownerAffiliations,
544
+ orgLogin2
911
545
  );
912
546
  setItems((prev) => reset || !after ? page.nodes : [...prev, ...page.nodes]);
913
547
  setEndCursor(page.endCursor);
@@ -920,7 +554,9 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
920
554
  sortKey,
921
555
  sortDir,
922
556
  pageSize: PAGE_SIZE,
923
- forkTracking: overrideForkTracking ?? forkTracking
557
+ forkTracking: overrideForkTracking ?? forkTracking,
558
+ ownerContext: orgLogin2 ? `org:${orgLogin2}` : "personal",
559
+ affiliations: ownerAffiliations.join(",")
924
560
  });
925
561
  markFetched(key);
926
562
  } catch {
@@ -996,7 +632,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
996
632
  setSearchLoading(false);
997
633
  }
998
634
  };
999
- useEffect(() => {
635
+ useEffect2(() => {
1000
636
  const ui = getUIPrefs();
1001
637
  if (ui.density !== void 0) setDensity(ui.density);
1002
638
  if (ui.sortKey && ["updated", "pushed", "name", "stars"].includes(ui.sortKey)) {
@@ -1007,35 +643,51 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1007
643
  }
1008
644
  if (ui.forkTracking !== void 0) setForkTracking(ui.forkTracking);
1009
645
  else setForkTracking(true);
646
+ if (ui.ownerContext) {
647
+ setOwnerContext(ui.ownerContext);
648
+ if (onOrgContextChange) {
649
+ onOrgContextChange(ui.ownerContext);
650
+ }
651
+ }
652
+ if (ui.ownerAffiliations && Array.isArray(ui.ownerAffiliations)) {
653
+ setOwnerAffiliations(ui.ownerAffiliations);
654
+ }
1010
655
  setPrefsLoaded(true);
1011
- }, []);
1012
- useEffect(() => {
656
+ }, [onOrgContextChange]);
657
+ useEffect2(() => {
1013
658
  if (!prefsLoaded) return;
1014
659
  let policy = "cache-first";
660
+ const orgLogin2 = ownerContext !== "personal" ? ownerContext.login : void 0;
1015
661
  try {
1016
662
  const key = makeApolloKey({
1017
663
  viewer: viewerLogin || "unknown",
1018
664
  sortKey,
1019
665
  sortDir,
1020
666
  pageSize: PAGE_SIZE,
1021
- forkTracking
667
+ forkTracking,
668
+ ownerContext: orgLogin2 ? `org:${orgLogin2}` : "personal",
669
+ affiliations: ownerAffiliations.join(",")
1022
670
  });
1023
671
  policy = isFresh(key) ? "cache-first" : "network-only";
1024
672
  } catch {
1025
673
  }
674
+ setCursor(0);
1026
675
  fetchPage(null, true, false, void 0, policy);
1027
- }, [client, prefsLoaded]);
1028
- useEffect(() => {
676
+ }, [client, prefsLoaded, ownerContext, ownerAffiliations]);
677
+ useEffect2(() => {
1029
678
  if (!searchActive) {
1030
679
  if (items.length > 0) {
1031
680
  let policy = "cache-first";
681
+ const orgLogin2 = ownerContext !== "personal" ? ownerContext.login : void 0;
1032
682
  try {
1033
683
  const key = makeApolloKey({
1034
684
  viewer: viewerLogin || "unknown",
1035
685
  sortKey,
1036
686
  sortDir,
1037
687
  pageSize: PAGE_SIZE,
1038
- forkTracking
688
+ forkTracking,
689
+ ownerContext: orgLogin2 ? `org:${orgLogin2}` : "personal",
690
+ affiliations: ownerAffiliations.join(",")
1039
691
  });
1040
692
  policy = isFresh(key) ? "cache-first" : "network-only";
1041
693
  } catch {
@@ -1061,7 +713,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1061
713
  }
1062
714
  }
1063
715
  }, [sortKey, sortDir]);
1064
- useEffect(() => {
716
+ useEffect2(() => {
1065
717
  if (viewerLogin && searchActive && !searchLoading && searchItems.length === 0) {
1066
718
  let policy = "cache-first";
1067
719
  try {
@@ -1071,7 +723,9 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1071
723
  sortKey,
1072
724
  sortDir,
1073
725
  pageSize: PAGE_SIZE,
1074
- forkTracking
726
+ forkTracking,
727
+ ownerContext: orgLogin ? `org:${orgLogin}` : "personal",
728
+ affiliations: ownerAffiliations.join(",")
1075
729
  });
1076
730
  policy = isFresh(key, 90 * 1e3) ? "cache-first" : "network-only";
1077
731
  } catch {
@@ -1079,7 +733,10 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1079
733
  fetchSearchPage(null, true, policy);
1080
734
  }
1081
735
  }, [viewerLogin]);
1082
- useInput((input, key) => {
736
+ useInput2((input, key) => {
737
+ if (orgSwitcherOpen) {
738
+ return;
739
+ }
1083
740
  if (deleteMode) {
1084
741
  if (key.escape || input && input.toUpperCase() === "C") {
1085
742
  cancelDeleteModal();
@@ -1315,6 +972,10 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1315
972
  fetchPage(null, true, true, void 0, "network-only");
1316
973
  })();
1317
974
  }
975
+ if (input && input.toUpperCase() === "W") {
976
+ setOrgSwitcherOpen(true);
977
+ return;
978
+ }
1318
979
  if (key.ctrl && (input === "a" || input === "A")) {
1319
980
  const repo = visibleItems[cursor];
1320
981
  if (repo) {
@@ -1364,6 +1025,10 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1364
1025
  setInfoMode(true);
1365
1026
  return;
1366
1027
  }
1028
+ if (input && input.toUpperCase() === "W") {
1029
+ setOrgSwitcherOpen(true);
1030
+ return;
1031
+ }
1367
1032
  if (input && input.toUpperCase() === "S") {
1368
1033
  const order = ["updated", "pushed", "name", "stars"];
1369
1034
  const idx = order.indexOf(sortKey);
@@ -1440,12 +1105,12 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1440
1105
  }, [filtered, sortKey, sortDir]);
1441
1106
  const searchActive = filter.trim().length >= 3;
1442
1107
  const visibleItems = searchActive ? searchItems : filteredAndSorted;
1443
- useEffect(() => {
1108
+ useEffect2(() => {
1444
1109
  if (searchActive) {
1445
1110
  addDebugMessage(`[State] searchActive=${searchActive}, searchItems=${searchItems.length}, visibleItems=${visibleItems.length}, filter="${filter}"`);
1446
1111
  }
1447
1112
  }, [searchActive, searchItems.length, visibleItems.length, filter]);
1448
- useEffect(() => {
1113
+ useEffect2(() => {
1449
1114
  setCursor((c) => Math.min(c, Math.max(0, (searchActive ? searchItems.length : items.length) - 1)));
1450
1115
  }, [searchActive, searchItems.length, items.length]);
1451
1116
  const headerHeight = 2;
@@ -1466,12 +1131,19 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1466
1131
  const end = Math.min(total, start + visibleRepos + buffer);
1467
1132
  return { start, end };
1468
1133
  }, [visibleItems.length, cursor, listHeight, spacingLines]);
1469
- useEffect(() => {
1470
- const nearEnd = cursor >= visibleItems.length - 5;
1134
+ useEffect2(() => {
1135
+ const prefetchThreshold = Math.floor(visibleItems.length * 0.8);
1136
+ const nearEnd = visibleItems.length > 0 && cursor >= prefetchThreshold;
1471
1137
  if (searchActive) {
1472
- if (!searchLoading && searchHasNextPage && nearEnd) fetchSearchPage(searchEndCursor);
1138
+ if (!searchLoading && searchHasNextPage && nearEnd) {
1139
+ addDebugMessage(`[Infinite Scroll] Prefetching search results at ${cursor}/${visibleItems.length} (80% threshold: ${prefetchThreshold})`);
1140
+ fetchSearchPage(searchEndCursor);
1141
+ }
1473
1142
  } else {
1474
- if (!loading && !loadingMore && hasNextPage && nearEnd) fetchPage(endCursor);
1143
+ if (!loading && !loadingMore && hasNextPage && nearEnd) {
1144
+ addDebugMessage(`[Infinite Scroll] Prefetching repos at ${cursor}/${visibleItems.length} (80% threshold: ${prefetchThreshold})`);
1145
+ fetchPage(endCursor);
1146
+ }
1475
1147
  }
1476
1148
  }, [cursor, visibleItems.length, searchActive, searchLoading, searchHasNextPage, searchEndCursor, loading, loadingMore, hasNextPage, endCursor]);
1477
1149
  function openInBrowser(url) {
@@ -1481,80 +1153,80 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1481
1153
  }
1482
1154
  const lowRate = rateLimit && rateLimit.remaining <= Math.ceil(rateLimit.limit * 0.1);
1483
1155
  const modalOpen = deleteMode || archiveMode || syncMode || logoutMode || infoMode;
1484
- const headerBar = useMemo(() => /* @__PURE__ */ jsxs(Box, { flexDirection: "row", justifyContent: "space-between", height: 1, marginBottom: 1, children: [
1485
- /* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 1, children: [
1486
- /* @__PURE__ */ jsx(Text, { bold: true, color: modalOpen ? "gray" : void 0, dimColor: modalOpen ? true : void 0, children: " Repositories" }),
1487
- /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
1156
+ const headerBar = useMemo(() => /* @__PURE__ */ jsxs2(Box2, { flexDirection: "row", justifyContent: "space-between", height: 1, marginBottom: 1, children: [
1157
+ /* @__PURE__ */ jsxs2(Box2, { flexDirection: "row", gap: 1, children: [
1158
+ /* @__PURE__ */ jsx2(Text2, { bold: true, color: modalOpen ? "gray" : void 0, dimColor: modalOpen ? true : void 0, children: " Repositories" }),
1159
+ /* @__PURE__ */ jsxs2(Text2, { color: "gray", children: [
1488
1160
  "(",
1489
1161
  visibleItems.length,
1490
1162
  "/",
1491
1163
  searchActive ? searchTotalCount : totalCount,
1492
1164
  ")"
1493
1165
  ] }),
1494
- (loading || searchLoading) && /* @__PURE__ */ jsx(Box, { width: 2, flexShrink: 0, flexGrow: 0, marginLeft: 1, children: /* @__PURE__ */ jsx(Text, { color: "yellow", children: /* @__PURE__ */ jsx(SlowSpinner, {}) }) })
1166
+ (loading || searchLoading) && /* @__PURE__ */ jsx2(Box2, { width: 2, flexShrink: 0, flexGrow: 0, marginLeft: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "yellow", children: /* @__PURE__ */ jsx2(SlowSpinner, {}) }) })
1495
1167
  ] }),
1496
- rateLimit && /* @__PURE__ */ jsxs(Text, { color: lowRate ? "yellow" : "gray", children: [
1168
+ rateLimit && /* @__PURE__ */ jsxs2(Text2, { color: lowRate ? "yellow" : "gray", children: [
1497
1169
  "API: ",
1498
1170
  rateLimit.remaining,
1499
1171
  "/",
1500
1172
  rateLimit.limit,
1501
- prevRateLimit !== void 0 && prevRateLimit !== rateLimit.remaining && /* @__PURE__ */ jsx(Text, { color: rateLimit.remaining < prevRateLimit ? "red" : "green", children: ` (${rateLimit.remaining - prevRateLimit > 0 ? "+" : ""}${rateLimit.remaining - prevRateLimit})` })
1173
+ prevRateLimit !== void 0 && prevRateLimit !== rateLimit.remaining && /* @__PURE__ */ jsx2(Text2, { color: rateLimit.remaining < prevRateLimit ? "red" : "green", children: ` (${rateLimit.remaining - prevRateLimit > 0 ? "+" : ""}${rateLimit.remaining - prevRateLimit})` })
1502
1174
  ] })
1503
1175
  ] }), [visibleItems.length, searchActive, searchTotalCount, totalCount, loading, searchLoading, rateLimit, lowRate, modalOpen, prevRateLimit]);
1504
1176
  if (error) {
1505
- return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", alignItems: "center", justifyContent: "center", flexGrow: 1, children: [
1506
- /* @__PURE__ */ jsx(Text, { color: "red", children: error }),
1507
- /* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: "Press 'r' to retry or 'q' to quit" })
1177
+ return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", alignItems: "center", justifyContent: "center", flexGrow: 1, children: [
1178
+ /* @__PURE__ */ jsx2(Text2, { color: "red", children: error }),
1179
+ /* @__PURE__ */ jsx2(Text2, { color: "gray", dimColor: true, children: "Press 'r' to retry or 'q' to quit" })
1508
1180
  ] });
1509
1181
  }
1510
1182
  if (loading && items.length === 0 || sortingLoading) {
1511
- return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", height: availableHeight, children: [
1512
- /* @__PURE__ */ jsx(Box, { flexDirection: "row", justifyContent: "space-between", height: 1, marginBottom: 1, children: /* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 1, children: [
1513
- /* @__PURE__ */ jsx(Text, { bold: true, children: " Repositories" }),
1514
- /* @__PURE__ */ jsx(Text, { color: "gray", children: "(Loading...)" })
1183
+ return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", height: availableHeight, children: [
1184
+ /* @__PURE__ */ jsx2(Box2, { flexDirection: "row", justifyContent: "space-between", height: 1, marginBottom: 1, children: /* @__PURE__ */ jsxs2(Box2, { flexDirection: "row", gap: 1, children: [
1185
+ /* @__PURE__ */ jsx2(Text2, { bold: true, children: " Repositories" }),
1186
+ /* @__PURE__ */ jsx2(Text2, { color: "gray", children: "(Loading...)" })
1515
1187
  ] }) }),
1516
- /* @__PURE__ */ jsx(Box, { borderStyle: "single", borderColor: "yellow", paddingX: 1, paddingY: 1, marginX: 1, height: contentHeight + containerPadding + 2, flexDirection: "column", children: /* @__PURE__ */ jsx(Box, { height: contentHeight, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsx(Box, { flexDirection: "column", alignItems: "center", children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", alignItems: "center", children: [
1517
- /* @__PURE__ */ jsxs(Box, { height: 1, flexDirection: "row", children: [
1518
- /* @__PURE__ */ jsx(Box, { width: 2, flexShrink: 0, flexGrow: 0, children: /* @__PURE__ */ jsx(Text, { color: "cyan", children: /* @__PURE__ */ jsx(SlowSpinner, {}) }) }),
1519
- /* @__PURE__ */ jsx(Text, { color: "cyan", children: refreshing ? "Refreshing..." : sortingLoading ? "Applying sort..." : "Loading repositories..." })
1188
+ /* @__PURE__ */ jsx2(Box2, { borderStyle: "single", borderColor: "yellow", paddingX: 1, paddingY: 1, marginX: 1, height: contentHeight + containerPadding + 2, flexDirection: "column", children: /* @__PURE__ */ jsx2(Box2, { height: contentHeight, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsx2(Box2, { flexDirection: "column", alignItems: "center", children: /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", alignItems: "center", children: [
1189
+ /* @__PURE__ */ jsxs2(Box2, { height: 1, flexDirection: "row", children: [
1190
+ /* @__PURE__ */ jsx2(Box2, { width: 2, flexShrink: 0, flexGrow: 0, children: /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: /* @__PURE__ */ jsx2(SlowSpinner, {}) }) }),
1191
+ /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: refreshing ? "Refreshing..." : sortingLoading ? "Applying sort..." : "Loading repositories..." })
1520
1192
  ] }),
1521
- /* @__PURE__ */ jsx(Box, { height: 1, marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "gray", children: refreshing ? "Fetching latest repository data" : sortingLoading ? `Sorting by ${sortKey} (${sortDir === "asc" ? "ascending" : "descending"})` : "Fetching your GitHub repositories" }) })
1193
+ /* @__PURE__ */ jsx2(Box2, { height: 1, marginTop: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "gray", children: refreshing ? "Fetching latest repository data" : sortingLoading ? `Sorting by ${sortKey} (${sortDir === "asc" ? "ascending" : "descending"})` : "Fetching your GitHub repositories" }) })
1522
1194
  ] }) }) }) }),
1523
- /* @__PURE__ */ jsx(Box, { marginTop: 1, paddingX: 1, children: /* @__PURE__ */ jsx(Text, { color: "gray", children: "Please wait..." }) })
1195
+ /* @__PURE__ */ jsx2(Box2, { marginTop: 1, paddingX: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "gray", children: "Please wait..." }) })
1524
1196
  ] });
1525
1197
  }
1526
- return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", height: availableHeight, children: [
1198
+ return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", height: availableHeight, children: [
1527
1199
  headerBar,
1528
- /* @__PURE__ */ jsx(Box, { borderStyle: "single", borderColor: modalOpen ? "gray" : "yellow", paddingX: 1, paddingY: 1, marginX: 1, height: contentHeight + containerPadding + 2, flexDirection: "column", children: deleteMode && deleteTarget ? (
1200
+ /* @__PURE__ */ jsx2(Box2, { borderStyle: "single", borderColor: modalOpen ? "gray" : "yellow", paddingX: 1, paddingY: 1, marginX: 1, height: contentHeight + containerPadding + 2, flexDirection: "column", children: deleteMode && deleteTarget ? (
1529
1201
  // Centered modal; hide list content while modal is open
1530
- /* @__PURE__ */ jsx(Box, { height: contentHeight, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "red", paddingX: 3, paddingY: 2, width: Math.min(terminalWidth - 8, 80), children: [
1531
- /* @__PURE__ */ jsx(Text, { bold: true, children: "Delete Confirmation" }),
1532
- /* @__PURE__ */ jsx(Text, { color: "red", children: "\u26A0\uFE0F Delete repository?" }),
1533
- /* @__PURE__ */ jsx(Box, { height: 2, children: /* @__PURE__ */ jsx(Text, { children: " " }) }),
1202
+ /* @__PURE__ */ jsx2(Box2, { height: contentHeight, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", borderStyle: "round", borderColor: "red", paddingX: 3, paddingY: 2, width: Math.min(terminalWidth - 8, 80), children: [
1203
+ /* @__PURE__ */ jsx2(Text2, { bold: true, children: "Delete Confirmation" }),
1204
+ /* @__PURE__ */ jsx2(Text2, { color: "red", children: "\u26A0\uFE0F Delete repository?" }),
1205
+ /* @__PURE__ */ jsx2(Box2, { height: 2, children: /* @__PURE__ */ jsx2(Text2, { children: " " }) }),
1534
1206
  (() => {
1535
1207
  const langName = deleteTarget.primaryLanguage?.name || "";
1536
1208
  const langColor = deleteTarget.primaryLanguage?.color || "#666666";
1537
1209
  let line1 = "";
1538
- line1 += chalk.white(deleteTarget.nameWithOwner);
1539
- if (deleteTarget.isPrivate) line1 += chalk.yellow(" Private");
1540
- if (deleteTarget.isArchived) line1 += chalk.gray.dim(" Archived");
1541
- if (deleteTarget.isFork && deleteTarget.parent) line1 += chalk.blue(` Fork of ${deleteTarget.parent.nameWithOwner}`);
1210
+ line1 += chalk2.white(deleteTarget.nameWithOwner);
1211
+ if (deleteTarget.isPrivate) line1 += chalk2.yellow(" Private");
1212
+ if (deleteTarget.isArchived) line1 += chalk2.gray.dim(" Archived");
1213
+ if (deleteTarget.isFork && deleteTarget.parent) line1 += chalk2.blue(` Fork of ${deleteTarget.parent.nameWithOwner}`);
1542
1214
  let line2 = "";
1543
- if (langName) line2 += chalk.hex(langColor)("\u25CF ") + chalk.gray(`${langName} `);
1544
- line2 += chalk.gray(`\u2605 ${deleteTarget.stargazerCount} \u2442 ${deleteTarget.forkCount} Updated ${formatDate(deleteTarget.updatedAt)}`);
1545
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1546
- /* @__PURE__ */ jsx(Text, { children: line1 }),
1547
- /* @__PURE__ */ jsx(Text, { children: line2 })
1215
+ if (langName) line2 += chalk2.hex(langColor)("\u25CF ") + chalk2.gray(`${langName} `);
1216
+ line2 += chalk2.gray(`\u2605 ${deleteTarget.stargazerCount} \u2442 ${deleteTarget.forkCount} Updated ${formatDate(deleteTarget.updatedAt)}`);
1217
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
1218
+ /* @__PURE__ */ jsx2(Text2, { children: line1 }),
1219
+ /* @__PURE__ */ jsx2(Text2, { children: line2 })
1548
1220
  ] });
1549
1221
  })(),
1550
- /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsxs(Text, { children: [
1222
+ /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsxs2(Text2, { children: [
1551
1223
  "Type ",
1552
- /* @__PURE__ */ jsx(Text, { color: "yellow", bold: true, children: deleteCode }),
1224
+ /* @__PURE__ */ jsx2(Text2, { color: "yellow", bold: true, children: deleteCode }),
1553
1225
  " to confirm."
1554
1226
  ] }) }),
1555
- !deleteConfirmStage && /* @__PURE__ */ jsxs(Box, { marginTop: 1, children: [
1556
- /* @__PURE__ */ jsx(Text, { children: "Confirm code: " }),
1557
- /* @__PURE__ */ jsx(
1227
+ !deleteConfirmStage && /* @__PURE__ */ jsxs2(Box2, { marginTop: 1, children: [
1228
+ /* @__PURE__ */ jsx2(Text2, { children: "Confirm code: " }),
1229
+ /* @__PURE__ */ jsx2(
1558
1230
  TextInput,
1559
1231
  {
1560
1232
  value: typedCode,
@@ -1581,11 +1253,11 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1581
1253
  }
1582
1254
  )
1583
1255
  ] }),
1584
- deleteConfirmStage && /* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
1585
- /* @__PURE__ */ jsx(Text, { color: "red", children: "This action will permanently delete the repository. This cannot be undone." }),
1586
- /* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "row", justifyContent: "center", gap: 6, children: [
1587
- /* @__PURE__ */ jsx(
1588
- Box,
1256
+ deleteConfirmStage && /* @__PURE__ */ jsxs2(Box2, { marginTop: 1, flexDirection: "column", children: [
1257
+ /* @__PURE__ */ jsx2(Text2, { color: "red", children: "This action will permanently delete the repository. This cannot be undone." }),
1258
+ /* @__PURE__ */ jsxs2(Box2, { marginTop: 1, flexDirection: "row", justifyContent: "center", gap: 6, children: [
1259
+ /* @__PURE__ */ jsx2(
1260
+ Box2,
1589
1261
  {
1590
1262
  borderStyle: "round",
1591
1263
  borderColor: "red",
@@ -1594,11 +1266,11 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1594
1266
  alignItems: "center",
1595
1267
  justifyContent: "center",
1596
1268
  flexDirection: "column",
1597
- children: /* @__PURE__ */ jsx(Text, { children: confirmFocus === "delete" ? chalk.bgRed.white.bold(" Delete ") : chalk.red.bold("Delete") })
1269
+ children: /* @__PURE__ */ jsx2(Text2, { children: confirmFocus === "delete" ? chalk2.bgRed.white.bold(" Delete ") : chalk2.red.bold("Delete") })
1598
1270
  }
1599
1271
  ),
1600
- /* @__PURE__ */ jsx(
1601
- Box,
1272
+ /* @__PURE__ */ jsx2(
1273
+ Box2,
1602
1274
  {
1603
1275
  borderStyle: "round",
1604
1276
  borderColor: confirmFocus === "cancel" ? "white" : "gray",
@@ -1607,16 +1279,16 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1607
1279
  alignItems: "center",
1608
1280
  justifyContent: "center",
1609
1281
  flexDirection: "column",
1610
- children: /* @__PURE__ */ jsx(Text, { children: confirmFocus === "cancel" ? chalk.bgGray.white.bold(" Cancel ") : chalk.gray.bold("Cancel") })
1282
+ children: /* @__PURE__ */ jsx2(Text2, { children: confirmFocus === "cancel" ? chalk2.bgGray.white.bold(" Cancel ") : chalk2.gray.bold("Cancel") })
1611
1283
  }
1612
1284
  )
1613
1285
  ] }),
1614
- /* @__PURE__ */ jsx(Box, { marginTop: 1, flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
1286
+ /* @__PURE__ */ jsx2(Box2, { marginTop: 1, flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ jsxs2(Text2, { color: "gray", children: [
1615
1287
  "Press Enter to ",
1616
1288
  confirmFocus === "delete" ? "Delete" : "Cancel",
1617
1289
  " \u2022 Y to confirm \u2022 C to cancel"
1618
1290
  ] }) }),
1619
- /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(
1291
+ /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(
1620
1292
  TextInput,
1621
1293
  {
1622
1294
  value: "",
@@ -1630,18 +1302,18 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1630
1302
  }
1631
1303
  ) })
1632
1304
  ] }),
1633
- deleteError && /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "magenta", children: deleteError }) }),
1634
- deleting && /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "yellow", children: "Deleting..." }) })
1305
+ deleteError && /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "magenta", children: deleteError }) }),
1306
+ deleting && /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "yellow", children: "Deleting..." }) })
1635
1307
  ] }) })
1636
- ) : archiveMode && archiveTarget ? /* @__PURE__ */ jsx(Box, { height: contentHeight, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: archiveTarget.isArchived ? "green" : "yellow", paddingX: 3, paddingY: 2, width: Math.min(terminalWidth - 8, 80), children: [
1637
- /* @__PURE__ */ jsx(Text, { bold: true, children: archiveTarget.isArchived ? "Unarchive Confirmation" : "Archive Confirmation" }),
1638
- /* @__PURE__ */ jsx(Text, { color: archiveTarget.isArchived ? "green" : "yellow", children: archiveTarget.isArchived ? "\u21BA Unarchive repository?" : "\u26A0\uFE0F Archive repository?" }),
1639
- /* @__PURE__ */ jsx(Box, { height: 1, children: /* @__PURE__ */ jsx(Text, { children: " " }) }),
1640
- /* @__PURE__ */ jsx(Text, { children: archiveTarget.nameWithOwner }),
1641
- /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { children: archiveTarget.isArchived ? "This will make the repository active again." : "This will make the repository read-only." }) }),
1642
- /* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "row", justifyContent: "center", gap: 6, children: [
1643
- /* @__PURE__ */ jsx(
1644
- Box,
1308
+ ) : archiveMode && archiveTarget ? /* @__PURE__ */ jsx2(Box2, { height: contentHeight, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", borderStyle: "round", borderColor: archiveTarget.isArchived ? "green" : "yellow", paddingX: 3, paddingY: 2, width: Math.min(terminalWidth - 8, 80), children: [
1309
+ /* @__PURE__ */ jsx2(Text2, { bold: true, children: archiveTarget.isArchived ? "Unarchive Confirmation" : "Archive Confirmation" }),
1310
+ /* @__PURE__ */ jsx2(Text2, { color: archiveTarget.isArchived ? "green" : "yellow", children: archiveTarget.isArchived ? "\u21BA Unarchive repository?" : "\u26A0\uFE0F Archive repository?" }),
1311
+ /* @__PURE__ */ jsx2(Box2, { height: 1, children: /* @__PURE__ */ jsx2(Text2, { children: " " }) }),
1312
+ /* @__PURE__ */ jsx2(Text2, { children: archiveTarget.nameWithOwner }),
1313
+ /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(Text2, { children: archiveTarget.isArchived ? "This will make the repository active again." : "This will make the repository read-only." }) }),
1314
+ /* @__PURE__ */ jsxs2(Box2, { marginTop: 1, flexDirection: "row", justifyContent: "center", gap: 6, children: [
1315
+ /* @__PURE__ */ jsx2(
1316
+ Box2,
1645
1317
  {
1646
1318
  borderStyle: "round",
1647
1319
  borderColor: archiveTarget.isArchived ? "green" : "yellow",
@@ -1650,11 +1322,11 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1650
1322
  alignItems: "center",
1651
1323
  justifyContent: "center",
1652
1324
  flexDirection: "column",
1653
- children: /* @__PURE__ */ jsx(Text, { children: archiveFocus === "confirm" ? chalk.bgGreen.white.bold(` ${archiveTarget.isArchived ? "Unarchive" : "Archive"} `) : chalk.bold[archiveTarget.isArchived ? "green" : "yellow"](archiveTarget.isArchived ? "Unarchive" : "Archive") })
1325
+ children: /* @__PURE__ */ jsx2(Text2, { children: archiveFocus === "confirm" ? chalk2.bgGreen.white.bold(` ${archiveTarget.isArchived ? "Unarchive" : "Archive"} `) : chalk2.bold[archiveTarget.isArchived ? "green" : "yellow"](archiveTarget.isArchived ? "Unarchive" : "Archive") })
1654
1326
  }
1655
1327
  ),
1656
- /* @__PURE__ */ jsx(
1657
- Box,
1328
+ /* @__PURE__ */ jsx2(
1329
+ Box2,
1658
1330
  {
1659
1331
  borderStyle: "round",
1660
1332
  borderColor: archiveFocus === "cancel" ? "white" : "gray",
@@ -1663,16 +1335,16 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1663
1335
  alignItems: "center",
1664
1336
  justifyContent: "center",
1665
1337
  flexDirection: "column",
1666
- children: /* @__PURE__ */ jsx(Text, { children: archiveFocus === "cancel" ? chalk.bgGray.white.bold(" Cancel ") : chalk.gray.bold("Cancel") })
1338
+ children: /* @__PURE__ */ jsx2(Text2, { children: archiveFocus === "cancel" ? chalk2.bgGray.white.bold(" Cancel ") : chalk2.gray.bold("Cancel") })
1667
1339
  }
1668
1340
  )
1669
1341
  ] }),
1670
- /* @__PURE__ */ jsx(Box, { marginTop: 1, flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
1342
+ /* @__PURE__ */ jsx2(Box2, { marginTop: 1, flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ jsxs2(Text2, { color: "gray", children: [
1671
1343
  "Press Enter to ",
1672
1344
  archiveFocus === "confirm" ? archiveTarget.isArchived ? "Unarchive" : "Archive" : "Cancel",
1673
1345
  " \u2022 Y to confirm \u2022 C to cancel"
1674
1346
  ] }) }),
1675
- /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(
1347
+ /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(
1676
1348
  TextInput,
1677
1349
  {
1678
1350
  value: "",
@@ -1700,21 +1372,21 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1700
1372
  }
1701
1373
  }
1702
1374
  ) }),
1703
- archiveError && /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "magenta", children: archiveError }) }),
1704
- archiving && /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "yellow", children: archiveTarget.isArchived ? "Unarchiving..." : "Archiving..." }) })
1705
- ] }) }) : syncMode && syncTarget ? /* @__PURE__ */ jsx(Box, { height: contentHeight, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "blue", paddingX: 3, paddingY: 2, width: Math.min(terminalWidth - 8, 80), children: [
1706
- /* @__PURE__ */ jsx(Text, { bold: true, children: "Sync Fork Confirmation" }),
1707
- /* @__PURE__ */ jsx(Text, { color: "blue", children: "\u27F2 Sync fork with upstream?" }),
1708
- /* @__PURE__ */ jsx(Box, { height: 1, children: /* @__PURE__ */ jsx(Text, { children: " " }) }),
1709
- /* @__PURE__ */ jsx(Text, { children: syncTarget.nameWithOwner }),
1710
- syncTarget.parent && /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
1375
+ archiveError && /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "magenta", children: archiveError }) }),
1376
+ archiving && /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "yellow", children: archiveTarget.isArchived ? "Unarchiving..." : "Archiving..." }) })
1377
+ ] }) }) : syncMode && syncTarget ? /* @__PURE__ */ jsx2(Box2, { height: contentHeight, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", borderStyle: "round", borderColor: "blue", paddingX: 3, paddingY: 2, width: Math.min(terminalWidth - 8, 80), children: [
1378
+ /* @__PURE__ */ jsx2(Text2, { bold: true, children: "Sync Fork Confirmation" }),
1379
+ /* @__PURE__ */ jsx2(Text2, { color: "blue", children: "\u27F2 Sync fork with upstream?" }),
1380
+ /* @__PURE__ */ jsx2(Box2, { height: 1, children: /* @__PURE__ */ jsx2(Text2, { children: " " }) }),
1381
+ /* @__PURE__ */ jsx2(Text2, { children: syncTarget.nameWithOwner }),
1382
+ syncTarget.parent && /* @__PURE__ */ jsxs2(Text2, { color: "gray", children: [
1711
1383
  "Upstream: ",
1712
1384
  syncTarget.parent.nameWithOwner
1713
1385
  ] }),
1714
- /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { children: "This will merge upstream changes into your fork." }) }),
1715
- /* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "row", justifyContent: "center", gap: 6, children: [
1716
- /* @__PURE__ */ jsx(
1717
- Box,
1386
+ /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(Text2, { children: "This will merge upstream changes into your fork." }) }),
1387
+ /* @__PURE__ */ jsxs2(Box2, { marginTop: 1, flexDirection: "row", justifyContent: "center", gap: 6, children: [
1388
+ /* @__PURE__ */ jsx2(
1389
+ Box2,
1718
1390
  {
1719
1391
  borderStyle: "round",
1720
1392
  borderColor: "blue",
@@ -1723,11 +1395,11 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1723
1395
  alignItems: "center",
1724
1396
  justifyContent: "center",
1725
1397
  flexDirection: "column",
1726
- children: /* @__PURE__ */ jsx(Text, { children: syncFocus === "confirm" ? chalk.bgBlue.white.bold(" Sync ") : chalk.blue.bold("Sync") })
1398
+ children: /* @__PURE__ */ jsx2(Text2, { children: syncFocus === "confirm" ? chalk2.bgBlue.white.bold(" Sync ") : chalk2.blue.bold("Sync") })
1727
1399
  }
1728
1400
  ),
1729
- /* @__PURE__ */ jsx(
1730
- Box,
1401
+ /* @__PURE__ */ jsx2(
1402
+ Box2,
1731
1403
  {
1732
1404
  borderStyle: "round",
1733
1405
  borderColor: syncFocus === "cancel" ? "white" : "gray",
@@ -1736,16 +1408,16 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1736
1408
  alignItems: "center",
1737
1409
  justifyContent: "center",
1738
1410
  flexDirection: "column",
1739
- children: /* @__PURE__ */ jsx(Text, { children: syncFocus === "cancel" ? chalk.bgGray.white.bold(" Cancel ") : chalk.gray.bold("Cancel") })
1411
+ children: /* @__PURE__ */ jsx2(Text2, { children: syncFocus === "cancel" ? chalk2.bgGray.white.bold(" Cancel ") : chalk2.gray.bold("Cancel") })
1740
1412
  }
1741
1413
  )
1742
1414
  ] }),
1743
- /* @__PURE__ */ jsx(Box, { marginTop: 1, flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
1415
+ /* @__PURE__ */ jsx2(Box2, { marginTop: 1, flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ jsxs2(Text2, { color: "gray", children: [
1744
1416
  "Press Enter to ",
1745
1417
  syncFocus === "confirm" ? "Sync" : "Cancel",
1746
1418
  " \u2022 y to confirm \u2022 c to cancel"
1747
1419
  ] }) }),
1748
- /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(
1420
+ /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(
1749
1421
  TextInput,
1750
1422
  {
1751
1423
  value: "",
@@ -1787,14 +1459,14 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1787
1459
  }
1788
1460
  }
1789
1461
  ) }),
1790
- syncError && /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "magenta", children: syncError }) }),
1791
- syncing && /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "yellow", children: "Syncing..." }) })
1792
- ] }) }) : logoutMode ? /* @__PURE__ */ jsx(Box, { height: contentHeight, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 3, paddingY: 2, width: Math.min(terminalWidth - 8, 80), children: [
1793
- /* @__PURE__ */ jsx(Text, { bold: true, children: "Logout Confirmation" }),
1794
- /* @__PURE__ */ jsx(Text, { color: "cyan", children: "Are you sure you want to log out?" }),
1795
- /* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "row", justifyContent: "center", gap: 6, children: [
1796
- /* @__PURE__ */ jsx(
1797
- Box,
1462
+ syncError && /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "magenta", children: syncError }) }),
1463
+ syncing && /* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "yellow", children: "Syncing..." }) })
1464
+ ] }) }) : logoutMode ? /* @__PURE__ */ jsx2(Box2, { height: contentHeight, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 3, paddingY: 2, width: Math.min(terminalWidth - 8, 80), children: [
1465
+ /* @__PURE__ */ jsx2(Text2, { bold: true, children: "Logout Confirmation" }),
1466
+ /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "Are you sure you want to log out?" }),
1467
+ /* @__PURE__ */ jsxs2(Box2, { marginTop: 1, flexDirection: "row", justifyContent: "center", gap: 6, children: [
1468
+ /* @__PURE__ */ jsx2(
1469
+ Box2,
1798
1470
  {
1799
1471
  borderStyle: "round",
1800
1472
  borderColor: "cyan",
@@ -1803,11 +1475,11 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1803
1475
  alignItems: "center",
1804
1476
  justifyContent: "center",
1805
1477
  flexDirection: "column",
1806
- children: /* @__PURE__ */ jsx(Text, { children: logoutFocus === "confirm" ? chalk.bgCyan.white.bold(" Logout ") : chalk.cyan.bold("Logout") })
1478
+ children: /* @__PURE__ */ jsx2(Text2, { children: logoutFocus === "confirm" ? chalk2.bgCyan.white.bold(" Logout ") : chalk2.cyan.bold("Logout") })
1807
1479
  }
1808
1480
  ),
1809
- /* @__PURE__ */ jsx(
1810
- Box,
1481
+ /* @__PURE__ */ jsx2(
1482
+ Box2,
1811
1483
  {
1812
1484
  borderStyle: "round",
1813
1485
  borderColor: logoutFocus === "cancel" ? "white" : "gray",
@@ -1816,82 +1488,91 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1816
1488
  alignItems: "center",
1817
1489
  justifyContent: "center",
1818
1490
  flexDirection: "column",
1819
- children: /* @__PURE__ */ jsx(Text, { children: logoutFocus === "cancel" ? chalk.bgGray.white.bold(" Cancel ") : chalk.gray.bold("Cancel") })
1491
+ children: /* @__PURE__ */ jsx2(Text2, { children: logoutFocus === "cancel" ? chalk2.bgGray.white.bold(" Cancel ") : chalk2.gray.bold("Cancel") })
1820
1492
  }
1821
1493
  )
1822
1494
  ] }),
1823
- /* @__PURE__ */ jsx(Box, { marginTop: 1, flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
1495
+ /* @__PURE__ */ jsx2(Box2, { marginTop: 1, flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ jsxs2(Text2, { color: "gray", children: [
1824
1496
  "Press Enter to ",
1825
1497
  logoutFocus === "confirm" ? "Logout" : "Cancel",
1826
1498
  " \u2022 Y to confirm \u2022 C to cancel"
1827
1499
  ] }) })
1828
- ] }) }) : infoMode ? /* @__PURE__ */ jsx(Box, { height: contentHeight, alignItems: "center", justifyContent: "center", children: (() => {
1500
+ ] }) }) : orgSwitcherOpen ? /* @__PURE__ */ jsx2(Box2, { height: contentHeight, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsx2(
1501
+ OrgSwitcher,
1502
+ {
1503
+ token,
1504
+ currentContext: ownerContext,
1505
+ onSelect: handleOrgContextChange,
1506
+ onClose: () => setOrgSwitcherOpen(false)
1507
+ }
1508
+ ) }) : infoMode ? /* @__PURE__ */ jsx2(Box2, { height: contentHeight, alignItems: "center", justifyContent: "center", children: (() => {
1829
1509
  const repo = visibleItems[cursor];
1830
- if (!repo) return /* @__PURE__ */ jsx(Text, { color: "red", children: "No repository selected." });
1510
+ if (!repo) return /* @__PURE__ */ jsx2(Text2, { color: "red", children: "No repository selected." });
1831
1511
  const langName = repo.primaryLanguage?.name || "N/A";
1832
1512
  const langColor = repo.primaryLanguage?.color || "#666666";
1833
- return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "magenta", paddingX: 3, paddingY: 2, width: Math.min(terminalWidth - 8, 90), children: [
1834
- /* @__PURE__ */ jsx(Text, { bold: true, children: "Repository Info" }),
1835
- /* @__PURE__ */ jsx(Box, { height: 1, children: /* @__PURE__ */ jsx(Text, { children: " " }) }),
1836
- /* @__PURE__ */ jsx(Text, { children: chalk.bold(repo.nameWithOwner) }),
1837
- repo.description && /* @__PURE__ */ jsx(Text, { color: "gray", children: repo.description }),
1838
- /* @__PURE__ */ jsx(Box, { height: 1, children: /* @__PURE__ */ jsx(Text, { children: " " }) }),
1839
- /* @__PURE__ */ jsxs(Text, { children: [
1840
- repo.isPrivate ? chalk.yellow("Private") : chalk.green("Public"),
1841
- repo.isArchived ? chalk.gray(" Archived") : "",
1842
- repo.isFork ? chalk.blue(" Fork") : ""
1513
+ return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", borderStyle: "round", borderColor: "magenta", paddingX: 3, paddingY: 2, width: Math.min(terminalWidth - 8, 90), children: [
1514
+ /* @__PURE__ */ jsx2(Text2, { bold: true, children: "Repository Info" }),
1515
+ /* @__PURE__ */ jsx2(Box2, { height: 1, children: /* @__PURE__ */ jsx2(Text2, { children: " " }) }),
1516
+ /* @__PURE__ */ jsx2(Text2, { children: chalk2.bold(repo.nameWithOwner) }),
1517
+ repo.description && /* @__PURE__ */ jsx2(Text2, { color: "gray", children: repo.description }),
1518
+ /* @__PURE__ */ jsx2(Box2, { height: 1, children: /* @__PURE__ */ jsx2(Text2, { children: " " }) }),
1519
+ /* @__PURE__ */ jsxs2(Text2, { children: [
1520
+ repo.isPrivate ? chalk2.yellow("Private") : chalk2.green("Public"),
1521
+ repo.isArchived ? chalk2.gray(" Archived") : "",
1522
+ repo.isFork ? chalk2.blue(" Fork") : ""
1843
1523
  ] }),
1844
- /* @__PURE__ */ jsx(Text, { children: chalk.gray(`\u2605 ${repo.stargazerCount} \u2442 ${repo.forkCount}`) }),
1845
- /* @__PURE__ */ jsxs(Text, { children: [
1846
- chalk.hex(langColor)(`\u25CF `),
1847
- chalk.gray(`${langName}`)
1524
+ /* @__PURE__ */ jsx2(Text2, { children: chalk2.gray(`\u2605 ${repo.stargazerCount} \u2442 ${repo.forkCount}`) }),
1525
+ /* @__PURE__ */ jsxs2(Text2, { children: [
1526
+ chalk2.hex(langColor)(`\u25CF `),
1527
+ chalk2.gray(`${langName}`)
1848
1528
  ] }),
1849
- /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
1529
+ /* @__PURE__ */ jsxs2(Text2, { color: "gray", children: [
1850
1530
  "Updated: ",
1851
1531
  formatDate(repo.updatedAt),
1852
1532
  " \u2022 Pushed: ",
1853
1533
  formatDate(repo.pushedAt)
1854
1534
  ] }),
1855
- /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
1535
+ /* @__PURE__ */ jsxs2(Text2, { color: "gray", children: [
1856
1536
  "Size: ",
1857
1537
  repo.diskUsage,
1858
1538
  " KB"
1859
1539
  ] }),
1860
- /* @__PURE__ */ jsx(Box, { height: 1, children: /* @__PURE__ */ jsx(Text, { children: " " }) }),
1861
- /* @__PURE__ */ jsx(Text, { color: "gray", children: "Press Esc or I to close" })
1540
+ /* @__PURE__ */ jsx2(Box2, { height: 1, children: /* @__PURE__ */ jsx2(Text2, { children: " " }) }),
1541
+ /* @__PURE__ */ jsx2(Text2, { color: "gray", children: "Press Esc or I to close" })
1862
1542
  ] });
1863
- })() }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1864
- /* @__PURE__ */ jsxs(Box, { flexDirection: "row", gap: 2, marginBottom: 1, children: [
1865
- /* @__PURE__ */ jsxs(Text, { color: "gray", dimColor: true, children: [
1543
+ })() }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
1544
+ /* @__PURE__ */ jsxs2(Box2, { flexDirection: "row", gap: 2, marginBottom: 1, children: [
1545
+ /* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: ownerContext === "personal" ? "Personal Account" : `Organization: ${ownerContext.name || ownerContext.login}` }),
1546
+ /* @__PURE__ */ jsxs2(Text2, { color: "gray", dimColor: true, children: [
1866
1547
  "Sort: ",
1867
1548
  sortKey,
1868
1549
  " ",
1869
1550
  sortDir === "asc" ? "\u2191" : "\u2193"
1870
1551
  ] }),
1871
- /* @__PURE__ */ jsxs(Text, { color: "gray", dimColor: true, children: [
1552
+ /* @__PURE__ */ jsxs2(Text2, { color: "gray", dimColor: true, children: [
1872
1553
  "Forks - Commits Behind: ",
1873
1554
  forkTracking ? "ON" : "OFF"
1874
1555
  ] }),
1875
- filter && !searchActive && /* @__PURE__ */ jsxs(Text, { color: "cyan", children: [
1556
+ filter && !searchActive && /* @__PURE__ */ jsxs2(Text2, { color: "cyan", children: [
1876
1557
  'Filter: "',
1877
1558
  filter,
1878
1559
  '"'
1879
1560
  ] }),
1880
- searchActive && /* @__PURE__ */ jsxs(Fragment, { children: [
1881
- /* @__PURE__ */ jsxs(Text, { color: "cyan", children: [
1561
+ searchActive && /* @__PURE__ */ jsxs2(Fragment, { children: [
1562
+ /* @__PURE__ */ jsxs2(Text2, { color: "cyan", children: [
1882
1563
  'Search: "',
1883
1564
  filter.trim(),
1884
1565
  '"'
1885
1566
  ] }),
1886
- searchLoading && /* @__PURE__ */ jsx(Box, { marginLeft: 1, children: /* @__PURE__ */ jsxs(Text, { color: "cyan", children: [
1887
- /* @__PURE__ */ jsx(SlowSpinner, {}),
1567
+ searchLoading && /* @__PURE__ */ jsx2(Box2, { marginLeft: 1, children: /* @__PURE__ */ jsxs2(Text2, { color: "cyan", children: [
1568
+ /* @__PURE__ */ jsx2(SlowSpinner, {}),
1888
1569
  " Searching\u2026"
1889
1570
  ] }) })
1890
1571
  ] })
1891
1572
  ] }),
1892
- filterMode && /* @__PURE__ */ jsxs(Box, { marginBottom: 1, children: [
1893
- /* @__PURE__ */ jsx(Text, { children: "Filter: " }),
1894
- /* @__PURE__ */ jsx(
1573
+ filterMode && /* @__PURE__ */ jsxs2(Box2, { marginBottom: 1, children: [
1574
+ /* @__PURE__ */ jsx2(Text2, { children: "Filter: " }),
1575
+ /* @__PURE__ */ jsx2(
1895
1576
  TextInput,
1896
1577
  {
1897
1578
  value: filter,
@@ -1931,10 +1612,10 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1931
1612
  }
1932
1613
  )
1933
1614
  ] }),
1934
- /* @__PURE__ */ jsxs(Box, { flexDirection: "column", height: listHeight, children: [
1935
- filterMode && filter.trim().length > 0 && filter.trim().length < 3 ? /* @__PURE__ */ jsx(Box, { justifyContent: "center", alignItems: "center", flexGrow: 1, children: /* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: "Type at least 3 characters to search" }) }) : visibleItems.slice(windowed.start, windowed.end).map((repo, i) => {
1615
+ /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", height: listHeight, children: [
1616
+ filterMode && filter.trim().length > 0 && filter.trim().length < 3 ? /* @__PURE__ */ jsx2(Box2, { justifyContent: "center", alignItems: "center", flexGrow: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "gray", dimColor: true, children: "Type at least 3 characters to search" }) }) : visibleItems.slice(windowed.start, windowed.end).map((repo, i) => {
1936
1617
  const idx = windowed.start + i;
1937
- return /* @__PURE__ */ jsx(
1618
+ return /* @__PURE__ */ jsx2(
1938
1619
  RepoRow,
1939
1620
  {
1940
1621
  repo,
@@ -1947,42 +1628,43 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin }) {
1947
1628
  repo.nameWithOwner
1948
1629
  );
1949
1630
  }),
1950
- loadingMore && hasNextPage && /* @__PURE__ */ jsx(Box, { justifyContent: "center", alignItems: "center", marginTop: 1, children: /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
1951
- /* @__PURE__ */ jsx(Box, { width: 2, flexShrink: 0, flexGrow: 0, marginRight: 1, children: /* @__PURE__ */ jsx(Text, { color: "cyan", children: /* @__PURE__ */ jsx(SlowSpinner, {}) }) }),
1952
- /* @__PURE__ */ jsx(Text, { color: "cyan", children: "Loading more repositories..." })
1631
+ loadingMore && hasNextPage && /* @__PURE__ */ jsx2(Box2, { justifyContent: "center", alignItems: "center", marginTop: 1, children: /* @__PURE__ */ jsxs2(Box2, { flexDirection: "row", children: [
1632
+ /* @__PURE__ */ jsx2(Box2, { width: 2, flexShrink: 0, flexGrow: 0, marginRight: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: /* @__PURE__ */ jsx2(SlowSpinner, {}) }) }),
1633
+ /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "Loading more repositories..." })
1953
1634
  ] }) }),
1954
- !loading && !searchLoading && visibleItems.length === 0 && /* @__PURE__ */ jsx(Box, { justifyContent: "center", alignItems: "center", flexGrow: 1, children: /* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: searchActive ? "No repositories match your search" : filter ? "No repositories match your filter" : "No repositories found" }) })
1635
+ !loading && !searchLoading && visibleItems.length === 0 && /* @__PURE__ */ jsx2(Box2, { justifyContent: "center", alignItems: "center", flexGrow: 1, children: /* @__PURE__ */ jsx2(Text2, { color: "gray", dimColor: true, children: searchActive ? "No repositories match your search" : filter ? "No repositories match your filter" : "No repositories found" }) })
1955
1636
  ] })
1956
1637
  ] }) }),
1957
- /* @__PURE__ */ jsxs(Box, { marginTop: 1, paddingX: 1, flexDirection: "column", children: [
1958
- /* @__PURE__ */ jsx(Box, { width: terminalWidth, justifyContent: "center", children: /* @__PURE__ */ jsx(Text, { color: "gray", dimColor: modalOpen ? true : void 0, children: "\u2191\u2193 Navigate \u2022 Ctrl+G Top \u2022 G Bottom \u2022 / Filter \u2022 S Sort \u2022 D Direction \u2022 T Density \u2022 F Forks - Commits Behind \u2022 \u23CE/O Open" }) }),
1959
- /* @__PURE__ */ jsx(Box, { width: terminalWidth, justifyContent: "center", children: /* @__PURE__ */ jsx(Text, { color: "gray", dimColor: modalOpen ? true : void 0, children: "Del/Ctrl+Backspace Delete \u2022 Ctrl+A Un/Archive \u2022 Ctrl+U Sync Fork \u2022 I Info \u2022 Ctrl+I Cache \u2022 Ctrl+L Logout \u2022 R Refresh \u2022 Q Quit" }) })
1638
+ /* @__PURE__ */ jsxs2(Box2, { marginTop: 1, paddingX: 1, flexDirection: "column", children: [
1639
+ /* @__PURE__ */ jsx2(Box2, { width: terminalWidth, justifyContent: "center", children: /* @__PURE__ */ jsx2(Text2, { color: "gray", dimColor: modalOpen ? true : void 0, children: "\u2191\u2193 Navigate \u2022 Ctrl+G Top \u2022 G Bottom \u2022 / Filter \u2022 W Org Switcher \u2022 S Sort \u2022 D Direction \u2022 T Density \u2022 F Forks \u2022 \u23CE/O Open" }) }),
1640
+ /* @__PURE__ */ jsx2(Box2, { width: terminalWidth, justifyContent: "center", children: /* @__PURE__ */ jsx2(Text2, { color: "gray", dimColor: modalOpen ? true : void 0, children: "Del/Ctrl+Backspace Delete \u2022 Ctrl+A Un/Archive \u2022 Ctrl+U Sync Fork \u2022 I Info \u2022 Ctrl+I Cache \u2022 Ctrl+L Logout \u2022 R Refresh \u2022 Q Quit" }) })
1960
1641
  ] }),
1961
- process.env.GH_MANAGER_DEBUG === "1" && /* @__PURE__ */ jsxs(Box, { marginTop: 1, borderStyle: "single", borderColor: "yellow", paddingX: 1, flexDirection: "column", children: [
1962
- /* @__PURE__ */ jsx(Text, { bold: true, color: "yellow", children: "Debug Messages:" }),
1963
- debugMessages.length === 0 ? /* @__PURE__ */ jsx(Text, { color: "gray", children: "No debug messages yet..." }) : debugMessages.map((msg, i) => /* @__PURE__ */ jsx(Text, { color: "gray", children: msg }, i))
1642
+ process.env.GH_MANAGER_DEBUG === "1" && /* @__PURE__ */ jsxs2(Box2, { marginTop: 1, borderStyle: "single", borderColor: "yellow", paddingX: 1, flexDirection: "column", children: [
1643
+ /* @__PURE__ */ jsx2(Text2, { bold: true, color: "yellow", children: "Debug Messages:" }),
1644
+ debugMessages.length === 0 ? /* @__PURE__ */ jsx2(Text2, { color: "gray", children: "No debug messages yet..." }) : debugMessages.map((msg, i) => /* @__PURE__ */ jsx2(Text2, { color: "gray", children: msg }, i))
1964
1645
  ] })
1965
1646
  ] });
1966
1647
  }
1967
1648
 
1968
1649
  // src/ui/App.tsx
1969
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1650
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1970
1651
  var packageJson = require_package();
1971
1652
  function App() {
1972
1653
  const { exit } = useApp2();
1973
1654
  const { stdout } = useStdout2();
1974
- const [mode, setMode] = useState2("checking");
1975
- const [token, setToken] = useState2(null);
1976
- const [input, setInput] = useState2("");
1977
- const [error, setError] = useState2(null);
1978
- const [viewer, setViewer] = useState2(null);
1979
- const [rateLimitReset, setRateLimitReset] = useState2(null);
1980
- const [dims, setDims] = useState2(() => {
1655
+ const [mode, setMode] = useState3("checking");
1656
+ const [token, setToken] = useState3(null);
1657
+ const [input, setInput] = useState3("");
1658
+ const [error, setError] = useState3(null);
1659
+ const [viewer, setViewer] = useState3(null);
1660
+ const [rateLimitReset, setRateLimitReset] = useState3(null);
1661
+ const [orgContext, setOrgContext] = useState3("personal");
1662
+ const [dims, setDims] = useState3(() => {
1981
1663
  const cols = stdout?.columns ?? 100;
1982
1664
  const rows = stdout?.rows ?? 30;
1983
1665
  return { cols, rows };
1984
1666
  });
1985
- useEffect2(() => {
1667
+ useEffect3(() => {
1986
1668
  if (!stdout) return;
1987
1669
  const onResize = () => {
1988
1670
  const cols = stdout.columns ?? 100;
@@ -1994,7 +1676,7 @@ function App() {
1994
1676
  stdout.off?.("resize", onResize);
1995
1677
  };
1996
1678
  }, [stdout]);
1997
- useEffect2(() => {
1679
+ useEffect3(() => {
1998
1680
  const env = getTokenFromEnv();
1999
1681
  const stored = getStoredToken();
2000
1682
  if (env) {
@@ -2007,7 +1689,7 @@ function App() {
2007
1689
  setMode("prompt");
2008
1690
  }
2009
1691
  }, []);
2010
- useEffect2(() => {
1692
+ useEffect3(() => {
2011
1693
  (async () => {
2012
1694
  if (mode !== "validating" || !token) return;
2013
1695
  const timeoutId = setTimeout(() => {
@@ -2092,7 +1774,7 @@ function App() {
2092
1774
  setViewer(null);
2093
1775
  setMode("prompt");
2094
1776
  };
2095
- useInput2((input2, key) => {
1777
+ useInput3((input2, key) => {
2096
1778
  if (mode === "prompt" && key.escape) {
2097
1779
  exit();
2098
1780
  }
@@ -2118,24 +1800,20 @@ function App() {
2118
1800
  }
2119
1801
  });
2120
1802
  const verticalPadding = Math.floor(dims.rows * 0.15);
2121
- const header = useMemo2(() => /* @__PURE__ */ jsxs2(Box2, { flexDirection: "row", justifyContent: "space-between", marginBottom: 1, children: [
2122
- /* @__PURE__ */ jsxs2(Box2, { flexDirection: "row", gap: 1, children: [
2123
- /* @__PURE__ */ jsxs2(Text2, { bold: true, color: "cyan", children: [
1803
+ const header = useMemo2(() => /* @__PURE__ */ jsxs3(Box3, { flexDirection: "row", justifyContent: "space-between", marginBottom: 1, children: [
1804
+ /* @__PURE__ */ jsxs3(Box3, { flexDirection: "row", gap: 1, children: [
1805
+ /* @__PURE__ */ jsxs3(Text3, { bold: true, color: "cyan", children: [
2124
1806
  " ",
2125
1807
  "GitHub Repository Manager"
2126
1808
  ] }),
2127
- /* @__PURE__ */ jsxs2(Text2, { color: "gray", dimColor: true, children: [
1809
+ /* @__PURE__ */ jsxs3(Text3, { color: "gray", dimColor: true, children: [
2128
1810
  "v",
2129
1811
  packageJson.version
2130
1812
  ] }),
2131
- process.env.GH_MANAGER_DEBUG === "1" && /* @__PURE__ */ jsx2(Text2, { backgroundColor: "blue", color: "white", children: " debug mode " })
1813
+ process.env.GH_MANAGER_DEBUG === "1" && /* @__PURE__ */ jsx3(Text3, { backgroundColor: "blue", color: "white", children: " debug mode " })
2132
1814
  ] }),
2133
- viewer && /* @__PURE__ */ jsxs2(Text2, { color: "gray", children: [
2134
- "@",
2135
- viewer,
2136
- " "
2137
- ] })
2138
- ] }), [viewer]);
1815
+ viewer && /* @__PURE__ */ jsx3(Text3, { color: "gray", children: orgContext !== "personal" && orgContext.login ? `${orgContext.login}/@${viewer} ` : `@${viewer} ` })
1816
+ ] }), [viewer, orgContext]);
2139
1817
  if (mode === "rate_limited") {
2140
1818
  const formatResetTime = (resetTime) => {
2141
1819
  if (!resetTime) return "Unknown";
@@ -2157,55 +1835,55 @@ function App() {
2157
1835
  return "Unknown";
2158
1836
  }
2159
1837
  };
2160
- return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", height: dims.rows, paddingX: 2, paddingTop: verticalPadding, paddingBottom: verticalPadding, children: [
1838
+ return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", height: dims.rows, paddingX: 2, paddingTop: verticalPadding, paddingBottom: verticalPadding, children: [
2161
1839
  header,
2162
- /* @__PURE__ */ jsx2(Box2, { flexGrow: 1, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs2(Box2, { borderStyle: "single", borderColor: "yellow", paddingX: 3, paddingY: 2, flexDirection: "column", width: Math.min(dims.cols - 8, 80), children: [
2163
- /* @__PURE__ */ jsx2(Text2, { bold: true, color: "yellow", marginBottom: 1, children: "\u26A0\uFE0F Rate Limit Exceeded" }),
2164
- /* @__PURE__ */ jsx2(Text2, { color: "gray", marginBottom: 1, children: "You've hit GitHub's API rate limit for your token." }),
2165
- /* @__PURE__ */ jsx2(Text2, { color: "gray", marginBottom: 1, children: "This happens when you make too many requests in a short time." }),
2166
- rateLimitReset && /* @__PURE__ */ jsxs2(Box2, { marginTop: 1, marginBottom: 1, children: [
2167
- /* @__PURE__ */ jsxs2(Text2, { children: [
2168
- /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "Reset in:" }),
1840
+ /* @__PURE__ */ jsx3(Box3, { flexGrow: 1, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs3(Box3, { borderStyle: "single", borderColor: "yellow", paddingX: 3, paddingY: 2, flexDirection: "column", width: Math.min(dims.cols - 8, 80), children: [
1841
+ /* @__PURE__ */ jsx3(Text3, { bold: true, color: "yellow", marginBottom: 1, children: "\u26A0\uFE0F Rate Limit Exceeded" }),
1842
+ /* @__PURE__ */ jsx3(Text3, { color: "gray", marginBottom: 1, children: "You've hit GitHub's API rate limit for your token." }),
1843
+ /* @__PURE__ */ jsx3(Text3, { color: "gray", marginBottom: 1, children: "This happens when you make too many requests in a short time." }),
1844
+ rateLimitReset && /* @__PURE__ */ jsxs3(Box3, { marginTop: 1, marginBottom: 1, children: [
1845
+ /* @__PURE__ */ jsxs3(Text3, { children: [
1846
+ /* @__PURE__ */ jsx3(Text3, { color: "cyan", children: "Reset in:" }),
2169
1847
  " ",
2170
- /* @__PURE__ */ jsx2(Text2, { bold: true, children: formatResetTime(rateLimitReset) })
1848
+ /* @__PURE__ */ jsx3(Text3, { bold: true, children: formatResetTime(rateLimitReset) })
2171
1849
  ] }),
2172
- /* @__PURE__ */ jsxs2(Text2, { color: "gray", dimColor: true, children: [
1850
+ /* @__PURE__ */ jsxs3(Text3, { color: "gray", dimColor: true, children: [
2173
1851
  "(",
2174
1852
  new Date(rateLimitReset).toLocaleTimeString(),
2175
1853
  ")"
2176
1854
  ] })
2177
1855
  ] }),
2178
- /* @__PURE__ */ jsxs2(Box2, { marginTop: 2, flexDirection: "column", gap: 1, children: [
2179
- /* @__PURE__ */ jsx2(Text2, { bold: true, children: "What would you like to do?" }),
2180
- /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", paddingLeft: 2, children: [
2181
- /* @__PURE__ */ jsxs2(Text2, { children: [
2182
- /* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "r" }),
1856
+ /* @__PURE__ */ jsxs3(Box3, { marginTop: 2, flexDirection: "column", gap: 1, children: [
1857
+ /* @__PURE__ */ jsx3(Text3, { bold: true, children: "What would you like to do?" }),
1858
+ /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", paddingLeft: 2, children: [
1859
+ /* @__PURE__ */ jsxs3(Text3, { children: [
1860
+ /* @__PURE__ */ jsx3(Text3, { color: "cyan", bold: true, children: "r" }),
2183
1861
  " - Retry now ",
2184
1862
  rateLimitReset && formatResetTime(rateLimitReset) !== "Now (should be reset)" ? "(likely to fail until reset)" : "(should work now)"
2185
1863
  ] }),
2186
- /* @__PURE__ */ jsxs2(Text2, { children: [
2187
- /* @__PURE__ */ jsx2(Text2, { color: "cyan", bold: true, children: "l" }),
1864
+ /* @__PURE__ */ jsxs3(Text3, { children: [
1865
+ /* @__PURE__ */ jsx3(Text3, { color: "cyan", bold: true, children: "l" }),
2188
1866
  " - Logout and use a different token"
2189
1867
  ] }),
2190
- /* @__PURE__ */ jsxs2(Text2, { children: [
2191
- /* @__PURE__ */ jsx2(Text2, { color: "gray", bold: true, children: "q/Esc" }),
1868
+ /* @__PURE__ */ jsxs3(Text3, { children: [
1869
+ /* @__PURE__ */ jsx3(Text3, { color: "gray", bold: true, children: "q/Esc" }),
2192
1870
  " - Quit application"
2193
1871
  ] })
2194
1872
  ] })
2195
1873
  ] }),
2196
- /* @__PURE__ */ jsx2(Text2, { color: "gray", dimColor: true, marginTop: 2, children: "Tip: Using multiple tokens or waiting between requests can help avoid rate limits." })
1874
+ /* @__PURE__ */ jsx3(Text3, { color: "gray", dimColor: true, marginTop: 2, children: "Tip: Using multiple tokens or waiting between requests can help avoid rate limits." })
2197
1875
  ] }) })
2198
1876
  ] });
2199
1877
  }
2200
1878
  if (mode === "prompt") {
2201
- return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", height: dims.rows, paddingX: 2, paddingTop: verticalPadding, paddingBottom: verticalPadding, children: [
1879
+ return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", height: dims.rows, paddingX: 2, paddingTop: verticalPadding, paddingBottom: verticalPadding, children: [
2202
1880
  header,
2203
- /* @__PURE__ */ jsx2(Box2, { flexGrow: 1, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs2(Box2, { borderStyle: "single", borderColor: "cyan", paddingX: 2, paddingY: 1, flexDirection: "column", children: [
2204
- /* @__PURE__ */ jsx2(Text2, { bold: true, marginBottom: 1, children: "Authentication Required" }),
2205
- /* @__PURE__ */ jsx2(Text2, { color: "gray", marginBottom: 1, children: "Enter your GitHub Personal Access Token" }),
2206
- /* @__PURE__ */ jsxs2(Box2, { children: [
2207
- /* @__PURE__ */ jsx2(Text2, { children: "Token: " }),
2208
- /* @__PURE__ */ jsx2(
1881
+ /* @__PURE__ */ jsx3(Box3, { flexGrow: 1, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs3(Box3, { borderStyle: "single", borderColor: "cyan", paddingX: 2, paddingY: 1, flexDirection: "column", children: [
1882
+ /* @__PURE__ */ jsx3(Text3, { bold: true, marginBottom: 1, children: "Authentication Required" }),
1883
+ /* @__PURE__ */ jsx3(Text3, { color: "gray", marginBottom: 1, children: "Enter your GitHub Personal Access Token" }),
1884
+ /* @__PURE__ */ jsxs3(Box3, { children: [
1885
+ /* @__PURE__ */ jsx3(Text3, { children: "Token: " }),
1886
+ /* @__PURE__ */ jsx3(
2209
1887
  TextInput2,
2210
1888
  {
2211
1889
  value: input,
@@ -2215,43 +1893,44 @@ function App() {
2215
1893
  }
2216
1894
  )
2217
1895
  ] }),
2218
- error && /* @__PURE__ */ jsx2(Text2, { color: "red", marginTop: 1, children: error }),
2219
- /* @__PURE__ */ jsx2(Text2, { color: "gray", dimColor: true, marginTop: 1, children: "The token will be stored securely in your local config" }),
2220
- /* @__PURE__ */ jsx2(Text2, { color: "gray", dimColor: true, marginTop: 1, children: "Press Esc to quit" })
1896
+ error && /* @__PURE__ */ jsx3(Text3, { color: "red", marginTop: 1, children: error }),
1897
+ /* @__PURE__ */ jsx3(Text3, { color: "gray", dimColor: true, marginTop: 1, children: "The token will be stored securely in your local config" }),
1898
+ /* @__PURE__ */ jsx3(Text3, { color: "gray", dimColor: true, marginTop: 1, children: "Press Esc to quit" })
2221
1899
  ] }) })
2222
1900
  ] });
2223
1901
  }
2224
1902
  if (mode === "validating" || mode === "checking") {
2225
- return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", height: dims.rows, paddingX: 2, paddingTop: verticalPadding, paddingBottom: verticalPadding, children: [
1903
+ return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", height: dims.rows, paddingX: 2, paddingTop: verticalPadding, paddingBottom: verticalPadding, children: [
2226
1904
  header,
2227
- /* @__PURE__ */ jsx2(Box2, { flexGrow: 1, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", alignItems: "center", children: [
2228
- /* @__PURE__ */ jsx2(Text2, { color: "yellow", children: "Validating token..." }),
2229
- mode === "validating" && /* @__PURE__ */ jsx2(Text2, { color: "gray", dimColor: true, marginTop: 1, children: "Press Esc to cancel" })
1905
+ /* @__PURE__ */ jsx3(Box3, { flexGrow: 1, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", alignItems: "center", children: [
1906
+ /* @__PURE__ */ jsx3(Text3, { color: "yellow", children: "Validating token..." }),
1907
+ mode === "validating" && /* @__PURE__ */ jsx3(Text3, { color: "gray", dimColor: true, marginTop: 1, children: "Press Esc to cancel" })
2230
1908
  ] }) })
2231
1909
  ] });
2232
1910
  }
2233
1911
  if (mode === "error") {
2234
- return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", height: dims.rows, paddingX: 2, paddingTop: verticalPadding, paddingBottom: verticalPadding, children: [
1912
+ return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", height: dims.rows, paddingX: 2, paddingTop: verticalPadding, paddingBottom: verticalPadding, children: [
2235
1913
  header,
2236
- /* @__PURE__ */ jsx2(Box2, { flexGrow: 1, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsx2(Text2, { color: "red", children: error ?? "Unexpected error" }) })
1914
+ /* @__PURE__ */ jsx3(Box3, { flexGrow: 1, justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsx3(Text3, { color: "red", children: error ?? "Unexpected error" }) })
2237
1915
  ] });
2238
1916
  }
2239
- return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", height: dims.rows, paddingX: 2, paddingTop: verticalPadding, paddingBottom: verticalPadding, children: [
1917
+ return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", height: dims.rows, paddingX: 2, paddingTop: verticalPadding, paddingBottom: verticalPadding, children: [
2240
1918
  header,
2241
- /* @__PURE__ */ jsx2(
1919
+ /* @__PURE__ */ jsx3(
2242
1920
  RepoList,
2243
1921
  {
2244
1922
  token,
2245
1923
  maxVisibleRows: dims.rows - verticalPadding * 2 - 4,
2246
1924
  onLogout: handleLogout,
2247
- viewerLogin: viewer ?? void 0
1925
+ viewerLogin: viewer ?? void 0,
1926
+ onOrgContextChange: setOrgContext
2248
1927
  }
2249
1928
  )
2250
1929
  ] });
2251
1930
  }
2252
1931
 
2253
1932
  // src/index.tsx
2254
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1933
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
2255
1934
  if (process.env.GH_MANAGER_DEBUG === "1") {
2256
1935
  process.stderr.write("\u{1F41B} Debug mode enabled\n");
2257
1936
  }
@@ -2264,8 +1943,8 @@ process.on("unhandledRejection", (reason) => {
2264
1943
  process.exit(1);
2265
1944
  });
2266
1945
  render(
2267
- /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
2268
- /* @__PURE__ */ jsx3(App, {}),
2269
- /* @__PURE__ */ jsx3(Text3, { color: "gray" })
1946
+ /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
1947
+ /* @__PURE__ */ jsx4(App, {}),
1948
+ /* @__PURE__ */ jsx4(Text4, { color: "gray" })
2270
1949
  ] })
2271
1950
  );