cursor icon indicating copy to clipboard operation
cursor copied to clipboard

Terminal contents as autocomplete context

Open jacobparis opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe. I'm working on an interactive patch tool that, when it fails to apply a patch automatically, outputs the diff to the terminal and pauses to allow the dev to make the changes manually. This can happen quite often in some codebases and isn't hard to resolve but it gets a bit tedious. The terminal output looks like this

Patch rejected for app/routes/_auth+/onboarding_.$provider.tsx
@@ -86,1 +87,1 @@ exercises/01.create/01.problem.nested-routing/app/routes/_auth+/onboarding_.$provider.tsx:86
-       const authSession = await authSessionStorage.getSession(
+       const connectionSession = await connectionSessionStorage.getSession(
@@ -94,1 +95,2 @@ exercises/01.create/01.problem.nested-routing/app/routes/_auth+/onboarding_.$provider.tsx:94
-       const formError = authSession.get(authenticator.sessionErrorKey)
+       const formError = connectionSession.get(authenticator.sessionErrorKey)
+       const hasError = typeof formError === 'string'
@@ -100,1 +101,1 @@ exercises/01.create/01.problem.nested-routing/app/routes/_auth+/onboarding_.$provider.tsx:100
-                       status: 'error',
+                       status: hasError ? 'error' : undefined,
@@ -102,3 +103,1 @@ exercises/01.create/01.problem.nested-routing/app/routes/_auth+/onboarding_.$provider.tsx:102
-                       error: {
-                               '': typeof formError === 'string' ? [formError] : [],
-                       },
+                       error: { '': hasError ? [formError] : [] },
@@ -133,1 +133,1 @@ exercises/01.create/01.problem.nested-routing/app/routes/_auth+/onboarding_.$provider.tsx:133
-               }).transform(async data => {
+               }).transform(async (data) => {
@@ -181,1 +181,1 @@ exercises/01.create/01.problem.nested-routing/app/routes/_auth+/onboarding_.$provider.tsx:181
- export default function SignupRoute() {
+ export default function OnboardingProviderRoute() {

Please resolve the conflict, stage the changes, and press Enter to continue...

Describe the solution you'd like

For this use-case, it'd be cool if the autocomplete text could take the last terminal output as additional context to guide its completions: I could imagine Cursor working really well here and basically letting me just tab complete each of these corrections.

I suspect this would also be useful for error messages with stack traces, helping guide the autofix.

If accepting all the terminal output is unfeasible it may be reasonable to look for filenames and line markers and include as context when the cursor is near that point?

jacobparis avatar Aug 04 '24 03:08 jacobparis