fix(agent-help): skip trail probe when logged out · Entire
fix(agent-help): skip trail probe when logged out
401373c→main·
dipree·2d ago·2 files·+43 added/-0 removed
Sessions
01KXJYA9NRAFDQ1PS32D360Q9WView transcript
[?
Fix Agent Help Trail AvailabilityPi·GPT-5.6-sol·3 steps](/content/gh/entireio/cli/session/019f65cc-0712-7af1-9340-2ded310ed0f4#timeline-01KXJYA9NRAFDQ1PS32D360Q9W/index.html)
Changes
2
cmd/entire/cli
Magent_help_cmd.go+8
Magent_help_cmd_test.go+35
88 unmodified lines
89
90
91
92
93
94
95
96
97
98
99
100
101
102
88 unmodified lines
\trepoLine = scope.RepoKey
\t}
\n\t// ResolveDataAPIToken performs data-host discovery before it can reject a
\t// missing login. The scope already carries the locally resolved auth identity,
\t// so avoid making an unauthenticated first run wait on a network request that
\t// cannot produce an enabled decision.
\tif scope.AuthKey == "" {
\t\treturn repoLine, false
\t}
\trefreshCtx, cancel := context.WithTimeout(ctx, trailEnablementRefreshTimeout)
\tdefer cancel()
\tif err := refresh(refreshCtx, scope); err != nil {
Mcmd/entire/cli/agent_help_cmd.go+8
98 unmodified lines
99
100
101
102
103
104
105
24 unmodified lines
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
98 unmodified lines
// repo-scoped trails availability check instead of being treated as disabled.
// Not parallel: changes the process working directory.
func TestAgentHelpRepoContext_RefreshesUnknownTrailsEnablement(t *testing.T) {
\tt.Setenv("ENTIRE_TOKEN", makeTestJWT(t, `{\"iss\":\"https://auth.entire.io\",\"sub\":\"user-1\",\"handle\":\"alice\",\"aud\":\"https://entire.io\"}`))
\trepoDir := t.TempDir()
\ttestutil.InitRepo(t, repoDir)
\tcmd := exec.CommandContext(t.Context(), "git", "remote", "add", "origin", "git@github.com:acme/app.git")
24 unmodified lines
\t}
// Without a local auth identity, refreshing cannot produce a usable trails
// decision. Skip it locally so agent-help does not block on API discovery before
// auth eventually reports that the user is not logged in.
// Not parallel: changes the process working directory and auth environment.
func TestAgentHelpRepoContext_SkipsRefreshWithoutLocalIdentity(t *testing.T) {
\tt.Setenv("ENTIRE_TOKEN", "")
\tt.Setenv("ENTIRE_CONFIG_DIR", t.TempDir())
\trepoDir := t.TempDir()
\ttestutil.InitRepo(t, repoDir)
\tcmd := exec.CommandContext(t.Context(), "git", "remote", "add", "origin", "git@github.com:acme/app.git")
\tcmd.Dir = repoDir
\tcmd.Env = testutil.GitIsolatedEnv()
\tif err := cmd.Run(); err != nil {
\t\tt.Fatalf("git remote add: %%v", err)
\t}
\tt.Chdir(repoDir)
\trefreshCalls := 0
\trepoLine, enabled := agentHelpRepoContextWithRefresh(t.Context(), func(context.Context, trailEnablementScope) error {
\t\trefreshCalls++
\t\treturn nil
\t})
\tif refreshCalls != 0 {
\t\tt.Fatalf("refresh calls = %%d, want 0 without a local auth identity", refreshCalls)
\t}
\tif repoLine != "gh/acme/app" {
\t\tt.Errorf("repo line = %%q, want gh/acme/app", repoLine)
\t}
\tif enabled {
\t\tt.Fatal("trails should not be advertised without a local auth identity")
\t}
}
// Drilling into a trail-gated command is blocked when trails are disabled.
func TestRunAgentHelp_TrailDrillGatedOnTrailsEnabled(t *testing.T) {
\tt.Parallel()